ar71xx: ag71xx: fix MAC address setup
[openwrt.git] / toolchain / uClibc / patches-0.9.30.2 / 600-ubicom32-uClibc.patch
1 Index: uClibc-0.9.30.2/Rules.mak
2 ===================================================================
3 --- uClibc-0.9.30.2.orig/Rules.mak 2010-01-13 22:22:31.000000000 +0100
4 +++ uClibc-0.9.30.2/Rules.mak 2010-01-14 11:05:01.000000000 +0100
5 @@ -406,6 +406,17 @@
6 SYMBOL_PREFIX=_
7 endif
8
9 +ifeq ($(TARGET_ARCH),ubicom32)
10 + OPTIMIZATION+=-fstrict-aliasing
11 + CPU_CFLAGS-$(CONFIG_UBICOM32_V3)+=-march=ubicom32v3
12 + CPU_CFLAGS-$(CONFIG_UBICOM32_V4)+=-march=ubicom32v4
13 +ifeq ($(UCLIBC_FORMAT_FDPIC_ELF),y)
14 + CPU_CFLAGS-y:=-mfdpic
15 + CPU_LDFLAGS-y += -Wl,-melf32ubicom32fdpic
16 +endif
17 +
18 +endif
19 +
20 ifeq ($(TARGET_ARCH),v850)
21 SYMBOL_PREFIX=_
22 endif
23 Index: uClibc-0.9.30.2/extra/Configs/Config.in
24 ===================================================================
25 --- uClibc-0.9.30.2.orig/extra/Configs/Config.in 2010-01-13 22:22:31.000000000 +0100
26 +++ uClibc-0.9.30.2/extra/Configs/Config.in 2010-01-14 11:05:01.000000000 +0100
27 @@ -73,6 +73,9 @@
28 config TARGET_sparc
29 bool "sparc"
30
31 +config TARGET_ubicom32
32 + bool "ubicom32"
33 +
34 config TARGET_v850
35 bool "v850 (BROKEN)"
36
37 @@ -174,6 +177,10 @@
38 source "extra/Configs/Config.sparc"
39 endif
40
41 +if TARGET_ubicom32
42 +source "extra/Configs/Config.ubicom32"
43 +endif
44 +
45 if TARGET_v850
46 source "extra/Configs/Config.v850"
47 endif
48 Index: uClibc-0.9.30.2/extra/Configs/Config.in.arch
49 ===================================================================
50 --- uClibc-0.9.30.2.orig/extra/Configs/Config.in.arch 2010-01-13 22:22:31.000000000 +0100
51 +++ uClibc-0.9.30.2/extra/Configs/Config.in.arch 2010-01-14 11:05:01.000000000 +0100
52 @@ -149,7 +149,7 @@
53 config DO_C99_MATH
54 bool "Enable full C99 math library support"
55 depends on UCLIBC_HAS_FLOATS
56 - default n
57 + default y
58 help
59 If you want the uClibc math library to contain the full set C99
60 math library features, then answer Y. If you leave this set to
61 Index: uClibc-0.9.30.2/extra/Configs/Config.ubicom32
62 ===================================================================
63 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
64 +++ uClibc-0.9.30.2/extra/Configs/Config.ubicom32 2010-01-14 11:05:01.000000000 +0100
65 @@ -0,0 +1,44 @@
66 +#
67 +# For a description of the syntax of this configuration file,
68 +# see extra/config/Kconfig-language.txt
69 +#
70 +
71 +config TARGET_ARCH
72 + string
73 + default "ubicom32"
74 +
75 +config FORCE_OPTIONS_FOR_ARCH
76 + bool
77 + default y
78 + select ARCH_BIG_ENDIAN
79 + select ARCH_HAS_NO_MMU
80 +
81 +choice
82 + prompt "Target Processor Architecture"
83 + default CONFIG_UC_UBICOM32_V3
84 + help
85 + This selects the instruction set architecture of your Ubicom32 CPU. This
86 + information is used for optimizing purposes. To build a library that
87 + will run on any Ubicom32 CPU, you can specify "v3" here.
88 + If you pick anything other than "v3," there is no
89 + guarantee that uClibc will even run on anything other than the
90 + selected processor type.
91 +
92 + You should probably select the Ubicom32 ISA that best matches the
93 + CPU you will be using on your device. uClibc will be tuned
94 + for that architecture.
95 +
96 + If you don't know what to do, choose "v3"
97 +
98 +config CONFIG_UC_UBICOM32_V3
99 + bool "ISA v3"
100 +
101 +config CONFIG_UC_UBICOM32_V4
102 + bool "ISA v4"
103 +endchoice
104 +
105 +config ARCH_CFLAGS
106 + string
107 +
108 +config CROSS
109 + string
110 Index: uClibc-0.9.30.2/include/elf.h
111 ===================================================================
112 --- uClibc-0.9.30.2.orig/include/elf.h 2010-01-13 22:22:31.000000000 +0100
113 +++ uClibc-0.9.30.2/include/elf.h 2010-01-14 11:06:14.000000000 +0100
114 @@ -337,6 +337,8 @@
115
116 #define EM_XSTORMY16 0xad45
117
118 +#define EM_UBICOM32 0xde3d /* Ubicom32; no ABI */
119 +
120 /* FRV magic number - no EABI available??. */
121 #define EM_CYGNUS_FRV 0x5441
122
123 @@ -3063,6 +3065,55 @@
124 /* Keep this the last entry. */
125 #define R_XTENSA_NUM 50
126
127 +/* Ubicom32 ELF relocation types */
128 +#define R_UBICOM32_NONE 0
129 +#define R_UBICOM32_16 1
130 +#define R_UBICOM32_32 2
131 +#define R_UBICOM32_LO16 3
132 +#define R_UBICOM32_HI16 4
133 +#define R_UBICOM32_21_PCREL 5
134 +#define R_UBICOM32_24_PCREL 6
135 +#define R_UBICOM32_HI24 7
136 +#define R_UBICOM32_LO7_S 8
137 +#define R_UBICOM32_LO7_2_S 9
138 +#define R_UBICOM32_LO7_4_S 10
139 +#define R_UBICOM32_LO7_D 11
140 +#define R_UBICOM32_LO7_2_D 12
141 +#define R_UBICOM32_LO7_4_D 13
142 +#define R_UBICOM32_32_HARVARD 14
143 +#define R_UBICOM32_LO7_CALLI 15
144 +#define R_UBICOM32_LO16_CALLI 16
145 +#define R_UBICOM32_GOT_HI24 17
146 +#define R_UBICOM32_GOT_LO7_S 18
147 +#define R_UBICOM32_GOT_LO7_2_S 19
148 +#define R_UBICOM32_GOT_LO7_4_S 20
149 +#define R_UBICOM32_GOT_LO7_D 21
150 +#define R_UBICOM32_GOT_LO7_2_D 22
151 +#define R_UBICOM32_GOT_LO7_4_D 23
152 +#define R_UBICOM32_FUNCDESC_GOT_HI24 24
153 +#define R_UBICOM32_FUNCDESC_GOT_LO7_S 25
154 +#define R_UBICOM32_FUNCDESC_GOT_LO7_2_S 26
155 +#define R_UBICOM32_FUNCDESC_GOT_LO7_4_S 27
156 +#define R_UBICOM32_FUNCDESC_GOT_LO7_D 28
157 +#define R_UBICOM32_FUNCDESC_GOT_LO7_2_D 29
158 +#define R_UBICOM32_FUNCDESC_GOT_LO7_4_D 30
159 +#define R_UBICOM32_GOT_LO7_CALLI 31
160 +#define R_UBICOM32_FUNCDESC_GOT_LO7_CALLI 32
161 +#define R_UBICOM32_FUNCDESC_VALUE 33
162 +#define R_UBICOM32_FUNCDESC 34
163 +#define R_UBICOM32_GOTOFFSET_LO 35
164 +#define R_UBICOM32_GOTOFFSET_HI 36
165 +#define R_UBICOM32_FUNCDESC_GOTOFFSET_LO 37
166 +#define R_UBICOM32_FUNCDESC_GOTOFFSET_HI 38
167 +#define R_UBICOM32_GNU_VTINHERIT 200
168 +#define R_UBICOM32_GNU_VTENTRY 201
169 +
170 +/* Ubicom32 Flags. */
171 +#define EF_UBICOM32_V3 0x00000001 /* -fmarch=ubicom32v3 */
172 +#define EF_UBICOM32_V4 0x00000002 /* -fmarch=ubicom32v4 */
173 +#define EF_UBICOM32_PIC 0x80000000 /* -fpic */
174 +#define EF_UBICOM32_FDPIC 0x40000000 /* -mfdpic */
175 +
176 #ifdef __cplusplus
177 }
178 #endif
179 Index: uClibc-0.9.30.2/include/features.h
180 ===================================================================
181 --- uClibc-0.9.30.2.orig/include/features.h 2010-01-13 22:22:31.000000000 +0100
182 +++ uClibc-0.9.30.2/include/features.h 2010-01-14 11:05:01.000000000 +0100
183 @@ -451,4 +451,10 @@
184 # define __linux__ 1
185 #endif
186
187 +#ifndef libc_hidden_proto
188 +#define libc_hidden_proto(name, attrs...)
189 +#endif
190 +#ifndef libm_hidden_proto
191 +#define libm_hidden_proto(name, attrs...)
192 +#endif
193 #endif /* features.h */
194 Index: uClibc-0.9.30.2/ldso/ldso/dl-startup.c
195 ===================================================================
196 --- uClibc-0.9.30.2.orig/ldso/ldso/dl-startup.c 2010-01-13 22:22:31.000000000 +0100
197 +++ uClibc-0.9.30.2/ldso/ldso/dl-startup.c 2010-01-14 11:05:01.000000000 +0100
198 @@ -164,10 +164,13 @@
199 aux_dat += 2;
200 }
201
202 +#if !defined __FDPIC__
203 /* locate the ELF header. We need this done as soon as possible
204 * (esp since SEND_STDERR() needs this on some platforms... */
205 if (!auxvt[AT_BASE].a_un.a_val)
206 auxvt[AT_BASE].a_un.a_val = elf_machine_load_address();
207 +#endif
208 +
209 DL_INIT_LOADADDR_BOOT(load_addr, auxvt[AT_BASE].a_un.a_val);
210 header = (ElfW(Ehdr) *) auxvt[AT_BASE].a_un.a_val;
211
212 Index: uClibc-0.9.30.2/ldso/ldso/ldso.c
213 ===================================================================
214 --- uClibc-0.9.30.2.orig/ldso/ldso/ldso.c 2010-01-13 22:22:31.000000000 +0100
215 +++ uClibc-0.9.30.2/ldso/ldso/ldso.c 2010-01-14 11:05:01.000000000 +0100
216 @@ -179,10 +179,12 @@
217 _dl_progname = argv[0];
218 }
219
220 +#if 0 // blackfin does this, we do to avoid die during reloc
221 if (_start == (void *) auxvt[AT_ENTRY].a_un.a_val) {
222 _dl_dprintf(_dl_debug_file, "Standalone execution is not supported yet\n");
223 _dl_exit(1);
224 }
225 +#endif
226
227 /* Start to build the tables of the modules that are required for
228 * this beast to run. We start with the basic executable, and then
229 Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-debug.h
230 ===================================================================
231 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
232 +++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-debug.h 2010-01-14 11:05:01.000000000 +0100
233 @@ -0,0 +1,72 @@
234 +/* vi: set sw=4 ts=4: */
235 +/* Ubicom32 ELF shared library loader suppport
236 + *
237 + * Copyright (c) 2009 Ubicom Inc.
238 + * Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
239 + * David Engel, Hongjiu Lu and Mitch D'Souza
240 + * Copyright (C) 2001-2004 Erik Andersen
241 + *
242 + * All rights reserved.
243 + *
244 + * Redistribution and use in source and binary forms, with or without
245 + * modification, are permitted provided that the following conditions
246 + * are met:
247 + * 1. Redistributions of source code must retain the above copyright
248 + * notice, this list of conditions and the following disclaimer.
249 + * 2. The name of the above contributors may not be
250 + * used to endorse or promote products derived from this software
251 + * without specific prior written permission.
252 + *
253 + * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
254 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
255 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
256 + * ARE DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
257 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
258 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
259 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
260 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
261 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
262 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
263 + * SUCH DAMAGE.
264 + */
265 +
266 +static const char *_dl_reltypes_tab[] =
267 +{
268 + "R_UBICOM32_NONE", /* 0 */
269 + "R_UBICOM32_16",
270 + "R_UBICOM32_32",
271 + "R_UBICOM32_LO16",
272 + "R_UBICOM32_HI16",
273 + "R_UBICOM32_21_PCREL", /* 5 */
274 + "R_UBICOM32_24_PCREL",
275 + "R_UBICOM32_HI24",
276 + "R_UBICOM32_LO7_S",
277 + "R_UBICOM32_LO7_2_S",
278 + "R_UBICOM32_LO7_4_S", /* 10 */
279 + "R_UBICOM32_LO7_D",
280 + "R_UBICOM32_LO7_2_D",
281 + "R_UBICOM32_LO7_4_D",
282 + "R_UBICOM32_32_HARVARD",
283 + "R_UBICOM32_LO7_CALLI", /* 15 */
284 + "R_UBICOM32_LO16_CALLI",
285 + "R_UBICOM32_GOT_HI24",
286 + "R_UBICOM32_GOT_LO7_S",
287 + "R_UBICOM32_GOT_LO7_2_S"
288 + "R_UBICOM32_GOT_LO7_4_S", /* 20 */
289 + "R_UBICOM32_GOT_LO7_D",
290 + "R_UBICOM32_GOT_LO7_2_D",
291 + "R_UBICOM32_GOT_LO7_4_D",
292 + "R_UBICOM32_FUNCDESC_GOT_HI24 24",
293 + "R_UBICOM32_FUNCDESC_GOT_LO7_S", /* 25 */
294 + "R_UBICOM32_FUNCDESC_GOT_LO7_2_S",
295 + "R_UBICOM32_FUNCDESC_GOT_LO7_4_S",
296 + "R_UBICOM32_FUNCDESC_GOT_LO7_D",
297 + "R_UBICOM32_FUNCDESC_GOT_LO7_2_D",
298 + "R_UBICOM32_FUNCDESC_GOT_LO7_4_D", /* 30 */
299 + "R_UBICOM32_GOT_LO7_CALLI",
300 + "R_UBICOM32_FUNCDESC_VALUE",
301 + "R_UBICOM32_FUNCDESC",
302 +#if 1
303 + [200] "R_UBICOM32_GNU_VTINHERIT" , "R_UBICOM32_GNU_VTENTRY"
304 +#endif
305 +};
306 Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-inlines.h
307 ===================================================================
308 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
309 +++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-inlines.h 2010-01-14 11:05:01.000000000 +0100
310 @@ -0,0 +1,582 @@
311 + /* Copyright (C) 2003, 2004 Red Hat, Inc.
312 + Contributed by Alexandre Oliva <aoliva@redhat.com>
313 +
314 +This file is part of uClibc.
315 +
316 +uClibc is free software; you can redistribute it and/or modify it
317 +under the terms of the GNU Lesser General Public License as
318 +published by the Free Software Foundation; either version 2.1 of the
319 +License, or (at your option) any later version.
320 +
321 +uClibc is distributed in the hope that it will be useful, but WITHOUT
322 +ANY WARRANTY; without even the implied warranty of
323 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
324 +Library General Public License for more details.
325 +
326 +You should have received a copy of the GNU Lesser General Public
327 +License along with uClibc; see the file COPYING.LIB. If not, write to
328 +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
329 +USA. */
330 +
331 +//#include <bfin_sram.h>
332 +#define SRAM_TEST(x) 0
333 +#ifndef _dl_assert
334 +# define _dl_assert(expr)
335 +#endif
336 +
337 +/* Initialize a DL_LOADADDR_TYPE given a got pointer and a complete
338 + load map. */
339 +static __always_inline void
340 +__dl_init_loadaddr_map (struct elf32_fdpic_loadaddr *loadaddr, Elf32_Addr dl_boot_got_pointer,
341 + struct elf32_fdpic_loadmap *map)
342 +{
343 + if (map->version != 0)
344 + {
345 + SEND_EARLY_STDERR ("Invalid loadmap version number\n");
346 + _dl_exit(-1);
347 + }
348 + if (map->nsegs == 0)
349 + {
350 + SEND_EARLY_STDERR ("Invalid segment count in loadmap\n");
351 + _dl_exit(-1);
352 + }
353 + loadaddr->got_value = (void*)dl_boot_got_pointer;
354 + loadaddr->map = map;
355 +}
356 +
357 +/* Figure out how many LOAD segments there are in the given headers,
358 + and allocate a block for the load map big enough for them.
359 + got_value will be properly initialized later on, with INIT_GOT. */
360 +static __always_inline int
361 +__dl_init_loadaddr (struct elf32_fdpic_loadaddr *loadaddr, Elf32_Phdr *ppnt,
362 + int pcnt)
363 +{
364 + int count = 0, i;
365 + size_t size;
366 +
367 + for (i = 0; i < pcnt; i++)
368 + if (ppnt[i].p_type == PT_LOAD)
369 + count++;
370 +
371 + loadaddr->got_value = 0;
372 +
373 + size = sizeof (struct elf32_fdpic_loadmap)
374 + + sizeof (struct elf32_fdpic_loadseg) * count;
375 + loadaddr->map = _dl_malloc (size);
376 + if (! loadaddr->map)
377 + _dl_exit (-1);
378 +
379 + loadaddr->map->version = 0;
380 + loadaddr->map->nsegs = 0;
381 +
382 + return count;
383 +}
384 +
385 +#if defined (__SUPPORT_LD_DEBUG__)
386 +extern char *_dl_debug;
387 +extern int _dl_debug_file;
388 +#endif
389 +
390 +/* Incrementally initialize a load map. */
391 +static __always_inline void
392 +__dl_init_loadaddr_hdr (struct elf32_fdpic_loadaddr loadaddr, void *addr,
393 + Elf32_Phdr *phdr, int maxsegs)
394 +{
395 + struct elf32_fdpic_loadseg *segdata;
396 +
397 + if (loadaddr.map->nsegs == maxsegs)
398 + _dl_exit (-1);
399 +
400 + segdata = &loadaddr.map->segs[loadaddr.map->nsegs++];
401 + segdata->addr = (Elf32_Addr) addr;
402 + segdata->p_vaddr = phdr->p_vaddr;
403 + segdata->p_memsz = phdr->p_memsz;
404 +
405 +#if defined (__SUPPORT_LD_DEBUG__)
406 + {
407 + if (_dl_debug)
408 + _dl_dprintf(_dl_debug_file, "%i: mapped %x at %x, size %x\n",
409 + loadaddr.map->nsegs-1,
410 + segdata->p_vaddr, segdata->addr, segdata->p_memsz);
411 + }
412 +#endif
413 +}
414 +
415 +static __always_inline void __dl_loadaddr_unmap
416 +(struct elf32_fdpic_loadaddr loadaddr, struct funcdesc_ht *funcdesc_ht);
417 +
418 +/* Figure out whether the given address is in one of the mapped
419 + segments. */
420 +static __always_inline int
421 +__dl_addr_in_loadaddr (void *p, struct elf32_fdpic_loadaddr loadaddr)
422 +{
423 + struct elf32_fdpic_loadmap *map = loadaddr.map;
424 + int c;
425 +
426 + for (c = 0; c < map->nsegs; c++)
427 + if ((void*)map->segs[c].addr <= p
428 + && (char*)p < (char*)map->segs[c].addr + map->segs[c].p_memsz)
429 + return 1;
430 +
431 + return 0;
432 +}
433 +
434 +static __always_inline void * _dl_funcdesc_for (void *entry_point, void *got_value);
435 +
436 +/* The hashcode handling code below is heavily inspired in libiberty's
437 + hashtab code, but with most adaptation points and support for
438 + deleting elements removed.
439 +
440 + Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
441 + Contributed by Vladimir Makarov (vmakarov@cygnus.com). */
442 +
443 +static __always_inline unsigned long
444 +higher_prime_number (unsigned long n)
445 +{
446 + /* These are primes that are near, but slightly smaller than, a
447 + power of two. */
448 + static const unsigned long primes[] = {
449 + (unsigned long) 7,
450 + (unsigned long) 13,
451 + (unsigned long) 31,
452 + (unsigned long) 61,
453 + (unsigned long) 127,
454 + (unsigned long) 251,
455 + (unsigned long) 509,
456 + (unsigned long) 1021,
457 + (unsigned long) 2039,
458 + (unsigned long) 4093,
459 + (unsigned long) 8191,
460 + (unsigned long) 16381,
461 + (unsigned long) 32749,
462 + (unsigned long) 65521,
463 + (unsigned long) 131071,
464 + (unsigned long) 262139,
465 + (unsigned long) 524287,
466 + (unsigned long) 1048573,
467 + (unsigned long) 2097143,
468 + (unsigned long) 4194301,
469 + (unsigned long) 8388593,
470 + (unsigned long) 16777213,
471 + (unsigned long) 33554393,
472 + (unsigned long) 67108859,
473 + (unsigned long) 134217689,
474 + (unsigned long) 268435399,
475 + (unsigned long) 536870909,
476 + (unsigned long) 1073741789,
477 + (unsigned long) 2147483647,
478 + /* 4294967291L */
479 + ((unsigned long) 2147483647) + ((unsigned long) 2147483644),
480 + };
481 +
482 + const unsigned long *low = &primes[0];
483 + const unsigned long *high = &primes[sizeof(primes) / sizeof(primes[0])];
484 +
485 + while (low != high)
486 + {
487 + const unsigned long *mid = low + (high - low) / 2;
488 + if (n > *mid)
489 + low = mid + 1;
490 + else
491 + high = mid;
492 + }
493 +
494 +#if 0
495 + /* If we've run out of primes, abort. */
496 + if (n > *low)
497 + {
498 + fprintf (stderr, "Cannot find prime bigger than %lu\n", n);
499 + abort ();
500 + }
501 +#endif
502 +
503 + return *low;
504 +}
505 +
506 +struct funcdesc_ht
507 +{
508 + /* Table itself. */
509 + struct funcdesc_value **entries;
510 +
511 + /* Current size (in entries) of the hash table */
512 + size_t size;
513 +
514 + /* Current number of elements. */
515 + size_t n_elements;
516 +};
517 +
518 +static __always_inline int
519 +hash_pointer (const void *p)
520 +{
521 + return (int) ((long)p >> 3);
522 +}
523 +
524 +static __always_inline struct funcdesc_ht *
525 +htab_create (void)
526 +{
527 + struct funcdesc_ht *ht = _dl_malloc (sizeof (struct funcdesc_ht));
528 +
529 + if (! ht)
530 + return NULL;
531 + ht->size = 3;
532 + ht->entries = _dl_malloc (sizeof (struct funcdesc_ht_value *) * ht->size);
533 + if (! ht->entries)
534 + return NULL;
535 +
536 + ht->n_elements = 0;
537 +
538 + _dl_memset (ht->entries, 0, sizeof (struct funcdesc_ht_value *) * ht->size);
539 +
540 + return ht;
541 +}
542 +
543 +/* This is only called from _dl_loadaddr_unmap, so it's safe to call
544 + _dl_free(). See the discussion below. */
545 +static __always_inline void
546 +htab_delete (struct funcdesc_ht *htab)
547 +{
548 + int i;
549 +
550 + for (i = htab->size - 1; i >= 0; i--)
551 + if (htab->entries[i])
552 + _dl_free (htab->entries[i]);
553 +
554 + _dl_free (htab->entries);
555 + _dl_free (htab);
556 +}
557 +
558 +/* Similar to htab_find_slot, but without several unwanted side effects:
559 + - Does not call htab->eq_f when it finds an existing entry.
560 + - Does not change the count of elements/searches/collisions in the
561 + hash table.
562 + This function also assumes there are no deleted entries in the table.
563 + HASH is the hash value for the element to be inserted. */
564 +
565 +static __always_inline struct funcdesc_value **
566 +find_empty_slot_for_expand (struct funcdesc_ht *htab, int hash)
567 +{
568 + size_t size = htab->size;
569 + unsigned int index = hash % size;
570 + struct funcdesc_value **slot = htab->entries + index;
571 + int hash2;
572 +
573 + if (! *slot)
574 + return slot;
575 +
576 + hash2 = 1 + hash % (size - 2);
577 + for (;;)
578 + {
579 + index += hash2;
580 + if (index >= size)
581 + index -= size;
582 +
583 + slot = htab->entries + index;
584 + if (! *slot)
585 + return slot;
586 + }
587 +}
588 +
589 +/* The following function changes size of memory allocated for the
590 + entries and repeatedly inserts the table elements. The occupancy
591 + of the table after the call will be about 50%. Naturally the hash
592 + table must already exist. Remember also that the place of the
593 + table entries is changed. If memory allocation failures are allowed,
594 + this function will return zero, indicating that the table could not be
595 + expanded. If all goes well, it will return a non-zero value. */
596 +
597 +static __always_inline int
598 +htab_expand (struct funcdesc_ht *htab)
599 +{
600 + struct funcdesc_value **oentries;
601 + struct funcdesc_value **olimit;
602 + struct funcdesc_value **p;
603 + struct funcdesc_value **nentries;
604 + size_t nsize;
605 +
606 + oentries = htab->entries;
607 + olimit = oentries + htab->size;
608 +
609 + /* Resize only when table after removal of unused elements is either
610 + too full or too empty. */
611 + if (htab->n_elements * 2 > htab->size)
612 + nsize = higher_prime_number (htab->n_elements * 2);
613 + else
614 + nsize = htab->size;
615 +
616 + nentries = _dl_malloc (sizeof (struct funcdesc_value *) * nsize);
617 + _dl_memset (nentries, 0, sizeof (struct funcdesc_value *) * nsize);
618 + if (nentries == NULL)
619 + return 0;
620 + htab->entries = nentries;
621 + htab->size = nsize;
622 +
623 + p = oentries;
624 + do
625 + {
626 + if (*p)
627 + *find_empty_slot_for_expand (htab, hash_pointer ((*p)->entry_point))
628 + = *p;
629 +
630 + p++;
631 + }
632 + while (p < olimit);
633 +
634 +#if 0 /* We can't tell whether this was allocated by the _dl_malloc()
635 + built into ld.so or malloc() in the main executable or libc,
636 + and calling free() for something that wasn't malloc()ed could
637 + do Very Bad Things (TM). Take the conservative approach
638 + here, potentially wasting as much memory as actually used by
639 + the hash table, even if multiple growths occur. That's not
640 + so bad as to require some overengineered solution that would
641 + enable us to keep track of how it was allocated. */
642 + _dl_free (oentries);
643 +#endif
644 + return 1;
645 +}
646 +
647 +/* This function searches for a hash table slot containing an entry
648 + equal to the given element. To delete an entry, call this with
649 + INSERT = 0, then call htab_clear_slot on the slot returned (possibly
650 + after doing some checks). To insert an entry, call this with
651 + INSERT = 1, then write the value you want into the returned slot.
652 + When inserting an entry, NULL may be returned if memory allocation
653 + fails. */
654 +
655 +static __always_inline struct funcdesc_value **
656 +htab_find_slot (struct funcdesc_ht *htab, void *ptr, int insert)
657 +{
658 + unsigned int index;
659 + int hash, hash2;
660 + size_t size;
661 + struct funcdesc_value **entry;
662 +
663 + if (htab->size * 3 <= htab->n_elements * 4
664 + && htab_expand (htab) == 0)
665 + return NULL;
666 +
667 + hash = hash_pointer (ptr);
668 +
669 + size = htab->size;
670 + index = hash % size;
671 +
672 + entry = &htab->entries[index];
673 + if (!*entry)
674 + goto empty_entry;
675 + else if ((*entry)->entry_point == ptr)
676 + return entry;
677 +
678 + hash2 = 1 + hash % (size - 2);
679 + for (;;)
680 + {
681 + index += hash2;
682 + if (index >= size)
683 + index -= size;
684 +
685 + entry = &htab->entries[index];
686 + if (!*entry)
687 + goto empty_entry;
688 + else if ((*entry)->entry_point == ptr)
689 + return entry;
690 + }
691 +
692 + empty_entry:
693 + if (!insert)
694 + return NULL;
695 +
696 + htab->n_elements++;
697 + return entry;
698 +}
699 +
700 +void *
701 +_dl_funcdesc_for (void *entry_point, void *got_value)
702 +{
703 + struct elf_resolve *tpnt = ((void**)got_value)[2];
704 + struct funcdesc_ht *ht = tpnt->funcdesc_ht;
705 + struct funcdesc_value **entry;
706 +
707 + _dl_assert (got_value == tpnt->loadaddr.got_value);
708 +
709 + if (! ht)
710 + {
711 + ht = htab_create ();
712 + if (! ht)
713 + return (void*)-1;
714 + tpnt->funcdesc_ht = ht;
715 + }
716 +
717 + entry = htab_find_slot (ht, entry_point, 1);
718 + if (*entry)
719 + {
720 + _dl_assert ((*entry)->entry_point == entry_point);
721 + return _dl_stabilize_funcdesc (*entry);
722 + }
723 +
724 + *entry = _dl_malloc (sizeof (struct funcdesc_value));
725 + (*entry)->entry_point = entry_point;
726 + (*entry)->got_value = got_value;
727 +
728 + return _dl_stabilize_funcdesc (*entry);
729 +}
730 +
731 +static __always_inline void const *
732 +_dl_lookup_address (void const *address)
733 +{
734 + struct elf_resolve *rpnt;
735 + struct funcdesc_value const *fd;
736 +
737 + /* Make sure we don't make assumptions about its alignment. */
738 + __asm__ ("" : "+r" (address));
739 +
740 + if ((Elf32_Addr)address & 7)
741 + /* It's not a function descriptor. */
742 + return address;
743 +
744 + fd = (struct funcdesc_value const *)address;
745 +
746 + for (rpnt = _dl_loaded_modules; rpnt; rpnt = rpnt->next)
747 + {
748 + if (! rpnt->funcdesc_ht)
749 + continue;
750 +
751 + if (fd->got_value != rpnt->loadaddr.got_value)
752 + continue;
753 +
754 + address = htab_find_slot (rpnt->funcdesc_ht, (void*)fd->entry_point, 0);
755 +
756 + if (address && *(struct funcdesc_value *const*)address == fd)
757 + {
758 + address = (*(struct funcdesc_value *const*)address)->entry_point;
759 + break;
760 + }
761 + else
762 + address = fd;
763 + }
764 +
765 + return address;
766 +}
767 +
768 +void
769 +__dl_loadaddr_unmap (struct elf32_fdpic_loadaddr loadaddr,
770 + struct funcdesc_ht *funcdesc_ht)
771 +{
772 + int i;
773 +
774 + for (i = 0; i < loadaddr.map->nsegs; i++)
775 + {
776 + struct elf32_fdpic_loadseg *segdata;
777 + ssize_t offs;
778 + segdata = loadaddr.map->segs + i;
779 +
780 +#if 0 /* SRAM */
781 + /* FIXME:
782 + A more cleaner way is to add type for struct elf32_fdpic_loadseg,
783 + and release the memory according to the type.
784 + Currently, we hardcode the memory address of L1 SRAM. */
785 + if ((segdata->addr & 0xff800000) == 0xff800000)
786 + {
787 + _dl_sram_free ((void *)segdata->addr);
788 + continue;
789 + }
790 +#endif
791 + offs = (segdata->p_vaddr & ADDR_ALIGN);
792 + _dl_munmap ((void*)segdata->addr - offs,
793 + segdata->p_memsz + offs);
794 + }
795 + /* _dl_unmap is only called for dlopen()ed libraries, for which
796 + calling free() is safe, or before we've completed the initial
797 + relocation, in which case calling free() is probably pointless,
798 + but still safe. */
799 + _dl_free (loadaddr.map);
800 + if (funcdesc_ht)
801 + htab_delete (funcdesc_ht);
802 +}
803 +
804 +#if 0 /* XXX TODO will look at enabling this if we decide to add support for OCM
805 + * code/data */
806 +// OLD BLACKFIN CODE
807 +static __always_inline int
808 +__dl_is_special_segment (Elf32_Ehdr *epnt,
809 + Elf32_Phdr *ppnt)
810 +{
811 + if (ppnt->p_type != PT_LOAD)
812 + return 0;
813 +
814 + if ((epnt->e_flags & EF_BFIN_CODE_IN_L1)
815 + && !(ppnt->p_flags & PF_W)
816 + && (ppnt->p_flags & PF_X))
817 + return 1;
818 +
819 + if ((epnt->e_flags & EF_BFIN_DATA_IN_L1)
820 + && (ppnt->p_flags & PF_W)
821 + && !(ppnt->p_flags & PF_X))
822 + return 1;
823 +
824 + /* 0xff700000, 0xff800000, 0xff900000 and 0xffa00000 are also used in
825 + GNU ld and linux kernel. They need to be keep synchronized. */
826 + if (ppnt->p_vaddr == 0xff700000
827 + || ppnt->p_vaddr == 0xff800000
828 + || ppnt->p_vaddr == 0xff900000
829 + || ppnt->p_vaddr == 0xffa00000)
830 + return 1;
831 +
832 + return 0;
833 +}
834 +
835 +static __always_inline char *
836 +__dl_map_segment (Elf32_Ehdr *epnt,
837 + Elf32_Phdr *ppnt,
838 + int infile,
839 + int flags)
840 +{
841 + char *status, *tryaddr, *l1addr;
842 + size_t size;
843 +
844 +
845 + if (((epnt->e_flags & EF_BFIN_CODE_IN_L1) || ppnt->p_vaddr == 0xffa00000)
846 + && !(ppnt->p_flags & PF_W)
847 + && (ppnt->p_flags & PF_X)) {
848 + status = (char *) _dl_mmap
849 + (tryaddr = 0,
850 + size = (ppnt->p_vaddr & ADDR_ALIGN) + ppnt->p_filesz,
851 + LXFLAGS(ppnt->p_flags),
852 + flags | MAP_EXECUTABLE | MAP_DENYWRITE,
853 + infile, ppnt->p_offset & OFFS_ALIGN);
854 + if (_dl_mmap_check_error(status)
855 + || (tryaddr && tryaddr != status))
856 + return NULL;
857 + l1addr = (char *) _dl_sram_alloc (ppnt->p_filesz, L1_INST_SRAM);
858 + if (l1addr != NULL)
859 + _dl_dma_memcpy (l1addr, status + (ppnt->p_vaddr & ADDR_ALIGN), ppnt->p_filesz);
860 + _dl_munmap (status, size);
861 + if (l1addr == NULL)
862 + _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__);
863 + return l1addr;
864 + }
865 +
866 + if (((epnt->e_flags & EF_BFIN_DATA_IN_L1)
867 + || ppnt->p_vaddr == 0xff700000
868 + || ppnt->p_vaddr == 0xff800000
869 + || ppnt->p_vaddr == 0xff900000)
870 + && (ppnt->p_flags & PF_W)
871 + && !(ppnt->p_flags & PF_X)) {
872 + if (ppnt->p_vaddr == 0xff800000)
873 + l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_A_SRAM);
874 + else if (ppnt->p_vaddr == 0xff900000)
875 + l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_B_SRAM);
876 + else
877 + l1addr = (char *) _dl_sram_alloc (ppnt->p_memsz, L1_DATA_SRAM);
878 + if (l1addr == NULL) {
879 + _dl_dprintf(2, "%s:%i: L1 allocation failed\n", _dl_progname, __LINE__);
880 + } else {
881 + if (_DL_PREAD (infile, l1addr, ppnt->p_filesz, ppnt->p_offset) != ppnt->p_filesz) {
882 + _dl_sram_free (l1addr);
883 + return NULL;
884 + }
885 + if (ppnt->p_filesz < ppnt->p_memsz)
886 + _dl_memset (l1addr + ppnt->p_filesz, 0, ppnt->p_memsz - ppnt->p_filesz);
887 + }
888 + return l1addr;
889 + }
890 + return 0;
891 +}
892 +#endif
893 Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-startup.h
894 ===================================================================
895 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
896 +++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-startup.h 2010-01-14 11:05:01.000000000 +0100
897 @@ -0,0 +1,232 @@
898 +/*
899 + Copyright (C) 2009 Ubicom, Inc.
900 + Copyright (C) 2003 Red Hat, Inc.
901 + Contributed by Alexandre Oliva <aoliva@redhat.com>
902 +
903 +This file is part of uClibc.
904 +
905 +uClibc is free software; you can redistribute it and/or modify it
906 +under the terms of the GNU Lesser General Public License as
907 +published by the Free Software Foundation; either version 2.1 of the
908 +License, or (at your option) any later version.
909 +
910 +uClibc is distributed in the hope that it will be useful, but WITHOUT
911 +ANY WARRANTY; without even the implied warranty of
912 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
913 +Library General Public License for more details.
914 +
915 +You should have received a copy of the GNU Lesser General Public
916 +License along with uClibc; see the file COPYING.LIB. If not, write to
917 +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
918 +USA. */
919 +
920 +/* Any assembly language/system dependent hacks needed to setup
921 + * boot1.c so it will work as expected and cope with whatever platform
922 + * specific wierdness is needed for this architecture.
923 +
924 + * We override the default _dl_boot function, and replace it with a
925 + * bit of asm. Then call the real _dl_boot function, which is now
926 + * named _dl_boot2. */
927 +
928 +/* At program start-up, p0 contains a pointer to a
929 + elf32_fdpic_loadmap that describes how the executable was loaded
930 + into memory. p1 contains a pointer to the interpreter (our!)
931 + loadmap, if there is an interpreter, or 0 if we're being run as an
932 + executable. p2 holds a pointer to the interpreter's dynamic
933 + section, if there is an interpreter, or to the executable's dynamic
934 + section, otherwise. If the executable is not dynamic, gr18 is 0.
935 +
936 + We rely on the fact that the linker adds a pointer to the
937 + _GLOBAL_OFFSET_TABLE_ as the last ROFIXUP entry, and that
938 + __self_reloc returns the relocated pointer to us, so that we can
939 + use this value to initialize the PIC register. */
940 +
941 +
942 +/*
943 + * _dl_boot is the entry point for ldso.
944 + *
945 + * The kernel leaves the main apps args on the stack (positive offsets), and
946 + * communicates the load maps as follows
947 + *
948 + * - d1 is set to the exec_map_addr (struct elf32_fdpic_loadmap *), which is the
949 + * current state of the mapped application.
950 + *
951 + * - d2 is set to interp_map_addr (struct elf32_fdpic_loadmap *), which is use
952 + * by ldso to relocate itself.
953 + *
954 + * - d3 is dynamic_addr which as far as I can tell is the stack pointer.
955 + *
956 + * - a1 is set to zero and will later be initialised to ldso _dl_fini funcdesc
957 + */
958 +
959 +__asm__(
960 + " .text \n\t"
961 + " .global _start \n\t"
962 + " .type _start,@function \n\t"
963 + "_start:\n\t"
964 + /*
965 + * Jump to .Lcall storing the location .Lcall in a5
966 + */
967 + " call a5, .Lcall \n\t"
968 + ".Lcall: \n\t"
969 + /*
970 + * Reserve and Push inputs to stack.
971 + * 32 byte stack layout as follows
972 + * offset 0 exec_map_addr
973 + * 4 interp_map_addr
974 + * 8 dynamic_addr
975 + * 12 not used
976 + * 16 dl_main_funcdesc structure for _dl_boot
977 + * (12 bytes sizeof funcdesc_value)
978 + * 28 reserved
979 + * 32 start of &original stack
980 + */
981 + " pdec sp, 32(sp); reserve stack space \n\t"
982 + " move.4 0(sp), d1 ; exec_map_addr \n\t"
983 + " move.4 4(sp), d2 ; interp_map_addr \n\t"
984 + " move.4 8(sp), d3; dynamic_addr \n\t"
985 +
986 + /*
987 + * Load linker version of .Lcall in to d0
988 + */
989 + " moveai a3, #%hi(.Lcall) \n\t"
990 + " lea.1 d0, %lo(.Lcall)(a3) \n\t"
991 +
992 + /*
993 + * Determine the offset from loaded .Lcall and put it in d0.
994 + */
995 + " sub.4 d0, a5, d0 \n\t"
996 +
997 + /*
998 + * Load linker version of __ROFIXUP_LIST__ and __ROFIXUP_END__ in to d1
999 + * and d2.
1000 + */
1001 + " moveai a3, #%hi(__ROFIXUP_LIST__) \n\t"
1002 + " lea.1 d1, %lo(__ROFIXUP_LIST__)(a3) \n\t"
1003 + " moveai a3, #%hi(__ROFIXUP_END__) \n\t"
1004 + " lea.1 d2, %lo(__ROFIXUP_END__)(a3) \n\t"
1005 + /*
1006 + * Use offset determined above to find the loaded versions.
1007 + */
1008 + " add.4 d1, d1, d0 \n\t"
1009 + " add.4 d2, d2, d0 \n\t"
1010 +
1011 + /*
1012 + * Load interp_map_addr into d0, if interp_map_addr is null use
1013 + * exec_map_addr.
1014 + */
1015 + " move.4 d0, 4(sp) ; load interp_map_addr \n\t"
1016 + " cmpi d0, #0 \n\t"
1017 + " jmpne.f 1f \n\t"
1018 + " move.4 d0, 0(sp) ; load exec_map_addr \n\t"
1019 +
1020 + /*
1021 + * call __self_reloc(map, void ***p, void ***e)
1022 + * it returns the the GOT in d0.
1023 + */
1024 + "1: call a5, __self_reloc ; returns a0 in d0 \n\t"
1025 + " move.4 a0, d0 ; set GOT \n\t"
1026 + " move.4 a2, d0 ; save GOT \n\t"
1027 +
1028 + /*
1029 + * now setup to call
1030 + * _dl_start (Elf32_Addr dl_boot_got_pointer, (d0)
1031 + * struct elf32_fdpic_loadmap *dl_boot_progmap, (d1)
1032 + * struct elf32_fdpic_loadmap *dl_boot_ldsomap, (d2)
1033 + * Elf32_Dyn *dl_boot_ldso_dyn_pointer, (d3)
1034 + * struct funcdesc_value *dl_main_funcdesc, (d4)
1035 + * unsigned long args (d5)
1036 + *
1037 + * NOTE: for dl_main_funcdesc we reserved space on the stack for this
1038 + * structure.
1039 + */
1040 + " move.4 d1, 0(sp) ; d1 = exec_map_addr \n\t"
1041 + " move.4 d2, 4(sp) ; d2 = interp_map_addr \n\t"
1042 + " move.4 d3, 8(sp) ; d3 = dynamic_addr \n\t"
1043 + " lea.1 d4, 16(sp) ; d4 = &dl_main_funcdesc \n\t"
1044 + " lea.1 d5, 32(sp) ; d5 = original stack ptr (args)\n\t"
1045 + " call a5, _dl_start \n\t"
1046 +
1047 + /*
1048 + * Setup to call the main entry point, starting with passing our FINI
1049 + * ptr() to the user in a1 (remember we saved the got in a2)
1050 + */
1051 + " movei d15, #%got_funcdesc_lo(_dl_fini) \n\t"
1052 + " move.4 a1, (a2, d15) \n\t"
1053 +
1054 + /*
1055 + * restore the load map from the kernel.
1056 + */
1057 + " move.4 d1, 0(sp) ; restore exec_map_addr \n\t"
1058 + " move.4 d2, 4(sp) ; restore interp_map_addr \n\t"
1059 + " move.4 d3, 8(sp) ; restore dynamic_addr \n\t"
1060 +
1061 + /*
1062 + * _dl_start returned the main apps entry point in dl_main_funcdesc,
1063 + * load that information now.
1064 + */
1065 + " move.4 a5, 16(sp) ; a5 = dl_main_funcdesc.entry_point \n\t"
1066 + " move.4 a0, 20(sp) ; a0 = dl_main_funcdesc.got_value \n\t"
1067 + " lea.1 sp, 32(sp); restore original stack ptr (args) \n\t"
1068 + " calli a5, 0(a5) \n\t"
1069 + " bkpt -1; should never get here \n\t"
1070 + " .size _start, . - _start \n\t"
1071 +);
1072 +
1073 +#undef DL_START
1074 +#define DL_START(X) \
1075 +static void __attribute__ ((used)) \
1076 +_dl_start (Elf32_Addr dl_boot_got_pointer, \
1077 + struct elf32_fdpic_loadmap *dl_boot_progmap, \
1078 + struct elf32_fdpic_loadmap *dl_boot_ldsomap, \
1079 + Elf32_Dyn *dl_boot_ldso_dyn_pointer, \
1080 + struct funcdesc_value *dl_main_funcdesc, \
1081 + X)
1082 +
1083 +struct elf32_fdpic_loadmap;
1084 +
1085 +/*
1086 + * Get a pointer to the argv array. On many platforms this can be just
1087 + * the address if the first argument, on other platforms we need to
1088 + * do something a little more subtle here.
1089 + */
1090 +#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*) ARGS) + 1)
1091 +
1092 +/*
1093 + * Here is a macro to perform a relocation. This is only used when
1094 + * bootstrapping the dynamic loader. RELP is the relocation that we
1095 + * are performing, REL is the pointer to the address we are relocating.
1096 + * SYMBOL is the symbol involved in the relocation, and LOAD is the
1097 + * load address.
1098 + */
1099 +#define PERFORM_BOOTSTRAP_RELOC(RELP,REL,SYMBOL,LOAD,SYMTAB) \
1100 + switch(ELF32_R_TYPE((RELP)->r_info)){ \
1101 + case R_UBICOM32_32: \
1102 + *(REL) += (SYMBOL); \
1103 + break; \
1104 + case R_UBICOM32_FUNCDESC_VALUE: \
1105 + { \
1106 + struct funcdesc_value fv = { \
1107 + (void*)((SYMBOL) + *(REL)), \
1108 + (LOAD).got_value \
1109 + }; \
1110 + *(struct funcdesc_value volatile *)(REL) = fv; \
1111 + break; \
1112 + } \
1113 + default: \
1114 + _dl_exit(1); \
1115 + }
1116 +
1117 +/*
1118 + * Transfer control to the user's application, once the dynamic loader
1119 + * is done. We return the address of the function's entry point to
1120 + * _dl_boot, see boot1_arch.h.
1121 + */
1122 +#define START() do { \
1123 + struct elf_resolve *exec_mod = _dl_loaded_modules; \
1124 + dl_main_funcdesc->entry_point = _dl_elf_main; \
1125 + while (exec_mod->libtype != elf_executable) \
1126 + exec_mod = exec_mod->next; \
1127 + dl_main_funcdesc->got_value = exec_mod->loadaddr.got_value; \
1128 + return; \
1129 +} while (0)
1130 Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-syscalls.h
1131 ===================================================================
1132 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1133 +++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-syscalls.h 2010-01-14 11:05:01.000000000 +0100
1134 @@ -0,0 +1,206 @@
1135 +/* Copyright (C) 2003, 2004 Red Hat, Inc.
1136 + Contributed by Alexandre Oliva <aoliva@redhat.com>
1137 +
1138 +This file is part of uClibc.
1139 +
1140 +uClibc is free software; you can redistribute it and/or modify it
1141 +under the terms of the GNU Lesser General Public License as
1142 +published by the Free Software Foundation; either version 2.1 of the
1143 +License, or (at your option) any later version.
1144 +
1145 +uClibc is distributed in the hope that it will be useful, but WITHOUT
1146 +ANY WARRANTY; without even the implied warranty of
1147 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1148 +Library General Public License for more details.
1149 +
1150 +You should have received a copy of the GNU Lesser General Public
1151 +License along with uClibc; see the file COPYING.LIB. If not, write to
1152 +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
1153 +USA. */
1154 +
1155 +/* We can't use the real errno in ldso, since it has not yet
1156 + * been dynamicly linked in yet. */
1157 +#include "sys/syscall.h"
1158 +extern int _dl_errno;
1159 +#undef __set_errno
1160 +#define __set_errno(X) {(_dl_errno) = (X);}
1161 +#include <sys/mman.h>
1162 +
1163 +/* The code below is extracted from libc/sysdeps/linux/frv/_mmap.c */
1164 +
1165 +#if defined(DYNAMIC_LOADER_IN_SIMULATOR) && DYNAMIC_LOADER_IN_SIMULATOR
1166 +#define __NR___syscall_mmap2 __NR_mmap2
1167 +static __inline__ _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr,
1168 + size_t, len, int, prot, int, flags, int, fd, off_t, offset);
1169 +
1170 +/* Make sure we don't get another definition of _dl_mmap from the
1171 + machine-independent code. */
1172 +#undef __NR_mmap
1173 +#undef __NR_mmap2
1174 +
1175 +/* This is always 12, even on architectures where PAGE_SHIFT != 12. */
1176 +# ifndef MMAP2_PAGE_SHIFT
1177 +# define MMAP2_PAGE_SHIFT 12
1178 +# endif
1179 +
1180 +#include <bits/uClibc_page.h> /* for PAGE_SIZE */
1181 +static __always_inline void *_dl_memset(void*,int,size_t);
1182 +static __always_inline ssize_t _dl_pread(int fd, void *buf, size_t count, off_t offset);
1183 +
1184 +static __ptr_t
1185 +_dl_mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
1186 +{
1187 + size_t plen = (len + PAGE_SIZE - 1) & -PAGE_SIZE;
1188 +
1189 +/* This is a hack to enable the dynamic loader to run within a
1190 + simulator that doesn't support mmap, with a number of very ugly
1191 + tricks. Also, it's not as useful as it sounds, since only dynamic
1192 + executables without DT_NEEDED dependencies can be run. AFAIK, they
1193 + can only be created with -pie. This trick suffices to enable the
1194 + dynamic loader to obtain a blank page that it maps early in the
1195 + bootstrap. */
1196 + if ((flags & MAP_FIXED) == 0)
1197 + {
1198 + void *_dl_mmap_base = 0;
1199 + __ptr_t *ret = 0;
1200 +
1201 + if (! _dl_mmap_base)
1202 + {
1203 + void *stack;
1204 + __asm__ ("mov sp, %0" : "=r" (stack));
1205 + _dl_mmap_base = (void *)(((long)stack + 2 * PAGE_SIZE) & -PAGE_SIZE);
1206 + retry:
1207 + if (((void **)_dl_mmap_base)[0] == _dl_mmap_base
1208 + && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
1209 + && (((void **)_dl_mmap_base)[177]
1210 + == ((void **)_dl_mmap_base)[771]))
1211 + {
1212 + while (((void**)_dl_mmap_base)[177])
1213 + {
1214 + _dl_mmap_base = ((void**)_dl_mmap_base)[177];
1215 + if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base
1216 + && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
1217 + && (((void **)_dl_mmap_base)[177]
1218 + == ((void**)_dl_mmap_base)[771])))
1219 + ((void(*)())0)();
1220 + }
1221 + }
1222 + else
1223 + {
1224 + int i;
1225 + for (i = 0; i < (int)PAGE_SIZE; i++)
1226 + if (*(char*)(_dl_mmap_base + i))
1227 + break;
1228 + if (i != PAGE_SIZE)
1229 + {
1230 + _dl_mmap_base = (void*)((long)_dl_mmap_base + PAGE_SIZE);
1231 + goto retry;
1232 + }
1233 + ((void**)_dl_mmap_base)[-1] =
1234 + ((void**)_dl_mmap_base)[0] =
1235 + ((void**)_dl_mmap_base)[1023] =
1236 + _dl_mmap_base;
1237 + }
1238 + }
1239 +
1240 + if (_dl_mmap_base)
1241 + {
1242 + if (!(((void **)_dl_mmap_base)[0] == _dl_mmap_base
1243 + && ((void **)_dl_mmap_base)[1023] == _dl_mmap_base
1244 + && (((void **)_dl_mmap_base)[177]
1245 + == ((void**)_dl_mmap_base)[771])))
1246 + ((void(*)())0)();
1247 + ret = (__ptr_t)((char*)_dl_mmap_base + PAGE_SIZE);
1248 + _dl_mmap_base =
1249 + ((void**)_dl_mmap_base)[177] =
1250 + ((void**)_dl_mmap_base)[771] =
1251 + (char*)_dl_mmap_base + plen + PAGE_SIZE;
1252 + ((void**)_dl_mmap_base)[0] =
1253 + ((void**)_dl_mmap_base)[1023] =
1254 + _dl_mmap_base;
1255 + }
1256 +
1257 + if ((flags & MAP_ANONYMOUS) != 0)
1258 + {
1259 + _dl_memset (ret, 0, plen);
1260 + return ret;
1261 + }
1262 +
1263 + flags |= MAP_FIXED;
1264 + addr = ret;
1265 + }
1266 + if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
1267 +#if 0
1268 + __set_errno (EINVAL);
1269 +#endif
1270 + return MAP_FAILED;
1271 + }
1272 + if ((flags & MAP_FIXED) != 0)
1273 + {
1274 + if (_dl_pread(fd, addr, len, offset) != (ssize_t)len)
1275 + return (void*)MAP_FAILED;
1276 + if (plen != len)
1277 + _dl_memset (addr + len, 0, plen - len);
1278 + return addr;
1279 + }
1280 + return(__syscall_mmap2(addr, len, prot, flags, fd, (off_t) (offset >> MMAP2_PAGE_SHIFT)));
1281 +}
1282 +#endif
1283 +
1284 +#ifdef __NR_pread64
1285 +#ifdef DYNAMIC_LOADER_IN_SIMULATOR
1286 +#include <unistd.h>
1287 +
1288 +#define __NR___syscall_lseek __NR_lseek
1289 +static __always_inline unsigned long _dl_read(int fd, const void *buf, unsigned long count);
1290 +
1291 +static __always_inline _syscall3(__off_t, __syscall_lseek, int, fd, __off_t, offset,
1292 + int, whence);
1293 +static __always_inline ssize_t
1294 +_dl_pread(int fd, void *buf, size_t count, off_t offset)
1295 +{
1296 + __off_t orig = __syscall_lseek (fd, 0, SEEK_CUR);
1297 + ssize_t ret;
1298 +
1299 + if (orig == -1)
1300 + return -1;
1301 +
1302 + if (__syscall_lseek (fd, offset, SEEK_SET) != offset)
1303 + return -1;
1304 +
1305 + ret = _dl_read (fd, buf, count);
1306 +
1307 + if (__syscall_lseek (fd, orig, SEEK_SET) != orig)
1308 + ((void(*)())0)();
1309 +
1310 + return ret;
1311 +}
1312 +#else
1313 +#define __NR___syscall_pread __NR_pread64
1314 +static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf,
1315 + size_t, count, off_t, offset_hi, off_t, offset_lo);
1316 +
1317 +static __always_inline ssize_t
1318 +_dl_pread(int fd, void *buf, size_t count, off_t offset)
1319 +{
1320 + return(__syscall_pread(fd,buf,count,__LONG_LONG_PAIR (offset >> 31, offset)));
1321 +}
1322 +#endif
1323 +#endif
1324 +
1325 +#ifdef __NR_sram_alloc
1326 +#define __NR__dl_sram_alloc __NR_sram_alloc
1327 +static __always_inline _syscall2(__ptr_t, _dl_sram_alloc,
1328 + size_t, len, unsigned long, flags);
1329 +#endif
1330 +
1331 +#ifdef __NR_sram_free
1332 +#define __NR__dl_sram_free __NR_sram_free
1333 +static __always_inline _syscall1(int, _dl_sram_free, __ptr_t, addr);
1334 +#endif
1335 +
1336 +#ifdef __NR_dma_memcpy
1337 +#define __NR__dl_dma_memcpy __NR_dma_memcpy
1338 +static __always_inline _syscall3(__ptr_t, _dl_dma_memcpy,
1339 + __ptr_t, dest, __ptr_t, src, size_t, len);
1340 +#endif
1341 Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-sysdep.h
1342 ===================================================================
1343 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1344 +++ uClibc-0.9.30.2/ldso/ldso/ubicom32/dl-sysdep.h 2010-01-14 11:05:01.000000000 +0100
1345 @@ -0,0 +1,243 @@
1346 + /* Copyright (C) 2003, 2004 Red Hat, Inc.
1347 + Contributed by Alexandre Oliva <aoliva@redhat.com>
1348 + Based on ../i386/dl-sysdep.h
1349 +
1350 +This file is part of uClibc.
1351 +
1352 +uClibc is free software; you can redistribute it and/or modify it
1353 +under the terms of the GNU Lesser General Public License as
1354 +published by the Free Software Foundation; either version 2.1 of the
1355 +License, or (at your option) any later version.
1356 +
1357 +uClibc is distributed in the hope that it will be useful, but WITHOUT
1358 +ANY WARRANTY; without even the implied warranty of
1359 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1360 +Library General Public License for more details.
1361 +
1362 +You should have received a copy of the GNU Lesser General Public
1363 +License along with uClibc; see the file COPYING.LIB. If not, write to
1364 +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
1365 +USA. */
1366 +
1367 +/*
1368 + * Various assembly language/system dependent hacks that are required
1369 + * so that we can minimize the amount of platform specific code.
1370 + */
1371 +
1372 +/*
1373 + * Define this if the system uses RELOCA.
1374 + */
1375 +#undef ELF_USES_RELOCA
1376 +
1377 +/* JMPREL relocs are inside the DT_RELA table. */
1378 +#define ELF_MACHINE_PLTREL_OVERLAP
1379 +
1380 +#define DL_NO_COPY_RELOCS
1381 +
1382 +#define HAVE_DL_INLINES_H
1383 +
1384 +/*
1385 + * Initialization sequence for a GOT. Copy the resolver function
1386 + * descriptor and the pointer to the elf_resolve/link_map data
1387 + * structure. Initialize the got_value in the module while at that.
1388 + */
1389 +#define INIT_GOT(GOT_BASE,MODULE) \
1390 +{ \
1391 + (MODULE)->loadaddr.got_value = (GOT_BASE); \
1392 + GOT_BASE[0] = ((unsigned long *)&_dl_linux_resolve)[0]; \
1393 + GOT_BASE[1] = ((unsigned long *)&_dl_linux_resolve)[1]; \
1394 + GOT_BASE[2] = (unsigned long) MODULE; \
1395 +}
1396 +
1397 +/* Here we define the magic numbers that this dynamic loader should accept */
1398 +#define MAGIC1 EM_UBICOM32
1399 +#undef MAGIC2
1400 +
1401 +/* Used for error messages */
1402 +#define ELF_TARGET "UBICOM32"
1403 +
1404 +struct elf_resolve;
1405 +
1406 +struct funcdesc_value
1407 +{
1408 + void *entry_point;
1409 + void *got_value;
1410 +/*int relocation; not sure if this required, but it does exist */
1411 +};
1412 +
1413 +extern int _dl_linux_resolve(void) __attribute__((__visibility__("hidden")));
1414 +extern struct funcdesc_value volatile *__attribute__((__visibility__("hidden")))
1415 + _dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry);
1416 +
1417 +/* 4KiB page alignment. Should perhaps be made dynamic using
1418 + getpagesize(), based on AT_PAGESZ from auxvt? */
1419 +#define PAGE_ALIGN 0xfffff000
1420 +#define ADDR_ALIGN 0xfff
1421 +#define OFFS_ALIGN 0x7ffff000
1422 +
1423 +struct funcdesc_ht;
1424 +
1425 +/*
1426 + * This asm does a quick relcation of string S (which is stored in the text
1427 + * section as thats all we can use
1428 + */
1429 +#undef SEND_EARLY_STDERR
1430 +#define SEND_EARLY_STDERR(S) \
1431 +do { \
1432 + static const char __attribute__((section(".text"))) __s[] = (S); \
1433 + const char *__p, *__scratch; \
1434 + __asm__ ( \
1435 + " call a3, 1f; \n\t" \
1436 + "1: movei %0, #%%got_lo(1b) \n\t" \
1437 + " move.4 %0, (%3, %0) \n\t" \
1438 + " sub.4 %1, a3, %0; \n\t" \
1439 + " add.4 %1, %1, %2; \n\t" \
1440 + : "=&d" (__scratch), "=&d" (__p) \
1441 + : "d" (__s), "a" (dl_boot_got_pointer) \
1442 + : "a3", "a4", "d15"); \
1443 + SEND_STDERR (__p); \
1444 + { int __t; \
1445 + for (__t = 0; __t < 0x100000; __t++) __asm__ __volatile__ (""); } \
1446 +} while (0)
1447 +
1448 +#define DL_LOADADDR_TYPE struct elf32_fdpic_loadaddr
1449 +
1450 +#define DL_RELOC_ADDR(LOADADDR, ADDR) \
1451 + ((ElfW(Addr))__reloc_pointer ((void*)(ADDR), (LOADADDR).map))
1452 +
1453 +#define DL_ADDR_TO_FUNC_PTR(ADDR, LOADADDR) \
1454 + ((void(*)(void)) _dl_funcdesc_for ((void*)(ADDR), (LOADADDR).got_value))
1455 +
1456 +#define _dl_stabilize_funcdesc(val) \
1457 + ({ __asm__ ("" : "+m" (*(val))); (val); })
1458 +
1459 +#define DL_CALL_FUNC_AT_ADDR(ADDR, LOADADDR, SIGNATURE, ...) \
1460 + ({ struct funcdesc_value fd = { (void*)(ADDR), (LOADADDR).got_value }; \
1461 + void (*pf)(void) = (void*) _dl_stabilize_funcdesc (&fd); \
1462 + (* SIGNATURE pf)(__VA_ARGS__); })
1463 +
1464 +#define DL_INIT_LOADADDR_BOOT(LOADADDR, BASEADDR) \
1465 + (__dl_init_loadaddr_map (&(LOADADDR), dl_boot_got_pointer, \
1466 + dl_boot_ldsomap ?: dl_boot_progmap))
1467 +
1468 +#define DL_INIT_LOADADDR_PROG(LOADADDR, BASEADDR) \
1469 + (__dl_init_loadaddr_map (&(LOADADDR), 0, dl_boot_progmap))
1470 +
1471 +#define DL_INIT_LOADADDR_EXTRA_DECLS \
1472 + int dl_init_loadaddr_load_count;
1473 +#define DL_INIT_LOADADDR(LOADADDR, BASEADDR, PHDR, PHDRCNT) \
1474 + (dl_init_loadaddr_load_count = \
1475 + __dl_init_loadaddr (&(LOADADDR), (PHDR), (PHDRCNT)))
1476 +#define DL_INIT_LOADADDR_HDR(LOADADDR, ADDR, PHDR) \
1477 + (__dl_init_loadaddr_hdr ((LOADADDR), (ADDR), (PHDR), \
1478 + dl_init_loadaddr_load_count))
1479 +#define DL_LOADADDR_UNMAP(LOADADDR, LEN) \
1480 + (__dl_loadaddr_unmap ((LOADADDR), (NULL)))
1481 +#define DL_LIB_UNMAP(LIB, LEN) \
1482 + (__dl_loadaddr_unmap ((LIB)->loadaddr, (LIB)->funcdesc_ht))
1483 +#define DL_LOADADDR_BASE(LOADADDR) \
1484 + ((LOADADDR).got_value)
1485 +
1486 +/* This is called from dladdr(), such that we map a function
1487 + descriptor's address to the function's entry point before trying to
1488 + find in which library it's defined. */
1489 +#define DL_LOOKUP_ADDRESS(ADDRESS) (_dl_lookup_address (ADDRESS))
1490 +
1491 +#define DL_ADDR_IN_LOADADDR(ADDR, TPNT, TFROM) \
1492 + (! (TFROM) && __dl_addr_in_loadaddr ((void*)(ADDR), (TPNT)->loadaddr))
1493 +
1494 +/*
1495 + * Compute the GOT address. On several platforms, we use assembly
1496 + * here. on FR-V FDPIC, there's no way to compute the GOT address,
1497 + * since the offset between text and data is not fixed, so we arrange
1498 + * for the assembly _dl_boot to pass this value as an argument to
1499 + * _dl_boot. */
1500 +#define DL_BOOT_COMPUTE_GOT(got) ((got) = dl_boot_got_pointer)
1501 +
1502 +#define DL_BOOT_COMPUTE_DYN(dpnt, got, load_addr) \
1503 + ((dpnt) = dl_boot_ldso_dyn_pointer)
1504 +
1505 +/* We only support loading FDPIC independently-relocatable shared
1506 + libraries. It probably wouldn't be too hard to support loading
1507 + shared libraries that require relocation by the same amount, but we
1508 + don't know that they exist or would be useful, and the dynamic
1509 + loader code could leak the whole-library map unless we keeping a
1510 + bit more state for DL_LOADADDR_UNMAP and DL_LIB_UNMAP, so let's
1511 + keep things simple for now. */
1512 +#define DL_CHECK_LIB_TYPE(epnt, piclib, _dl_progname, libname) \
1513 +do \
1514 +{ \
1515 + if (((epnt)->e_flags & EF_UBICOM32_FDPIC) && ! ((epnt)->e_flags & EF_UBICOM32_PIC)) \
1516 + (piclib) = 2; \
1517 + else \
1518 + { \
1519 + _dl_internal_error_number = LD_ERROR_NOTDYN; \
1520 + _dl_dprintf(2, "%s: '%s' is not an FDPIC shared library" \
1521 + "\n", (_dl_progname), (libname)); \
1522 + _dl_close(infile); \
1523 + return NULL; \
1524 + } \
1525 +\
1526 +} \
1527 +while (0)
1528 +
1529 +/* We want want to apply all relocations in the interpreter during
1530 + bootstrap. Because of this, we have to skip the interpreter
1531 + relocations in _dl_parse_relocation_information(), see
1532 + elfinterp.c. */
1533 +#define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0
1534 +
1535 +#ifdef __NR_pread64
1536 +#define _DL_PREAD(FD, BUF, SIZE, OFFSET) \
1537 + (_dl_pread((FD), (BUF), (SIZE), (OFFSET)))
1538 +#endif
1539 +
1540 +/* We want to return to dlsym() a function descriptor if the symbol
1541 + turns out to be a function. */
1542 +#define DL_FIND_HASH_VALUE(TPNT, TYPE_CLASS, SYM) \
1543 + (((TYPE_CLASS) & ELF_RTYPE_CLASS_DLSYM) \
1544 + && ELF32_ST_TYPE((SYM)->st_info) == STT_FUNC \
1545 + ? _dl_funcdesc_for ((void *)DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value), \
1546 + (TPNT)->loadaddr.got_value) \
1547 + : DL_RELOC_ADDR ((TPNT)->loadaddr, (SYM)->st_value))
1548 +
1549 +#if 0 /* XXX TODO will look at enabling this if we decide to add support for OCM
1550 + * code/data */
1551 +
1552 +#define DL_IS_SPECIAL_SEGMENT(EPNT, PPNT) \
1553 + __dl_is_special_segment(EPNT, PPNT)
1554 +#define DL_MAP_SEGMENT(EPNT, PPNT, INFILE, FLAGS) \
1555 + __dl_map_segment (EPNT, PPNT, INFILE, FLAGS)
1556 +
1557 +#endif
1558 +
1559 +
1560 +#define DL_GET_READY_TO_RUN_EXTRA_PARMS \
1561 + , struct elf32_fdpic_loadmap *dl_boot_progmap, Elf32_Addr dl_boot_got_pointer
1562 +#define DL_GET_READY_TO_RUN_EXTRA_ARGS \
1563 + , dl_boot_progmap, dl_boot_got_pointer
1564 +
1565 +
1566 +#ifdef __USE_GNU
1567 +# include <link.h>
1568 +#else
1569 +# define __USE_GNU
1570 +# include <link.h>
1571 +# undef __USE_GNU
1572 +#endif
1573 +
1574 +#include <elf.h>
1575 +static __inline__ void
1576 +elf_machine_relative (DL_LOADADDR_TYPE load_off, const Elf32_Addr rel_addr,
1577 + Elf32_Word relative_count)
1578 +{
1579 +#if 0
1580 + Elf32_Rel * rpnt = (void *) rel_addr;
1581 + --rpnt;
1582 + do {
1583 + Elf32_Addr *const reloc_addr = (void *) (load_off + (++rpnt)->r_offset);
1584 +
1585 + *reloc_addr = DL_RELOC_ADDR (load_off, *reloc_addr);
1586 + } while (--relative_count);
1587 +#endif
1588 +}
1589 Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/elfinterp.c
1590 ===================================================================
1591 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1592 +++ uClibc-0.9.30.2/ldso/ldso/ubicom32/elfinterp.c 2010-01-14 11:05:01.000000000 +0100
1593 @@ -0,0 +1,366 @@
1594 +/* Blackfin ELF shared library loader suppport
1595 + Copyright (C) 2003, 2004 Red Hat, Inc.
1596 + Contributed by Alexandre Oliva <aoliva@redhat.com>
1597 + Lots of code copied from ../i386/elfinterp.c, so:
1598 + Copyright (c) 1994-2000 Eric Youngdale, Peter MacDonald,
1599 + David Engel, Hongjiu Lu and Mitch D'Souza
1600 + Copyright (C) 2001-2002, Erik Andersen
1601 + All rights reserved.
1602 +
1603 +This file is part of uClibc.
1604 +
1605 +uClibc is free software; you can redistribute it and/or modify it
1606 +under the terms of the GNU Lesser General Public License as
1607 +published by the Free Software Foundation; either version 2.1 of the
1608 +License, or (at your option) any later version.
1609 +
1610 +uClibc is distributed in the hope that it will be useful, but WITHOUT
1611 +ANY WARRANTY; without even the implied warranty of
1612 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1613 +Library General Public License for more details.
1614 +
1615 +You should have received a copy of the GNU Lesser General Public
1616 +License along with uClibc; see the file COPYING.LIB. If not, write to
1617 +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
1618 +USA. */
1619 +
1620 +#include <sys/cdefs.h> /* __attribute_used__ */
1621 +
1622 +/* Program to load an ELF binary on a linux system, and run it.
1623 + References to symbols in sharable libraries can be resolved by either
1624 + an ELF sharable library or a linux style of shared library. */
1625 +
1626 +/* Disclaimer: I have never seen any AT&T source code for SVr4, nor have
1627 + I ever taken any courses on internals. This program was developed using
1628 + information available through the book "UNIX SYSTEM V RELEASE 4,
1629 + Programmers guide: Ansi C and Programming Support Tools", which did
1630 + a more than adequate job of explaining everything required to get this
1631 + working. */
1632 +extern int _dl_ubicom32_resolve_pending(void) __attribute__((__visibility__("hidden")));
1633 +
1634 +struct funcdesc_value volatile *__attribute__((__visibility__("hidden")))
1635 +_dl_linux_resolver (struct elf_resolve *tpnt, int reloc_entry)
1636 +{
1637 + int reloc_type;
1638 + ELF_RELOC *this_reloc;
1639 + char *strtab;
1640 + ElfW(Sym) *symtab;
1641 + int symtab_index;
1642 + char *rel_addr;
1643 + struct elf_resolve *new_tpnt;
1644 + char *new_addr;
1645 + struct funcdesc_value funcval;
1646 + struct funcdesc_value volatile *got_entry;
1647 + char *symname;
1648 +
1649 + rel_addr = (char *)tpnt->dynamic_info[DT_JMPREL];
1650 +
1651 + this_reloc = (ELF_RELOC *)(intptr_t)(rel_addr + reloc_entry);
1652 + reloc_type = ELF_R_TYPE(this_reloc->r_info);
1653 + symtab_index = ELF_R_SYM(this_reloc->r_info);
1654 +
1655 + symtab = (Elf32_Sym *) tpnt->dynamic_info[DT_SYMTAB];
1656 + strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
1657 + symname= strtab + symtab[symtab_index].st_name;
1658 +
1659 + if (reloc_type != R_UBICOM32_FUNCDESC_VALUE) {
1660 + _dl_dprintf(2, "%s: Incorrect relocation type in jump relocations\n",
1661 + _dl_progname);
1662 + _dl_exit(1);
1663 + }
1664 +
1665 + /* Address of GOT entry fix up */
1666 + got_entry = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, this_reloc->r_offset);
1667 +
1668 + /* Get the address to be used to fill in the GOT entry. */
1669 + new_addr = _dl_lookup_hash(symname, tpnt->symbol_scope, NULL, 0, &new_tpnt);
1670 + if (!new_addr) {
1671 + new_addr = _dl_lookup_hash(symname, NULL, NULL, 0, &new_tpnt);
1672 + if (!new_addr) {
1673 + _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
1674 + _dl_progname, symname);
1675 + _dl_exit(1);
1676 + }
1677 + }
1678 +
1679 + funcval.entry_point = new_addr;
1680 + funcval.got_value = new_tpnt->loadaddr.got_value;
1681 +
1682 +#if defined (__SUPPORT_LD_DEBUG__)
1683 + if (_dl_debug_bindings) {
1684 + _dl_dprintf(_dl_debug_file, "\nresolve function: %s", symname);
1685 + if (_dl_debug_detail)
1686 + _dl_dprintf(_dl_debug_file,
1687 + "\n\tpatched (%x,%x) ==> (%x,%x) @ %x\n",
1688 + got_entry->entry_point, got_entry->got_value,
1689 + funcval.entry_point, funcval.got_value,
1690 + got_entry);
1691 + }
1692 + if (1 || !_dl_debug_nofixups) {
1693 + got_entry->entry_point = ((unsigned long *)&_dl_ubicom32_resolve_pending)[0];
1694 + got_entry->got_value = funcval.got_value;
1695 + got_entry->entry_point = funcval.entry_point;
1696 + }
1697 +#else
1698 + /*
1699 + * initially set the entry point to resolve pending before starting
1700 + * the update. This has the effect of putting all other requests in a
1701 + * holding pattern until the resolution is completed.
1702 + */
1703 + got_entry->entry_point = ((unsigned long *)&_dl_ubicom32_resolve_pending)[0];
1704 + got_entry->got_value = funcval.got_value;
1705 + got_entry->entry_point = funcval.entry_point;
1706 +#endif
1707 +
1708 + return got_entry;
1709 +}
1710 +
1711 +static int
1712 +_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
1713 + unsigned long rel_addr, unsigned long rel_size,
1714 + int (*reloc_fnc) (struct elf_resolve *tpnt, struct dyn_elf *scope,
1715 + ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab))
1716 +{
1717 + unsigned int i;
1718 + char *strtab;
1719 + ElfW(Sym) *symtab;
1720 + ELF_RELOC *rpnt;
1721 + int symtab_index;
1722 +
1723 + /* Now parse the relocation information */
1724 + rpnt = (ELF_RELOC *) rel_addr;
1725 + rel_size = rel_size / sizeof(ELF_RELOC);
1726 +
1727 + symtab = (ElfW(Sym) *) tpnt->dynamic_info[DT_SYMTAB];
1728 + strtab = (char *) tpnt->dynamic_info[DT_STRTAB];
1729 +
1730 + for (i = 0; i < rel_size; i++, rpnt++) {
1731 + int res;
1732 +
1733 + symtab_index = ELF_R_SYM(rpnt->r_info);
1734 + debug_sym(symtab,strtab,symtab_index);
1735 + debug_reloc(symtab,strtab,rpnt);
1736 +
1737 + res = reloc_fnc (tpnt, scope, rpnt, symtab, strtab);
1738 +
1739 + if (res==0) continue;
1740 +
1741 + _dl_dprintf(2, "\n%s: ",_dl_progname);
1742 +
1743 + if (symtab_index)
1744 + _dl_dprintf(2, "symbol '%s': ", strtab + symtab[symtab_index].st_name);
1745 +
1746 + if (res <0) {
1747 + int reloc_type = ELF_R_TYPE(rpnt->r_info);
1748 +#if defined (__SUPPORT_LD_DEBUG__)
1749 + _dl_dprintf(2, "can't handle reloc type %s\n ", _dl_reltypes(reloc_type));
1750 +#else
1751 + _dl_dprintf(2, "can't handle reloc type %x\n", reloc_type);
1752 +#endif
1753 + _dl_exit(-res);
1754 + } else if (res >0) {
1755 + _dl_dprintf(2, "can't resolve symbol\n");
1756 + return res;
1757 + }
1758 + }
1759 + return 0;
1760 +}
1761 +
1762 +static int
1763 +_dl_do_reloc (struct elf_resolve *tpnt,struct dyn_elf *scope,
1764 + ELF_RELOC *rpnt, ElfW(Sym) *symtab, char *strtab)
1765 +{
1766 + int reloc_type;
1767 + int symtab_index;
1768 + char *symname;
1769 + unsigned long reloc_value = 0, *reloc_addr;
1770 + struct { unsigned long v; } __attribute__((__packed__))
1771 + *reloc_addr_packed;
1772 + unsigned long symbol_addr;
1773 + struct elf_resolve *symbol_tpnt;
1774 + struct funcdesc_value funcval;
1775 +#if defined (__SUPPORT_LD_DEBUG__)
1776 + unsigned long old_val;
1777 +#endif
1778 +
1779 + reloc_addr = (unsigned long *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset);
1780 + __asm__ ("" : "=r" (reloc_addr_packed) : "0" (reloc_addr));
1781 + reloc_type = ELF_R_TYPE(rpnt->r_info);
1782 + symtab_index = ELF_R_SYM(rpnt->r_info);
1783 + symbol_addr = 0;
1784 + symname = strtab + symtab[symtab_index].st_name;
1785 +
1786 + if (ELF_ST_BIND (symtab[symtab_index].st_info) == STB_LOCAL) {
1787 + symbol_addr = (unsigned long) DL_RELOC_ADDR(tpnt->loadaddr, symtab[symtab_index].st_value);
1788 + symbol_tpnt = tpnt;
1789 + } else {
1790 +
1791 + symbol_addr = (unsigned long)
1792 + _dl_lookup_hash(symname, scope, NULL, 0, &symbol_tpnt);
1793 +
1794 + /*
1795 + * We want to allow undefined references to weak symbols - this might
1796 + * have been intentional. We should not be linking local symbols
1797 + * here, so all bases should be covered.
1798 + */
1799 +
1800 + if (!symbol_addr && ELF_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
1801 + _dl_dprintf (2, "%s: can't resolve symbol '%s'\n",
1802 + _dl_progname, strtab + symtab[symtab_index].st_name);
1803 + _dl_exit (1);
1804 + }
1805 + }
1806 +
1807 +#if defined (__SUPPORT_LD_DEBUG__)
1808 + if (_dl_debug_reloc && _dl_debug_detail)
1809 + {
1810 + if ((long)reloc_addr_packed & 3)
1811 + old_val = reloc_addr_packed->v;
1812 + else
1813 + old_val = *reloc_addr;
1814 + }
1815 + else
1816 + old_val = 0;
1817 +#endif
1818 + switch (reloc_type) {
1819 + case R_UBICOM32_NONE:
1820 + break;
1821 + case R_UBICOM32_32:
1822 + if ((long)reloc_addr_packed & 3)
1823 + reloc_value = reloc_addr_packed->v += symbol_addr;
1824 + else
1825 + reloc_value = *reloc_addr += symbol_addr;
1826 + break;
1827 + case R_UBICOM32_FUNCDESC_VALUE:
1828 + funcval.entry_point = (void*)symbol_addr;
1829 + /* The addend of FUNCDESC_VALUE
1830 + relocations referencing global
1831 + symbols must be ignored, because it
1832 + may hold the address of a lazy PLT
1833 + entry. */
1834 + if (ELF_ST_BIND(symtab[symtab_index].st_info) == STB_LOCAL)
1835 + funcval.entry_point += *reloc_addr;
1836 + reloc_value = (unsigned long)funcval.entry_point;
1837 + if (symbol_addr)
1838 + funcval.got_value
1839 + = symbol_tpnt->loadaddr.got_value;
1840 + else
1841 + funcval.got_value = 0;
1842 +
1843 +/// XXX this is my best guess as to what I should be doing, but I'm
1844 +/// putting a break-point here so I can inspect the first time this is
1845 +/// used.
1846 + __asm__ (
1847 + " move.4 4(%0), 4(%1) \n\t"
1848 + " move.4 0(%0), 0(%1) \n\t" /* Must to entry_point last */
1849 + :
1850 + : "a" (reloc_addr), "a" (&funcval)
1851 + : "memory" );
1852 + break;
1853 + case R_UBICOM32_FUNCDESC:
1854 + if ((long)reloc_addr_packed & 3)
1855 + reloc_value = reloc_addr_packed->v;
1856 + else
1857 + reloc_value = *reloc_addr;
1858 + if (symbol_addr)
1859 + reloc_value = (unsigned long)_dl_funcdesc_for
1860 + ((char *)symbol_addr + reloc_value,
1861 + symbol_tpnt->loadaddr.got_value);
1862 + else
1863 + reloc_value = 0;
1864 + if ((long)reloc_addr_packed & 3)
1865 + reloc_addr_packed->v = reloc_value;
1866 + else
1867 + *reloc_addr = reloc_value;
1868 + break;
1869 + default:
1870 + return -1;
1871 + }
1872 +#if defined (__SUPPORT_LD_DEBUG__)
1873 + if (_dl_debug_reloc && _dl_debug_detail) {
1874 + _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, reloc_value, reloc_addr);
1875 + switch (reloc_type) {
1876 + case R_UBICOM32_FUNCDESC_VALUE:
1877 + _dl_dprintf(_dl_debug_file, " got %x", ((struct funcdesc_value *)reloc_value)->got_value);
1878 + break;
1879 + case R_UBICOM32_FUNCDESC:
1880 + if (! reloc_value)
1881 + break;
1882 + _dl_dprintf(_dl_debug_file, " funcdesc (%x,%x)",
1883 + ((struct funcdesc_value *)reloc_value)->entry_point,
1884 + ((struct funcdesc_value *)reloc_value)->got_value);
1885 + break;
1886 + }
1887 + }
1888 +#endif
1889 +
1890 + return 0;
1891 +}
1892 +
1893 +static int
1894 +_dl_do_lazy_reloc (struct elf_resolve *tpnt,
1895 + struct dyn_elf *scope __attribute__((unused)),
1896 + ELF_RELOC *rpnt, ElfW(Sym) *symtab __attribute__((unused)),
1897 + char *strtab __attribute__((unused)))
1898 +{
1899 + int reloc_type;
1900 + struct funcdesc_value volatile *reloc_addr;
1901 + struct funcdesc_value funcval;
1902 +#if defined (__SUPPORT_LD_DEBUG__)
1903 + unsigned long old_val;
1904 +#endif
1905 +
1906 + reloc_addr = (struct funcdesc_value *) DL_RELOC_ADDR(tpnt->loadaddr, rpnt->r_offset);
1907 + reloc_type = ELF_R_TYPE(rpnt->r_info);
1908 +
1909 +#if defined (__SUPPORT_LD_DEBUG__)
1910 + old_val = (unsigned long)reloc_addr->entry_point;
1911 +#endif
1912 + switch (reloc_type) {
1913 + case R_UBICOM32_NONE:
1914 + break;
1915 + case R_UBICOM32_FUNCDESC_VALUE:
1916 + funcval = *reloc_addr;
1917 + funcval.entry_point = (void*)DL_RELOC_ADDR(tpnt->loadaddr, funcval.entry_point);
1918 + funcval.got_value = tpnt->loadaddr.got_value;
1919 + *reloc_addr = funcval;
1920 + break;
1921 + default:
1922 + return -1;
1923 + }
1924 +#if defined (__SUPPORT_LD_DEBUG__)
1925 + if (_dl_debug_reloc && _dl_debug_detail)
1926 + _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x", old_val, reloc_addr->entry_point, reloc_addr);
1927 +#endif
1928 + return 0;
1929 +
1930 +}
1931 +
1932 +void
1933 +_dl_parse_lazy_relocation_information
1934 +(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
1935 +{
1936 + _dl_parse(rpnt->dyn, NULL, rel_addr, rel_size, _dl_do_lazy_reloc);
1937 +}
1938 +
1939 +int
1940 +_dl_parse_relocation_information
1941 +(struct dyn_elf *rpnt, unsigned long rel_addr, unsigned long rel_size)
1942 +{
1943 + return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size, _dl_do_reloc);
1944 +}
1945 +
1946 +#if 0
1947 +/* We don't have copy relocs. */
1948 +int
1949 +_dl_parse_copy_information
1950 +(struct dyn_elf *rpnt __attribute__((unused)),
1951 + unsigned long rel_addr __attribute__((unused)),
1952 + unsigned long rel_size __attribute__((unused)))
1953 +{
1954 + return 0;
1955 +}
1956 +#endif
1957 +#ifndef IS_IN_libdl
1958 +# include "../../libc/sysdeps/linux/ubicom32/crtreloc.c"
1959 +#endif
1960 Index: uClibc-0.9.30.2/ldso/ldso/ubicom32/resolve.S
1961 ===================================================================
1962 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1963 +++ uClibc-0.9.30.2/ldso/ldso/ubicom32/resolve.S 2010-01-14 11:05:01.000000000 +0100
1964 @@ -0,0 +1,161 @@
1965 + /* Copyright (C) 2003 Red Hat, Inc.
1966 + Contributed by Alexandre Oliva <aoliva@redhat.com>
1967 +
1968 + Copyright (C) 2009 Ubicom Inc.
1969 + Ported to Ubicom32 by Ubicom Inc.
1970 +
1971 +This file is part of uClibc.
1972 +
1973 +uClibc is free software; you can redistribute it and/or modify it
1974 +under the terms of the GNU Lesser General Public License as
1975 +published by the Free Software Foundation; either version 2.1 of the
1976 +License, or (at your option) any later version.
1977 +
1978 +uClibc is distributed in the hope that it will be useful, but WITHOUT
1979 +ANY WARRANTY; without even the implied warranty of
1980 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1981 +Library General Public License for more details.
1982 +
1983 +You should have received a copy of the GNU Lesser General Public
1984 +License along with uClibc; see the file COPYING.LIB. If not, write to
1985 +the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
1986 +USA. */
1987 +
1988 +
1989 +/*
1990 + * The function below is tail-called by resolver stubs when a lazily-bound *
1991 + * function is called. It must preserve all registers that could * be used to
1992 + * pass arguments to the actual function.
1993 + *
1994 + * On entry to the function d0-d13 contain parameters to the actual function of
1995 + * interest
1996 + *
1997 + * a5 contains the return address
1998 + * a0 is pointing to the GOT table for the original function
1999 + * (a0) _dl_linux_resolve
2000 + * 4(a0) GOT for _dl_linux_resolve
2001 + * 8(a0) is pointer to "structure elf_resolve" of the module where the call
2002 + * originated from
2003 + *
2004 + * a3 is pointing to the function descriptor in the GOT table, and 8(a3) the
2005 + * resolver lookup information.
2006 + *
2007 + * _dl_linux_resolve calls _dl_linux_resolver passing it pointer to
2008 + * struct elf_resolve and the relocation entry.
2009 + *
2010 + * _dl_linux_resolver() figures out where the jump symbol is _really_ supposed
2011 + * to have jumped to and returns that to us. Once we have that, we prepare to
2012 + * tail-call the actual function, clean up after ourselves, restoring the
2013 + * original arguments, then jump to the fixed up address.
2014 + */
2015 +
2016 +#if 0
2017 + /*
2018 + * Here is what the linker will use for the PLT.
2019 + */
2020 +sample_PLT_functionX: /* (at entry a0 contains GOT for this library) */
2021 + movei d15, # -%lo(got_funcdescX) ; load offset for GOT
2022 + lea.4 a3, (a0, d15) ; a4 is now the function descriptor
2023 + move.4 a4, 0(a3) ; get entry_point
2024 + move.4 a0, 4(a3) ; set new GOT
2025 +
2026 + /*
2027 + * jump to resovled function OR PLT_trampoline Nat had some code here
2028 + * that uses the stack instead of a3 to reduces hazards.
2029 + */
2030 + calli a4, 0(a4)
2031 +
2032 +
2033 +sample_PLT_trampoline:
2034 + /*
2035 + * find the old got by undoing what was done above. An alternative
2036 + * could have been to ‘save’ the old got in say d14 but that would add 1
2037 + * instruction to every PLT and there is only 1 PLT trampoline per library.
2038 + */
2039 + ret (a0) ; jump to _dl_linux_resolve
2040 +#endif
2041 +
2042 + .text
2043 + .p2align 4
2044 +
2045 + .hidden _dl_linux_resolve
2046 + .global _dl_linux_resolve
2047 + .type _dl_linux_resolve,@function
2048 +_dl_linux_resolve:
2049 + /* Preserve arguments and return address */
2050 + move.4 -4(sp)++, d0
2051 + move.4 -4(sp)++, d1
2052 + move.4 -4(sp)++, d2
2053 + move.4 -4(sp)++, d3
2054 + move.4 -4(sp)++, d4
2055 + move.4 -4(sp)++, d5
2056 + move.4 -4(sp)++, d6
2057 + move.4 -4(sp)++, d7
2058 + move.4 -4(sp)++, d8
2059 + move.4 -4(sp)++, d9
2060 + move.4 -4(sp)++, d10
2061 + move.4 -4(sp)++, d11
2062 + move.4 -4(sp)++, d12
2063 + move.4 -4(sp)++, d13
2064 + move.4 -4(sp)++, a5
2065 +
2066 + /* Prepare to call _dl_linux_resolver. */
2067 + move.4 d0, 8(a0) ; reference to elf_resolve
2068 + /* Not aligned for space reasons. */
2069 + move.4 d1, mac_hi ; reference to GOT table entry which
2070 + ; contains the relocation information.
2071 +
2072 + move.4 a0, 4(a0) ; switch to GOT for _dl_linux_resolve
2073 + call a5, _dl_linux_resolver;
2074 +
2075 + /* Move aside return value that contains the FUNCDESC_VALUE. */
2076 + ;P3 = R0;
2077 + move.4 a3, d0;
2078 +
2079 + /* Restore arguments. */
2080 + move.4 a5, (sp)4++
2081 + move.4 d13, (sp)4++
2082 + move.4 d12, (sp)4++
2083 + move.4 d11, (sp)4++
2084 + move.4 d10, (sp)4++
2085 + move.4 d9, (sp)4++
2086 + move.4 d8, (sp)4++
2087 + move.4 d7, (sp)4++
2088 + move.4 d6, (sp)4++
2089 + move.4 d5, (sp)4++
2090 + move.4 d4, (sp)4++
2091 + move.4 d3, (sp)4++
2092 + move.4 d2, (sp)4++
2093 + move.4 d1, (sp)4++
2094 + move.4 d0, (sp)4++
2095 +
2096 + /* Now jump to the actual function. */
2097 + /* a3 contains func_desc resolution */
2098 + move.4 a4, 0(a3) ; address of function X
2099 + move.4 a0, 4(a3) ; switch to GOT for function X
2100 + calli a4, 0(a4) ; call through a4, a5 remains
2101 +
2102 + .size _dl_linux_resolve, . - _dl_linux_resolve
2103 +
2104 + .hidden _dl_ubicom32_resolve_pending
2105 + .global _dl_ubicom32_resolve_pending
2106 + .type _dl_ubicom32_resolve_pending,@function
2107 +
2108 +_dl_ubicom32_resolve_pending:
2109 + /*
2110 + * A special function that is used to ensure thread saftly when the fd
2111 + * for a particular resolution is being updated.
2112 + *
2113 + * At entry, a3 must point to the FD. While the FD is being updated the
2114 + * entry_point will continue to point to _dl_ubicom32_resolve_pending so
2115 + * we will effectively spin until the resolver update is complete.
2116 + */
2117 +
2118 + move.4 a4, 0(a3) ; get entry_point
2119 + move.4 a0, 4(a3) ; set new GOT
2120 +
2121 + /*
2122 + * jump to resovled function or back to _dl_ubicom32_resolve_pending.
2123 + */
2124 + calli a4, 0(a4)
2125 + .size _dl_ubicom32_resolve_pending, . - _dl_ubicom32_resolve_pending
2126 Index: uClibc-0.9.30.2/libc/misc/Makefile.in
2127 ===================================================================
2128 --- uClibc-0.9.30.2.orig/libc/misc/Makefile.in 2010-01-13 22:22:31.000000000 +0100
2129 +++ uClibc-0.9.30.2/libc/misc/Makefile.in 2010-01-14 11:05:01.000000000 +0100
2130 @@ -12,7 +12,9 @@
2131 include $(top_srcdir)libc/misc/ctype/Makefile.in
2132 include $(top_srcdir)libc/misc/dirent/Makefile.in
2133 include $(top_srcdir)libc/misc/error/Makefile.in
2134 +ifneq ($(ARCH_HAS_NO_LDSO),y)
2135 include $(top_srcdir)libc/misc/elf/Makefile.in
2136 +endif
2137 include $(top_srcdir)libc/misc/file/Makefile.in
2138 include $(top_srcdir)libc/misc/fnmatch/Makefile.in
2139 include $(top_srcdir)libc/misc/ftw/Makefile.in
2140 Index: uClibc-0.9.30.2/libc/misc/elf/dl-iterate-phdr.c
2141 ===================================================================
2142 --- uClibc-0.9.30.2.orig/libc/misc/elf/dl-iterate-phdr.c 2010-01-13 22:22:31.000000000 +0100
2143 +++ uClibc-0.9.30.2/libc/misc/elf/dl-iterate-phdr.c 2010-01-14 11:05:01.000000000 +0100
2144 @@ -14,7 +14,7 @@
2145
2146 #include <link.h>
2147 #include <ldso.h>
2148 -
2149 +#include <memory.h>
2150 /* we want this in libc but nowhere else */
2151 #ifdef __USE_GNU
2152
2153 Index: uClibc-0.9.30.2/libc/stdlib/malloc/malloc.c
2154 ===================================================================
2155 --- uClibc-0.9.30.2.orig/libc/stdlib/malloc/malloc.c 2010-01-13 22:22:31.000000000 +0100
2156 +++ uClibc-0.9.30.2/libc/stdlib/malloc/malloc.c 2010-01-14 11:05:01.000000000 +0100
2157 @@ -25,7 +25,7 @@
2158
2159 /* The malloc heap. We provide a bit of initial static space so that
2160 programs can do a little mallocing without mmaping in more space. */
2161 -HEAP_DECLARE_STATIC_FREE_AREA (initial_fa, 256);
2162 +HEAP_DECLARE_STATIC_FREE_AREA (initial_fa, 32768);
2163 struct heap_free_area *__malloc_heap = HEAP_INIT_WITH_FA (initial_fa);
2164 #ifdef HEAP_USE_LOCKING
2165 pthread_mutex_t __malloc_heap_lock = PTHREAD_MUTEX_INITIALIZER;
2166 Index: uClibc-0.9.30.2/libc/string/ubicom32/Makefile
2167 ===================================================================
2168 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2169 +++ uClibc-0.9.30.2/libc/string/ubicom32/Makefile 2010-01-14 11:05:01.000000000 +0100
2170 @@ -0,0 +1,13 @@
2171 +# Makefile for uClibc
2172 +#
2173 +# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
2174 +#
2175 +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
2176 +#
2177 +
2178 +top_srcdir:=../../../
2179 +top_builddir:=../../../
2180 +all: objs
2181 +include $(top_builddir)Rules.mak
2182 +include ../Makefile.in
2183 +include $(top_srcdir)Makerules
2184 Index: uClibc-0.9.30.2/libc/string/ubicom32/memcpy.c
2185 ===================================================================
2186 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2187 +++ uClibc-0.9.30.2/libc/string/ubicom32/memcpy.c 2010-01-14 11:05:01.000000000 +0100
2188 @@ -0,0 +1,152 @@
2189 +/* Copy memory to memory until the specified number of bytes
2190 + has been copied. Overlap is NOT handled correctly.
2191 + Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc.
2192 + This file is part of the GNU C Library.
2193 + Contributed by Torbjorn Granlund (tege@sics.se).
2194 +
2195 + The GNU C Library is free software; you can redistribute it and/or
2196 + modify it under the terms of the GNU Lesser General Public
2197 + License as published by the Free Software Foundation; either
2198 + version 2.1 of the License, or (at your option) any later version.
2199 +
2200 + The GNU C Library is distributed in the hope that it will be useful,
2201 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2202 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2203 + Lesser General Public License for more details.
2204 +
2205 + You should have received a copy of the GNU Lesser General Public
2206 + License along with the GNU C Library; if not, write to the Free
2207 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2208 + 02111-1307 USA. */
2209 +
2210 +#include <string.h>
2211 +
2212 +typedef unsigned long addr_t;
2213 +
2214 +libc_hidden_proto(memcpy)
2215 +
2216 +void *memcpy (void *dest, const void *src, size_t n)
2217 +{
2218 + void *dest_ret = dest;
2219 + void *aligned_start;
2220 +
2221 + if (likely((((addr_t)dest ^ (addr_t)src) & 3) == 0) && likely(n > 6)) {
2222 + size_t m;
2223 + n -= (4 - (addr_t)dest) & 0x03;
2224 + m = n >> 2;
2225 + __asm__ volatile (
2226 + " call %4, 99f \n\t" // load %4 with address of 99
2227 + "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99
2228 + " add.4 %4, %4, d15 \n\t" // add difference
2229 +
2230 + " sub.4 d15, #0, %2 \n\t" // set up for jump table
2231 + " and.4 d15, #(32-1), d15 \n\t" // d15 = (-m) & (32 - 1)
2232 + " lea.4 %4, (%4,d15) \n\t"
2233 +
2234 + " bfextu d15, %0, #2 \n\t" // d15 = (dest & 3)
2235 + " jmpne.w.f 100f \n\t"
2236 + " calli %4, 0(%4) \n\t" // 4-byte alignment
2237 +
2238 + "100: cmpi d15, #2 \n\t"
2239 + " jmpne.s.f 101f \n\t"
2240 + " move.2 (%0)2++, (%1)2++ \n\t"
2241 + " calli %4, 0(%4) \n\t" // 2-byte alignment
2242 +
2243 + "101: move.1 (%0)1++, (%1)1++ \n\t"
2244 + " jmpgt.s.f 102f \n\t" // 3-byte alignment
2245 + " move.2 (%0)2++, (%1)2++ \n\t" // 1-byte alignment
2246 + "102: calli %4, 0(%4) \n\t"
2247 +
2248 + "200: cmpi %3, #2 \n\t"
2249 + " jmplt.s.f 201f \n\t"
2250 + " move.2 (%0)2++, (%1)2++ \n\t"
2251 + " jmpeq.s.t 2f \n\t"
2252 + "201: move.1 (%0)1++, (%1)1++ \n\t"
2253 + " jmpt.w.t 2f \n\t"
2254 +
2255 + "1: .rept 25 \n\t"
2256 + " movea (%0)4++, (%1)4++ \n\t"
2257 + " .endr \n\t"
2258 + " .rept 7 \n\t"
2259 + " move.4 (%0)4++, (%1)4++ \n\t"
2260 + " .endr \n\t"
2261 + " add.4 %2, #-32, %2 \n\t"
2262 + " jmpgt.w.f 1b \n\t"
2263 +
2264 + " and.4 %3, #3, %3 \n\t" // check n
2265 + " jmpne.w.f 200b \n\t"
2266 + "2: \n\t"
2267 + : "+a"(dest), "+a"(src), "+d"(m), "+d"(n), "=a"(aligned_start)
2268 + :
2269 + : "d15", "memory", "cc"
2270 + );
2271 +
2272 + return dest_ret;
2273 + }
2274 +
2275 + if (likely((((addr_t)dest ^ (addr_t)src) & 1) == 0) && likely(n > 2)) {
2276 + size_t m;
2277 + n -= (addr_t)dest & 0x01;
2278 + m = n >> 1;
2279 + __asm__ volatile (
2280 + " call %4, 99f \n\t" // load %4 with address of 99
2281 + "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99
2282 + " add.4 %4, %4, d15 \n\t" // add difference
2283 +
2284 + " sub.4 d15, #0, %2 \n\t" // set up for jump table
2285 + " and.4 d15, #(32-1), d15 \n\t" // d15 = (-m) & (32 - 1)
2286 + " lea.4 %4, (%4,d15) \n\t"
2287 +
2288 + " btst %0, #0 \n\t" // check bit 0
2289 + " jmpne.w.f 100f \n\t"
2290 + " calli %4, 0(%4) \n\t" // 4-byte alignment
2291 +
2292 + "100: move.1 (%0)1++, (%1)1++ \n\t"
2293 + " calli %4, 0(%4) \n\t"
2294 +
2295 + "200: move.1 (%0)1++, (%1)1++ \n\t"
2296 + " jmpt.w.t 2f \n\t"
2297 +
2298 + "1: .rept 32 \n\t"
2299 + " move.2 (%0)2++, (%1)2++ \n\t"
2300 + " .endr \n\t"
2301 + " add.4 %2, #-32, %2 \n\t"
2302 + " jmpgt.w.f 1b \n\t"
2303 +
2304 + " and.4 %3, #1, %3 \n\t" // check n
2305 + " jmpne.w.f 200b \n\t"
2306 + "2: \n\t"
2307 +
2308 + : "+a"(dest), "+a"(src), "+d"(m), "+d"(n), "=a"(aligned_start)
2309 + :
2310 + : "d15", "memory", "cc"
2311 + );
2312 + return dest_ret;
2313 + }
2314 +
2315 + __asm__ volatile (
2316 + " call %3, 99f \n\t" // load %3 with address of 99
2317 + "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99
2318 + " add.4 %3, %3, d15 \n\t" // add difference
2319 +
2320 + " sub.4 d15, #0, %2 \n\t"
2321 + " jmpeq.w.f 2f \n\t"
2322 + " and.4 d15, #(16-1), d15 \n\t" // d15 = (-n) & (16 - 1)
2323 + " lea.4 %3, (%3,d15) \n\t"
2324 + " calli %3, 0(%3) \n\t"
2325 +
2326 + "1: .rept 16 \n\t"
2327 + " move.1 (%0)1++, (%1)1++ \n\t"
2328 + " .endr \n\t"
2329 + " add.4 %2, #-16, %2 \n\t"
2330 + " jmpgt.w.f 1b \n\t"
2331 + "2: \n\t"
2332 +
2333 + : "+a"(dest), "+a"(src), "+d"(n), "=a"(aligned_start)
2334 + :
2335 + : "d15", "memory", "cc"
2336 + );
2337 +
2338 + return dest_ret;
2339 +}
2340 +libc_hidden_def(memcpy)
2341 Index: uClibc-0.9.30.2/libc/string/ubicom32/memset.c
2342 ===================================================================
2343 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2344 +++ uClibc-0.9.30.2/libc/string/ubicom32/memset.c 2010-01-14 11:05:01.000000000 +0100
2345 @@ -0,0 +1,107 @@
2346 +/* Copyright (C) 1991, 1997, 2003 Free Software Foundation, Inc.
2347 + This file is part of the GNU C Library.
2348 +
2349 + The GNU C Library is free software; you can redistribute it and/or
2350 + modify it under the terms of the GNU Lesser General Public
2351 + License as published by the Free Software Foundation; either
2352 + version 2.1 of the License, or (at your option) any later version.
2353 +
2354 + The GNU C Library is distributed in the hope that it will be useful,
2355 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2356 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2357 + Lesser General Public License for more details.
2358 +
2359 + You should have received a copy of the GNU Lesser General Public
2360 + License along with the GNU C Library; if not, write to the Free
2361 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2362 + 02111-1307 USA. */
2363 +
2364 +#include <string.h>
2365 +
2366 +typedef unsigned long addr_t;
2367 +
2368 +libc_hidden_proto(memset)
2369 +void *memset (void *s, int c, size_t n)
2370 +{
2371 + void *s_ret = s;
2372 + void *aligned_start;
2373 + if (likely(n > 6)) {
2374 + size_t m;
2375 + n -= (4 - (addr_t)s) & 0x03;
2376 + m = n >> 2;
2377 + __asm__ volatile (
2378 + " call %4, 99f \n\t" // load %4 with address of 99
2379 + "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99
2380 + " add.4 %4, %4, d15 \n\t" // add difference
2381 +
2382 + " sub.4 d15, #0, %2 \n\t" // set up for jump table
2383 + " and.4 d15, #(32-1), d15 \n\t" // d15 = (-m) & (32 - 1)
2384 + " shmrg.1 %1, %1, %1 \n\t"
2385 + " shmrg.2 %1, %1, %1 \n\t" // %1 = (c<<24)|(c<<16)|(c<<8)|c
2386 + " lea.4 %4, (%4,d15) \n\t"
2387 +
2388 + " bfextu d15, %0, #2 \n\t" // d15 = (s & 3)
2389 + " jmpne.w.f 100f \n\t"
2390 + " calli %4, 0(%4) \n\t" // 4-byte alignment
2391 +
2392 + "100: cmpi d15, #2 \n\t"
2393 + " jmpne.s.f 101f \n\t"
2394 + " move.2 (%0)2++, %1 \n\t"
2395 + " calli %4, 0(%4) \n\t" // 2-byte alignment
2396 +
2397 + "101: move.1 (%0)1++, %1 \n\t"
2398 + " jmpgt.s.f 102f \n\t" // 3-byte alignment
2399 + " move.2 (%0)2++, %1 \n\t" // 1-byte alignment
2400 + "102: calli %4, 0(%4) \n\t"
2401 +
2402 + "200: cmpi %3, #2 \n\t"
2403 + " jmplt.s.f 201f \n\t"
2404 + " move.2 (%0)2++, %1 \n\t"
2405 + " jmpeq.s.t 2f \n\t"
2406 + "201: move.1 (%0)1++, %1 \n\t"
2407 + " jmpt.w.t 2f \n\t"
2408 +
2409 + "1: .rept 25 \n\t"
2410 + " movea (%0)4++, %1 \n\t"
2411 + " .endr \n\t"
2412 + " .rept 7 \n\t"
2413 + " move.4 (%0)4++, %1 \n\t"
2414 + " .endr \n\t"
2415 + " add.4 %2, #-32, %2 \n\t"
2416 + " jmpgt.w.f 1b \n\t"
2417 +
2418 + " and.4 %3, #3, %3 \n\t" // test bit 1 of n
2419 + " jmpne.w.f 200b \n\t"
2420 + "2: \n\t"
2421 + : "+a"(s), "+d"(c), "+d"(m), "+d"(n), "=a"(aligned_start)
2422 + :
2423 + : "d15", "memory", "cc"
2424 + );
2425 +
2426 + return s_ret;
2427 + }
2428 +
2429 + __asm__ volatile (
2430 + " call %3, 99f \n\t" // load %3 with address of 99
2431 + "99: movei d15, #%%lo(1f-99b) \n\t" // load d15 with offset to 1 from 99
2432 + " add.4 %3, %3, d15 \n\t" // add difference
2433 +
2434 + " sub.4 d15, #0, %2 \n\t"
2435 + " jmpeq.w.f 2f \n\t"
2436 + " and.4 d15, #(8-1), d15 \n\t" // d15 = (-%2) & (16 - 1)
2437 + " lea.4 %3, (%3,d15) \n\t"
2438 + " calli %3, 0(%3) \n\t"
2439 +
2440 + "1: .rept 8 \n\t"
2441 + " move.1 (%0)1++, %1 \n\t"
2442 + " .endr \n\t"
2443 + "2: \n\t"
2444 +
2445 + : "+a"(s), "+d"(c), "+d"(n), "=a"(aligned_start)
2446 + :
2447 + : "d15", "memory", "cc"
2448 + );
2449 +
2450 + return s_ret;
2451 +}
2452 +libc_hidden_def(memset)
2453 Index: uClibc-0.9.30.2/libc/sysdeps/linux/common/sys/user.h
2454 ===================================================================
2455 --- uClibc-0.9.30.2.orig/libc/sysdeps/linux/common/sys/user.h 2010-01-13 22:22:31.000000000 +0100
2456 +++ uClibc-0.9.30.2/libc/sysdeps/linux/common/sys/user.h 2010-01-14 11:05:01.000000000 +0100
2457 @@ -1 +1,4 @@
2458 +#if 0
2459 +/* As of linux v2.6.25 this is not part of the exported linux headers */
2460 #include <linux/user.h>
2461 +#endif
2462 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile
2463 ===================================================================
2464 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2465 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile 2010-01-14 11:05:01.000000000 +0100
2466 @@ -0,0 +1,13 @@
2467 +# Makefile for uClibc
2468 +#
2469 +# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
2470 +#
2471 +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
2472 +#
2473 +
2474 +top_srcdir=../../../../
2475 +top_builddir=../../../../
2476 +all: objs
2477 +include $(top_builddir)Rules.mak
2478 +include Makefile.arch
2479 +include $(top_srcdir)Makerules
2480 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile.arch
2481 ===================================================================
2482 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2483 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/Makefile.arch 2010-01-14 11:05:01.000000000 +0100
2484 @@ -0,0 +1,28 @@
2485 +# Makefile for uClibc
2486 +#
2487 +# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
2488 +#
2489 +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
2490 +#
2491 +
2492 +#CSRC := \
2493 +# brk.c \
2494 +# crtbegin.c \
2495 +# crtend.c
2496 +#
2497 +#SSRC := \
2498 +# __longjmp.S \
2499 +# bsd-_setjmp.S \
2500 +# bsd-setjmp.S \
2501 +# setjmp.S \
2502 +# clone.S \
2503 +# vfork.S
2504 +
2505 +CSRC := \
2506 + syscall.c __syscall_error.c
2507 +
2508 +SSRC := \
2509 + clone.S setjmp.S vfork.S
2510 +
2511 +ARCH_CFLAGS := $(CPU_CFLAGS-y)
2512 +include $(top_srcdir)libc/sysdeps/linux/Makefile.commonarch
2513 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/__syscall_error.c
2514 ===================================================================
2515 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2516 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/__syscall_error.c 2010-01-14 11:05:01.000000000 +0100
2517 @@ -0,0 +1,11 @@
2518 +#include <errno.h>
2519 +#include <features.h>
2520 +
2521 +/* This routine is jumped to by some of the syscall handlers, to stash
2522 + * an error number into errno. */
2523 +int __syscall_error(int err_no) attribute_hidden;
2524 +int __syscall_error(int err_no)
2525 +{
2526 + __set_errno(err_no);
2527 + return -1;
2528 +}
2529 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/elf-fdpic.h
2530 ===================================================================
2531 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2532 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/elf-fdpic.h 2010-01-14 11:05:01.000000000 +0100
2533 @@ -0,0 +1,115 @@
2534 +/* Copyright 2003, 2004 Free Software Foundation, Inc.
2535 +This file is part of the GNU C Library.
2536 +
2537 +The GNU C Library is free software; you can redistribute it and/or
2538 +modify it under the terms of the GNU Lesser General Public License as
2539 +published by the Free Software Foundation; either version 2.1 of the
2540 +License, or (at your option) any later version.
2541 +
2542 +In addition to the permissions in the GNU Lesser General Public
2543 +License, the Free Software Foundation gives you unlimited
2544 +permission to link the compiled version of this file with other
2545 +programs, and to distribute those programs without any restriction
2546 +coming from the use of this file. (The GNU Lesser General Public
2547 +License restrictions do apply in other respects; for example, they
2548 +cover modification of the file, and distribution when not linked
2549 +into another program.)
2550 +
2551 +The GNU C Library is distributed in the hope that it will be useful,
2552 +but WITHOUT ANY WARRANTY; without even the implied warranty of
2553 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2554 +Library General Public License for more details.
2555 +
2556 +You should have received a copy of the GNU Lesser General Public
2557 +License along with the GNU C Library; see the file COPYING.LIB. If
2558 +not, write to the Free Software Foundation, Inc., 675 Mass Ave,
2559 +Cambridge, MA 02139, USA. */
2560 +
2561 +#ifndef _BITS_ELF_FDPIC_H
2562 +#define _BITS_ELF_FDPIC_H
2563 +
2564 +/* These data structures are described in the FDPIC ABI extension.
2565 + The kernel passes a process a memory map, such that for every LOAD
2566 + segment there is an elf32_fdpic_loadseg entry. A pointer to an
2567 + elf32_fdpic_loadmap is passed in d8 at start-up, and a pointer to
2568 + an additional such map is passed in d9 for the interpreter, when
2569 + there is one. */
2570 +
2571 +#include <elf.h>
2572 +
2573 +/* This data structure represents a PT_LOAD segment. */
2574 +struct elf32_fdpic_loadseg
2575 +{
2576 + /* Core address to which the segment is mapped. */
2577 + Elf32_Addr addr;
2578 + /* VMA recorded in the program header. */
2579 + Elf32_Addr p_vaddr;
2580 + /* Size of this segment in memory. */
2581 + Elf32_Word p_memsz;
2582 +};
2583 +
2584 +struct elf32_fdpic_loadmap {
2585 + /* Protocol version number, must be zero. */
2586 + Elf32_Half version;
2587 + /* Number of segments in this map. */
2588 + Elf32_Half nsegs;
2589 + /* The actual memory map. */
2590 + struct elf32_fdpic_loadseg segs[/*nsegs*/];
2591 +};
2592 +
2593 +struct elf32_fdpic_loadaddr {
2594 + struct elf32_fdpic_loadmap *map;
2595 + void *got_value;
2596 +};
2597 +
2598 +/* Map a pointer's VMA to its corresponding address according to the
2599 + load map. */
2600 +static __always_inline void *
2601 +__reloc_pointer (void *p,
2602 + const struct elf32_fdpic_loadmap *map)
2603 +{
2604 + int c;
2605 +
2606 +#if 0
2607 + if (map->version != 0)
2608 + /* Crash. */
2609 + ((void(*)())0)();
2610 +#endif
2611 +
2612 + /* No special provision is made for NULL. We don't want NULL
2613 + addresses to go through relocation, so they shouldn't be in
2614 + .rofixup sections, and, if they're present in dynamic
2615 + relocations, they shall be mapped to the NULL address without
2616 + undergoing relocations. */
2617 +
2618 + for (c = 0;
2619 + /* Take advantage of the fact that the loadmap is ordered by
2620 + virtual addresses. In general there will only be 2 entries,
2621 + so it's not profitable to do a binary search. */
2622 + c < map->nsegs && p >= (void*)map->segs[c].p_vaddr;
2623 + c++)
2624 + {
2625 + /* This should be computed as part of the pointer comparison
2626 + above, but we want to use the carry in the comparison, so we
2627 + can't convert it to an integer type beforehand. */
2628 + unsigned long offset = p - (void*)map->segs[c].p_vaddr;
2629 + /* We only check for one-past-the-end for the last segment,
2630 + assumed to be the data segment, because other cases are
2631 + ambiguous in the absence of padding between segments, and
2632 + rofixup already serves as padding between text and data.
2633 + Unfortunately, unless we special-case the last segment, we
2634 + fail to relocate the _end symbol. */
2635 + if (offset < map->segs[c].p_memsz
2636 + || (offset == map->segs[c].p_memsz && c + 1 == map->nsegs))
2637 + return (char*)map->segs[c].addr + offset;
2638 + }
2639 +
2640 + /* We might want to crash instead. */
2641 + return (void*)-1;
2642 +}
2643 +
2644 +# define __RELOC_POINTER(ptr, loadaddr) \
2645 + (__reloc_pointer ((void*)(ptr), \
2646 + (loadaddr).map))
2647 +
2648 +#endif /* _BITS_ELF_FDPIC_H */
2649 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/endian.h
2650 ===================================================================
2651 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2652 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/endian.h 2010-01-14 11:05:01.000000000 +0100
2653 @@ -0,0 +1,7 @@
2654 +/* Ubicom32 is big-endian. */
2655 +
2656 +#ifndef _ENDIAN_H
2657 +# error "Never use <bits/endian.h> directly; include <endian.h> instead."
2658 +#endif
2659 +
2660 +#define __BYTE_ORDER __BIG_ENDIAN
2661 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/fcntl.h
2662 ===================================================================
2663 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2664 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/fcntl.h 2010-01-14 11:05:01.000000000 +0100
2665 @@ -0,0 +1,224 @@
2666 +/* O_*, F_*, FD_* bit values for Linux.
2667 + Copyright (C) 2000 Free Software Foundation, Inc.
2668 + This file is part of the GNU C Library.
2669 +
2670 + The GNU C Library is free software; you can redistribute it and/or
2671 + modify it under the terms of the GNU Lesser General Public
2672 + License as published by the Free Software Foundation; either
2673 + version 2.1 of the License, or (at your option) any later version.
2674 +
2675 + The GNU C Library is distributed in the hope that it will be useful,
2676 + but WITHOUT ANY WARRANTY; without even the implied warranty of
2677 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2678 + Lesser General Public License for more details.
2679 +
2680 + You should have received a copy of the GNU Lesser General Public
2681 + License along with the GNU C Library; if not, write to the Free
2682 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
2683 + 02111-1307 USA. */
2684 +
2685 +#ifndef _FCNTL_H
2686 +# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
2687 +#endif
2688 +
2689 +
2690 +#include <sys/types.h>
2691 +#ifdef __USE_GNU
2692 +# include <bits/uio.h>
2693 +#endif
2694 +
2695 +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
2696 + located on an ext2 file system */
2697 +#define O_ACCMODE 0003
2698 +#define O_RDONLY 00
2699 +#define O_WRONLY 01
2700 +#define O_RDWR 02
2701 +#define O_CREAT 0100 /* not fcntl */
2702 +#define O_EXCL 0200 /* not fcntl */
2703 +#define O_NOCTTY 0400 /* not fcntl */
2704 +#define O_TRUNC 01000 /* not fcntl */
2705 +#define O_APPEND 02000
2706 +#define O_NONBLOCK 04000
2707 +#define O_NDELAY O_NONBLOCK
2708 +#define O_SYNC 010000
2709 +#define O_FSYNC O_SYNC
2710 +#define O_ASYNC 020000
2711 +
2712 +#ifdef __USE_GNU
2713 +# define O_DIRECTORY 040000 /* Must be a directory. */
2714 +# define O_NOFOLLOW 0100000 /* Do not follow links. */
2715 +# define O_DIRECT 0200000 /* Direct disk access. */
2716 +# define O_STREAMING 04000000/* streaming access */
2717 +#endif
2718 +
2719 +/* For now Linux has synchronisity options for data and read operations.
2720 + We define the symbols here but let them do the same as O_SYNC since
2721 + this is a superset. */
2722 +#if defined __USE_POSIX199309 || defined __USE_UNIX98
2723 +# define O_DSYNC O_SYNC /* Synchronize data. */
2724 +# define O_RSYNC O_SYNC /* Synchronize read operations. */
2725 +#endif
2726 +
2727 +#ifdef __USE_LARGEFILE64
2728 +# define O_LARGEFILE 0400000
2729 +#endif
2730 +
2731 +/* Values for the second argument to `fcntl'. */
2732 +#define F_DUPFD 0 /* Duplicate file descriptor. */
2733 +#define F_GETFD 1 /* Get file descriptor flags. */
2734 +#define F_SETFD 2 /* Set file descriptor flags. */
2735 +#define F_GETFL 3 /* Get file status flags. */
2736 +#define F_SETFL 4 /* Set file status flags. */
2737 +#ifndef __USE_FILE_OFFSET64
2738 +# define F_GETLK 5 /* Get record locking info. */
2739 +# define F_SETLK 6 /* Set record locking info (non-blocking). */
2740 +# define F_SETLKW 7 /* Set record locking info (blocking). */
2741 +#else
2742 +# define F_GETLK F_GETLK64 /* Get record locking info. */
2743 +# define F_SETLK F_SETLK64 /* Set record locking info (non-blocking).*/
2744 +# define F_SETLKW F_SETLKW64 /* Set record locking info (blocking). */
2745 +#endif
2746 +#define F_GETLK64 12 /* Get record locking info. */
2747 +#define F_SETLK64 13 /* Set record locking info (non-blocking). */
2748 +#define F_SETLKW64 14 /* Set record locking info (blocking). */
2749 +
2750 +#if defined __USE_BSD || defined __USE_XOPEN2K
2751 +# define F_SETOWN 8 /* Get owner of socket (receiver of SIGIO). */
2752 +# define F_GETOWN 9 /* Set owner of socket (receiver of SIGIO). */
2753 +#endif
2754 +
2755 +#ifdef __USE_GNU
2756 +# define F_SETSIG 10 /* Set number of signal to be sent. */
2757 +# define F_GETSIG 11 /* Get number of signal to be sent. */
2758 +#endif
2759 +
2760 +#ifdef __USE_GNU
2761 +# define F_SETLEASE 1024 /* Set a lease. */
2762 +# define F_GETLEASE 1025 /* Enquire what lease is active. */
2763 +# define F_NOTIFY 1026 /* Request notfications on a directory. */
2764 +#endif
2765 +
2766 +/* For F_[GET|SET]FL. */
2767 +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */
2768 +
2769 +/* For posix fcntl() and `l_type' field of a `struct flock' for lockf(). */
2770 +#define F_RDLCK 0 /* Read lock. */
2771 +#define F_WRLCK 1 /* Write lock. */
2772 +#define F_UNLCK 2 /* Remove lock. */
2773 +
2774 +/* For old implementation of bsd flock(). */
2775 +#define F_EXLCK 4 /* or 3 */
2776 +#define F_SHLCK 8 /* or 4 */
2777 +
2778 +#ifdef __USE_BSD
2779 +/* Operations for bsd flock(), also used by the kernel implementation. */
2780 +# define LOCK_SH 1 /* shared lock */
2781 +# define LOCK_EX 2 /* exclusive lock */
2782 +# define LOCK_NB 4 /* or'd with one of the above to prevent
2783 + blocking */
2784 +# define LOCK_UN 8 /* remove lock */
2785 +#endif
2786 +
2787 +#ifdef __USE_GNU
2788 +# define LOCK_MAND 32 /* This is a mandatory flock: */
2789 +# define LOCK_READ 64 /* ... which allows concurrent read operations. */
2790 +# define LOCK_WRITE 128 /* ... which allows concurrent write operations. */
2791 +# define LOCK_RW 192 /* ... Which allows concurrent read & write operations. */
2792 +#endif
2793 +
2794 +#ifdef __USE_GNU
2795 +/* Types of directory notifications that may be requested with F_NOTIFY. */
2796 +# define DN_ACCESS 0x00000001 /* File accessed. */
2797 +# define DN_MODIFY 0x00000002 /* File modified. */
2798 +# define DN_CREATE 0x00000004 /* File created. */
2799 +# define DN_DELETE 0x00000008 /* File removed. */
2800 +# define DN_RENAME 0x00000010 /* File renamed. */
2801 +# define DN_ATTRIB 0x00000020 /* File changed attibutes. */
2802 +# define DN_MULTISHOT 0x80000000 /* Don't remove notifier. */
2803 +#endif
2804 +
2805 +struct flock
2806 + {
2807 + short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
2808 + short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
2809 +#ifndef __USE_FILE_OFFSET64
2810 + __off_t l_start; /* Offset where the lock begins. */
2811 + __off_t l_len; /* Size of the locked area; zero means until EOF. */
2812 +#else
2813 + __off64_t l_start; /* Offset where the lock begins. */
2814 + __off64_t l_len; /* Size of the locked area; zero means until EOF. */
2815 +#endif
2816 + __pid_t l_pid; /* Process holding the lock. */
2817 + };
2818 +
2819 +#ifdef __USE_LARGEFILE64
2820 +struct flock64
2821 + {
2822 + short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */
2823 + short int l_whence; /* Where `l_start' is relative to (like `lseek'). */
2824 + __off64_t l_start; /* Offset where the lock begins. */
2825 + __off64_t l_len; /* Size of the locked area; zero means until EOF. */
2826 + __pid_t l_pid; /* Process holding the lock. */
2827 + };
2828 +#endif
2829 +
2830 +/* Define some more compatibility macros to be backward compatible with
2831 + BSD systems which did not managed to hide these kernel macros. */
2832 +#ifdef __USE_BSD
2833 +# define FAPPEND O_APPEND
2834 +# define FFSYNC O_FSYNC
2835 +# define FASYNC O_ASYNC
2836 +# define FNONBLOCK O_NONBLOCK
2837 +# define FNDELAY O_NDELAY
2838 +#endif /* Use BSD. */
2839 +
2840 +/* Advise to `posix_fadvise'. */
2841 +#ifdef __USE_XOPEN2K
2842 +# define POSIX_FADV_NORMAL 0 /* No further special treatment. */
2843 +# define POSIX_FADV_RANDOM 1 /* Expect random page references. */
2844 +# define POSIX_FADV_SEQUENTIAL 2 /* Expect sequential page references. */
2845 +# define POSIX_FADV_WILLNEED 3 /* Will need these pages. */
2846 +# define POSIX_FADV_DONTNEED 4 /* Don't need these pages. */
2847 +# define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
2848 +#endif
2849 +
2850 +#ifdef __USE_GNU
2851 +# define SYNC_FILE_RANGE_WAIT_BEFORE 1 /* Wait upon writeout of all pages
2852 + in the range before performing the
2853 + write. */
2854 +# define SYNC_FILE_RANGE_WRITE 2 /* Initiate writeout of all those
2855 + dirty pages in the range which are
2856 + not presently under writeback. */
2857 +# define SYNC_FILE_RANGE_WAIT_AFTER 4 /* Wait upon writeout of all pages in
2858 + the range after performing the
2859 + write. */
2860 +#endif
2861 +
2862 +__BEGIN_DECLS
2863 +
2864 +#ifdef __USE_GNU
2865 +
2866 +/* Provide kernel hint to read ahead. */
2867 +extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count)
2868 + __THROW;
2869 +
2870 +/* Selective file content synch'ing. */
2871 +extern int sync_file_range (int __fd, __off64_t __from, __off64_t __to,
2872 + unsigned int __flags);
2873 +
2874 +/* Splice address range into a pipe. */
2875 +extern ssize_t vmsplice (int __fdout, const struct iovec *__iov,
2876 + size_t __count, unsigned int __flags);
2877 +
2878 +/* Splice two files together. */
2879 +extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
2880 + __off64_t *__offout, size_t __len,
2881 + unsigned int __flags);
2882 +
2883 +/* In-kernel implementation of tee for pipe buffers. */
2884 +extern ssize_t tee (int __fdin, int __fdout, size_t __len,
2885 + unsigned int __flags);
2886 +
2887 +#endif
2888 +
2889 +__END_DECLS
2890 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_stat.h
2891 ===================================================================
2892 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2893 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_stat.h 2010-01-14 11:05:01.000000000 +0100
2894 @@ -0,0 +1,61 @@
2895 +#ifndef _BITS_STAT_STRUCT_H
2896 +#define _BITS_STAT_STRUCT_H
2897 +
2898 +#ifndef _LIBC
2899 +#error bits/kernel_stat.h is for internal uClibc use only!
2900 +#endif
2901 +
2902 +/* This file provides whatever this particular arch's kernel thinks
2903 + * struct kernel_stat should look like... It turns out each arch has a
2904 + * different opinion on the subject... */
2905 +
2906 +struct kernel_stat {
2907 + unsigned short st_dev;
2908 + unsigned short __pad1;
2909 + unsigned long st_ino;
2910 + unsigned short st_mode;
2911 + unsigned short st_nlink;
2912 + unsigned short st_uid;
2913 + unsigned short st_gid;
2914 + unsigned short st_rdev;
2915 + unsigned short __pad2;
2916 + unsigned long st_size;
2917 + unsigned long st_blksize;
2918 + unsigned long st_blocks;
2919 + unsigned long st_atime;
2920 + unsigned long __unused1;
2921 + unsigned long st_mtime;
2922 + unsigned long __unused2;
2923 + unsigned long st_ctime;
2924 + unsigned long __unused3;
2925 + unsigned long __unused4;
2926 + unsigned long __unused5;
2927 +};
2928 +
2929 +struct kernel_stat64 {
2930 + unsigned char __pad0[6];
2931 + unsigned short st_dev;
2932 + unsigned char __pad1[4];
2933 +#define _HAVE_STAT64___ST_INO
2934 + unsigned long __st_ino;
2935 + unsigned int st_mode;
2936 + unsigned int st_nlink;
2937 + unsigned long st_uid;
2938 + unsigned long st_gid;
2939 + unsigned char __pad2[6];
2940 + unsigned short st_rdev;
2941 + unsigned char __pad3[4];
2942 + long long st_size;
2943 + unsigned long st_blksize;
2944 + unsigned long st_blocks; /* Number 512-byte blocks allocated. */
2945 + unsigned long __pad4; /* future possible st_blocks high bits */
2946 + unsigned long st_atime;
2947 + unsigned long __pad5;
2948 + unsigned long st_mtime;
2949 + unsigned long __pad6;
2950 + unsigned long st_ctime;
2951 + unsigned long __pad7; /* will be high 32 bits of ctime someday */
2952 + unsigned long long st_ino;
2953 +};
2954 +
2955 +#endif /* _BITS_STAT_STRUCT_H */
2956 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_types.h
2957 ===================================================================
2958 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
2959 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/kernel_types.h 2010-01-14 11:05:01.000000000 +0100
2960 @@ -0,0 +1,44 @@
2961 +/* Note that we use the exact same include guard #define names
2962 + * as asm/posix_types.h. This will avoid gratuitous conflicts
2963 + * with the posix_types.h kernel header, and will ensure that
2964 + * our private content, and not the kernel header, will win.
2965 + * -Erik
2966 + */
2967 +#ifndef __ARCH_UBICOM32_POSIX_TYPES_H
2968 +#define __ARCH_UBICOM32_POSIX_TYPES_H
2969 +
2970 +typedef unsigned long __kernel_dev_t;
2971 +typedef unsigned long __kernel_ino_t;
2972 +typedef unsigned short __kernel_mode_t;
2973 +typedef unsigned short __kernel_nlink_t;
2974 +typedef long __kernel_off_t;
2975 +typedef int __kernel_pid_t;
2976 +typedef unsigned short __kernel_ipc_pid_t;
2977 +typedef unsigned short __kernel_uid_t;
2978 +typedef unsigned short __kernel_gid_t;
2979 +typedef unsigned int __kernel_size_t;
2980 +typedef int __kernel_ssize_t;
2981 +typedef int __kernel_ptrdiff_t;
2982 +typedef long __kernel_time_t;
2983 +typedef long __kernel_suseconds_t;
2984 +typedef long __kernel_clock_t;
2985 +typedef int __kernel_daddr_t;
2986 +typedef char * __kernel_caddr_t;
2987 +typedef unsigned short __kernel_uid16_t;
2988 +typedef unsigned short __kernel_gid16_t;
2989 +typedef unsigned int __kernel_uid32_t;
2990 +typedef unsigned int __kernel_gid32_t;
2991 +typedef unsigned short __kernel_old_uid_t;
2992 +typedef unsigned short __kernel_old_gid_t;
2993 +typedef unsigned short __kernel_old_dev_t;
2994 +typedef long long __kernel_loff_t;
2995 +
2996 +typedef struct {
2997 +#ifdef __USE_ALL
2998 + int val[2];
2999 +#else
3000 + int __val[2];
3001 +#endif
3002 +} __kernel_fsid_t;
3003 +
3004 +#endif /* __ARCH_UBICOM32_POSIX_TYPES_H */
3005 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/mman.h
3006 ===================================================================
3007 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3008 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/mman.h 2010-01-14 11:05:01.000000000 +0100
3009 @@ -0,0 +1,102 @@
3010 +/* Definitions for POSIX memory map interface. Linux/m68k version.
3011 + Copyright (C) 1997, 2000, 2003, 2005 Free Software Foundation, Inc.
3012 + This file is part of the GNU C Library.
3013 +
3014 + The GNU C Library is free software; you can redistribute it and/or
3015 + modify it under the terms of the GNU Lesser General Public
3016 + License as published by the Free Software Foundation; either
3017 + version 2.1 of the License, or (at your option) any later version.
3018 +
3019 + The GNU C Library is distributed in the hope that it will be useful,
3020 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3021 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3022 + Lesser General Public License for more details.
3023 +
3024 + You should have received a copy of the GNU Lesser General Public
3025 + License along with the GNU C Library; if not, write to the Free
3026 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3027 + 02111-1307 USA. */
3028 +
3029 +#ifndef _SYS_MMAN_H
3030 +# error "Never use <bits/mman.h> directly; include <sys/mman.h> instead."
3031 +#endif
3032 +
3033 +/* The following definitions basically come from the kernel headers.
3034 + But the kernel header is not namespace clean. */
3035 +
3036 +
3037 +/* Protections are chosen from these bits, OR'd together. The
3038 + implementation does not necessarily support PROT_EXEC or PROT_WRITE
3039 + without PROT_READ. The only guarantees are that no writing will be
3040 + allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
3041 +
3042 +#define PROT_READ 0x1 /* Page can be read. */
3043 +#define PROT_WRITE 0x2 /* Page can be written. */
3044 +#define PROT_EXEC 0x4 /* Page can be executed. */
3045 +#define PROT_NONE 0x0 /* Page can not be accessed. */
3046 +#define PROT_GROWSDOWN 0x01000000 /* Extend change to start of
3047 + growsdown vma (mprotect only). */
3048 +#define PROT_GROWSUP 0x02000000 /* Extend change to start of
3049 + growsup vma (mprotect only). */
3050 +
3051 +/* Sharing types (must choose one and only one of these). */
3052 +#define MAP_SHARED 0x01 /* Share changes. */
3053 +#define MAP_PRIVATE 0x02 /* Changes are private. */
3054 +#ifdef __USE_MISC
3055 +# define MAP_TYPE 0x0f /* Mask for type of mapping. */
3056 +#endif
3057 +
3058 +/* Other flags. */
3059 +#define MAP_FIXED 0x10 /* Interpret addr exactly. */
3060 +#ifdef __USE_MISC
3061 +# define MAP_FILE 0
3062 +# define MAP_ANONYMOUS 0x20 /* Don't use a file. */
3063 +# define MAP_ANON MAP_ANONYMOUS
3064 +#endif
3065 +
3066 +/* These are Linux-specific. */
3067 +#ifdef __USE_MISC
3068 +# define MAP_GROWSDOWN 0x00100 /* Stack-like segment. */
3069 +# define MAP_DENYWRITE 0x00800 /* ETXTBSY */
3070 +# define MAP_EXECUTABLE 0x01000 /* Mark it as an executable. */
3071 +# define MAP_LOCKED 0x02000 /* Lock the mapping. */
3072 +# define MAP_NORESERVE 0x04000 /* Don't check for reservations. */
3073 +# define MAP_POPULATE 0x08000 /* Populate (prefault) pagetables. */
3074 +# define MAP_NONBLOCK 0x10000 /* Do not block on IO. */
3075 +#endif
3076 +
3077 +/* Flags to `msync'. */
3078 +#define MS_ASYNC 1 /* Sync memory asynchronously. */
3079 +#define MS_SYNC 4 /* Synchronous memory sync. */
3080 +#define MS_INVALIDATE 2 /* Invalidate the caches. */
3081 +
3082 +/* Flags for `mlockall'. */
3083 +#define MCL_CURRENT 1 /* Lock all currently mapped pages. */
3084 +#define MCL_FUTURE 2 /* Lock all additions to address
3085 + space. */
3086 +
3087 +/* Flags for `mremap'. */
3088 +#ifdef __USE_GNU
3089 +# define MREMAP_MAYMOVE 1
3090 +# define MREMAP_FIXED 2
3091 +#endif
3092 +
3093 +/* Advice to `madvise'. */
3094 +#ifdef __USE_BSD
3095 +# define MADV_NORMAL 0 /* No further special treatment. */
3096 +# define MADV_RANDOM 1 /* Expect random page references. */
3097 +# define MADV_SEQUENTIAL 2 /* Expect sequential page references. */
3098 +# define MADV_WILLNEED 3 /* Will need these pages. */
3099 +# define MADV_DONTNEED 4 /* Don't need these pages. */
3100 +# define MADV_DONTFORK 10 /* Do not inherit across fork. */
3101 +# define MADV_DOFORK 11 /* Do inherit across fork. */
3102 +#endif
3103 +
3104 +/* The POSIX people had to invent similar names for the same things. */
3105 +#ifdef __USE_XOPEN2K
3106 +# define POSIX_MADV_NORMAL 0 /* No further special treatment. */
3107 +# define POSIX_MADV_RANDOM 1 /* Expect random page references. */
3108 +# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references. */
3109 +# define POSIX_MADV_WILLNEED 3 /* Will need these pages. */
3110 +# define POSIX_MADV_DONTNEED 4 /* Don't need these pages. */
3111 +#endif
3112 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/setjmp.h
3113 ===================================================================
3114 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3115 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/setjmp.h 2010-01-14 11:05:01.000000000 +0100
3116 @@ -0,0 +1,52 @@
3117 +/* Define the machine-dependent type `jmp_buf'. Ubicom32 version.
3118 + Copyright (C) 1992,93,95,97,2000 Free Software Foundation, Inc.
3119 + This file is part of the GNU C Library.
3120 +
3121 + The GNU C Library is free software; you can redistribute it and/or
3122 + modify it under the terms of the GNU Lesser General Public
3123 + License as published by the Free Software Foundation; either
3124 + version 2.1 of the License, or (at your option) any later version.
3125 +
3126 + The GNU C Library is distributed in the hope that it will be useful,
3127 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3128 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3129 + Lesser General Public License for more details.
3130 +
3131 + You should have received a copy of the GNU Lesser General Public
3132 + License along with the GNU C Library; if not, write to the Free
3133 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3134 + 02111-1307 USA. */
3135 +
3136 +#ifndef _BITS_SETJMP_H
3137 +#define _BITS_SETJMP_H 1
3138 +
3139 +#if !defined _SETJMP_H && !defined _PTHREAD_H
3140 +# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
3141 +#endif
3142 +
3143 +#ifndef _ASM
3144 +/*
3145 + * This is the structure where we are going to save D10-D13, A0, A1, A2, A5, A6 and SP(A7).
3146 + * A5 is the return address. Call to setjmp will save these. Call to longjmp will return
3147 + * Control to the address in A5.
3148 + */
3149 +typedef struct setjmp_save_struct {
3150 + unsigned long d10; /* D10 */
3151 + unsigned long d11; /* D11 */
3152 + unsigned long d12; /* D12 */
3153 + unsigned long d13; /* D13 */
3154 + unsigned long a1; /* A1 */
3155 + unsigned long a2; /* A2 */
3156 + unsigned long a5; /* A5 return address. */
3157 + unsigned long a6; /* A6 */
3158 + unsigned long sp; /* A7 stack pointer. */
3159 +} __jmp_buf[1];
3160 +
3161 +#endif
3162 +
3163 +/* Test if longjmp to JMPBUF would unwind the frame
3164 + containing a local variable at ADDRESS. */
3165 +#define _JMPBUF_UNWINDS(jmpbuf, address) \
3166 + ((void *) (address) < (void*)(jmpbuf)->sp)
3167 +
3168 +#endif /* bits/setjmp.h */
3169 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/stackinfo.h
3170 ===================================================================
3171 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3172 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/stackinfo.h 2010-01-14 11:05:01.000000000 +0100
3173 @@ -0,0 +1,28 @@
3174 +/* Copyright (C) 1999 Free Software Foundation, Inc.
3175 + This file is part of the GNU C Library.
3176 +
3177 + The GNU C Library is free software; you can redistribute it and/or
3178 + modify it under the terms of the GNU Lesser General Public
3179 + License as published by the Free Software Foundation; either
3180 + version 2.1 of the License, or (at your option) any later version.
3181 +
3182 + The GNU C Library is distributed in the hope that it will be useful,
3183 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3184 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3185 + Lesser General Public License for more details.
3186 +
3187 + You should have received a copy of the GNU Lesser General Public
3188 + License along with the GNU C Library; if not, write to the Free
3189 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3190 + 02111-1307 USA. */
3191 +
3192 +/* This file contains a bit of information about the stack allocation
3193 + of the processor. */
3194 +
3195 +#ifndef _STACKINFO_H
3196 +#define _STACKINFO_H 1
3197 +
3198 +/* On Ubicom32 the stack grows down. */
3199 +#define _STACK_GROWS_DOWN 1
3200 +
3201 +#endif /* stackinfo.h */
3202 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/syscalls.h
3203 ===================================================================
3204 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3205 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/syscalls.h 2010-01-14 11:05:01.000000000 +0100
3206 @@ -0,0 +1,169 @@
3207 +#ifndef _BITS_SYSCALLS_H
3208 +#define _BITS_SYSCALLS_H
3209 +#ifndef _SYSCALL_H
3210 +# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
3211 +#endif
3212 +
3213 +/* m68k headers does stupid stuff with __NR_iopl / __NR_vm86:
3214 + * #define __NR_iopl not supported
3215 + * #define __NR_vm86 not supported
3216 + */
3217 +#undef __NR_iopl
3218 +#undef __NR_vm86
3219 +
3220 +#ifndef __ASSEMBLER__
3221 +
3222 +#include <errno.h>
3223 +
3224 +/* Linux takes system call arguments in registers:
3225 +
3226 + syscall number %d8
3227 + arg 1 %d0
3228 + arg 2 %d1
3229 + arg 3 %d2
3230 + arg 4 %d3
3231 + arg 5 %d4
3232 + arg 6 %d5
3233 +*/
3234 +
3235 +#define __syscall_return(type, res) \
3236 + do { \
3237 + if (likely((unsigned long)(res) < (unsigned long)(-125))) { \
3238 + return (type) (res); \
3239 + } else { \
3240 + /* avoid using res which is declared to be in register d0; \
3241 + errno might expand to a function call and clobber it. */ \
3242 + int __err = -(res); \
3243 + __set_errno(__err); \
3244 + return (type) -1; \
3245 + } \
3246 + } while (0)
3247 +
3248 +extern void __illegally_sized_syscall_arg1 (void);
3249 +extern void __illegally_sized_syscall_arg2 (void);
3250 +extern void __illegally_sized_syscall_arg3 (void);
3251 +extern void __illegally_sized_syscall_arg4 (void);
3252 +extern void __illegally_sized_syscall_arg5 (void);
3253 +extern void __illegally_sized_syscall_arg6 (void);
3254 +
3255 +#define __loadargs_0(name, dummy) \
3256 + d8 = name
3257 +
3258 +#define __loadargs_1(name, __arg1) \
3259 + __loadargs_0(name, 0); \
3260 + if (__builtin_classify_type (__arg1) != 5 && sizeof (__arg1) > 4) \
3261 + __illegally_sized_syscall_arg1 (); \
3262 + d0_retval = (long int) __arg1
3263 +#define __loadargs_2(name, __arg1, __arg2) \
3264 + __loadargs_1(name, __arg1); \
3265 + if (__builtin_classify_type (__arg2) != 5 && sizeof (__arg2) > 4) \
3266 + __illegally_sized_syscall_arg2 (); \
3267 + d1 = (long int) __arg2
3268 +
3269 +#define __loadargs_3(name, __arg1, __arg2, __arg3) \
3270 + __loadargs_2(name, __arg1, __arg2); \
3271 + if (__builtin_classify_type (__arg3) != 5 && sizeof (__arg3) > 4) \
3272 + __illegally_sized_syscall_arg3 (); \
3273 + d2 = (long int) __arg3
3274 +
3275 +#define __loadargs_4(name, __arg1, __arg2, __arg3, __arg4) \
3276 + __loadargs_3(name, __arg1, __arg2, __arg3); \
3277 + if (__builtin_classify_type (__arg4) != 5 && sizeof (__arg4) > 4) \
3278 + __illegally_sized_syscall_arg4 (); \
3279 + d3 = (long int)__arg4
3280 +
3281 +#define __loadargs_5(name, __arg1, __arg2, __arg3, __arg4, __arg5) \
3282 + __loadargs_4(name, __arg1, __arg2, __arg3, __arg4); \
3283 + if (__builtin_classify_type (__arg5) != 5 && sizeof (__arg5) > 4) \
3284 + __illegally_sized_syscall_arg5 (); \
3285 + d4 = (long int)__arg5
3286 +
3287 +#define __loadargs_6(name, __arg1, __arg2, __arg3, __arg4, __arg5, __arg6) \
3288 + __loadargs_5(name, __arg1, __arg2, __arg3, __arg4, __arg5); \
3289 + if (__builtin_classify_type (__arg6) != 5 && sizeof (__arg6) > 4) \
3290 + __illegally_sized_syscall_arg6 (); \
3291 + d5 = (long int)__arg6
3292 +
3293 +#define __internal_syscall_body(name, nr, args...) \
3294 + register long int d0_retval __asm__ ("d0"); \
3295 + register long int d1 __asm__ ("d1"); \
3296 + register long int d2 __asm__ ("d2"); \
3297 + register long int d3 __asm__ ("d3"); \
3298 + register long int d4 __asm__ ("d4"); \
3299 + register long int d5 __asm__ ("d5"); \
3300 + register long int d8 __asm__ ("d8"); \
3301 + __loadargs_##nr (__NR_##name, args); \
3302 + __asm__ __volatile__ ( \
3303 + " moveai a5, #%%hi(0x40400000)\n\t" \
3304 + " calli a5, 16(a5)\n\t" \
3305 + : "+r" (d0_retval), "+r" (d1), "+r" (d2), "+r" (d3), \
3306 + "+r" (d4), "+r" (d5), "+r" (d8) : \
3307 + : "cc", "memory", \
3308 + "acc0_lo", "acc0_hi", "acc1_lo", "acc1_hi", \
3309 + "source3", \
3310 + "a0", "a3", "a4", "a5", \
3311 + "d6", "d7", "d9", "d14", "d15" \
3312 + );
3313 +
3314 +#define INLINE_SYSCALL(name, nr, args...) \
3315 + ({ \
3316 + __internal_syscall_body(name, nr, args); \
3317 + if (unlikely((unsigned long)(d0_retval) >= (unsigned long)(-125))) { \
3318 + __set_errno (-d0_retval); \
3319 + d0_retval = -1L; \
3320 + } \
3321 + d0_retval; \
3322 + })
3323 +
3324 +
3325 +#undef _syscall0
3326 +#define _syscall0(type,name) \
3327 +type name(void){ \
3328 + __internal_syscall_body(name, 0); \
3329 + __syscall_return(type, d0_retval); \
3330 +}
3331 +
3332 +#undef _syscall1
3333 +#define _syscall1(type,name,type1,arg1) \
3334 +type name(type1 arg1){ \
3335 + __internal_syscall_body(name, 1, arg1); \
3336 + __syscall_return(type, d0_retval); \
3337 +}
3338 +
3339 +#undef _syscall2
3340 +#define _syscall2(type,name,type1,arg1,type2,arg2) \
3341 +type name(type1 arg1, type2 arg2){ \
3342 + __internal_syscall_body(name, 2, arg1, arg2); \
3343 + __syscall_return(type, d0_retval); \
3344 +}
3345 +
3346 +#undef _syscall3
3347 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
3348 +type name(type1 arg1, type2 arg2, type3 arg3){ \
3349 + __internal_syscall_body(name, 3, arg1, arg2, arg3); \
3350 + __syscall_return(type, d0_retval); \
3351 +}
3352 +
3353 +#undef _syscall4
3354 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
3355 +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4){ \
3356 + __internal_syscall_body(name, 4, arg1, arg2, arg3, arg4); \
3357 + __syscall_return(type, d0_retval); \
3358 +}
3359 +
3360 +#undef _syscall5
3361 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
3362 +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5){ \
3363 + __internal_syscall_body(name, 5, arg1, arg2, arg3, arg4, arg5); \
3364 + __syscall_return(type, d0_retval); \
3365 +}
3366 +
3367 +#undef _syscall6
3368 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
3369 +type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6){ \
3370 + __internal_syscall_body(name, 6, arg1, arg2, arg3, arg4, arg5, arg6); \
3371 + __syscall_return(type, d0_retval); \
3372 +}
3373 +
3374 +#endif /* __ASSEMBLER__ */
3375 +#endif /* _BITS_SYSCALLS_H */
3376 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/uClibc_arch_features.h
3377 ===================================================================
3378 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3379 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/uClibc_arch_features.h 2010-01-14 11:05:01.000000000 +0100
3380 @@ -0,0 +1,45 @@
3381 +/*
3382 + * Track misc arch-specific features that aren't config options
3383 + */
3384 +
3385 +#ifndef _BITS_UCLIBC_ARCH_FEATURES_H
3386 +#define _BITS_UCLIBC_ARCH_FEATURES_H
3387 +
3388 +/* instruction used when calling abort() to kill yourself */
3389 +/*#define __UCLIBC_ABORT_INSTRUCTION__ "asm instruction"*/
3390 +#undef __UCLIBC_ABORT_INSTRUCTION__
3391 +
3392 +/* can your target use syscall6() for mmap ? */
3393 +#undef __UCLIBC_MMAP_HAS_6_ARGS__
3394 +
3395 +/* does your target use syscall4() for truncate64 ? (32bit arches only) */
3396 +#undef __UCLIBC_TRUNCATE64_HAS_4_ARGS__
3397 +
3398 +/* does your target have a broken create_module() ? */
3399 +#undef __UCLIBC_BROKEN_CREATE_MODULE__
3400 +
3401 +/* does your target have to worry about older [gs]etrlimit() ? */
3402 +#undef __UCLIBC_HANDLE_OLDER_RLIMIT__
3403 +
3404 +/* does your target prefix all symbols with an _ ? */
3405 +#define __UCLIBC_NO_UNDERSCORES__
3406 +
3407 +/* does your target have an asm .set ? */
3408 +#define __UCLIBC_HAVE_ASM_SET_DIRECTIVE__
3409 +
3410 +/* define if target doesn't like .global */
3411 +#undef __UCLIBC_ASM_GLOBAL_DIRECTIVE__
3412 +
3413 +/* define if target supports .weak */
3414 +#define __UCLIBC_HAVE_ASM_WEAK_DIRECTIVE__
3415 +
3416 +/* define if target supports .weakext */
3417 +#undef __UCLIBC_HAVE_ASM_WEAKEXT_DIRECTIVE__
3418 +
3419 +/* needed probably only for ppc64 */
3420 +#undef __UCLIBC_HAVE_ASM_GLOBAL_DOT_NAME__
3421 +
3422 +/* define if target supports IEEE signed zero floats */
3423 +#define __UCLIBC_HAVE_SIGNED_ZERO__
3424 +
3425 +#endif /* _BITS_UCLIBC_ARCH_FEATURES_H */
3426 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/wordsize.h
3427 ===================================================================
3428 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3429 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/bits/wordsize.h 2010-01-14 11:05:01.000000000 +0100
3430 @@ -0,0 +1,19 @@
3431 +/* Copyright (C) 1999 Free Software Foundation, Inc.
3432 + This file is part of the GNU C Library.
3433 +
3434 + The GNU C Library is free software; you can redistribute it and/or
3435 + modify it under the terms of the GNU Lesser General Public
3436 + License as published by the Free Software Foundation; either
3437 + version 2.1 of the License, or (at your option) any later version.
3438 +
3439 + The GNU C Library is distributed in the hope that it will be useful,
3440 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3441 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3442 + Lesser General Public License for more details.
3443 +
3444 + You should have received a copy of the GNU Lesser General Public
3445 + License along with the GNU C Library; if not, write to the Free
3446 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3447 + 02111-1307 USA. */
3448 +
3449 +#define __WORDSIZE 32
3450 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/clone.S
3451 ===================================================================
3452 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3453 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/clone.S 2010-01-14 11:05:01.000000000 +0100
3454 @@ -0,0 +1,71 @@
3455 +#include <sys/syscall.h>
3456 +
3457 + .global __syscall_error
3458 +
3459 +/* int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
3460 + .text
3461 + .type clone,@function
3462 + .global clone
3463 +clone:
3464 + /* Sanity check arguments. */
3465 + sub.4 #0, #0, d0 /* Test if fn is zero. */
3466 + jmpeq.f 1f /* arg bad */
3467 + sub.4 #0, #0, d1 /* Test if child_stack is zero. */
3468 + jmpeq.f 1f /* arg bad */
3469 +
3470 + /* Set up child_stack frame.. arg and fn */
3471 + move.4 a3, d1
3472 + move.4 -4(a3)++, d3 /* push 'arg' to child stack */
3473 + move.4 -4(a3)++, d0 /* push fn to child stack, this will become a5
3474 + * on new child */
3475 + move.4 d1, a3
3476 + move.4 -4(sp)++, a5 /* push a5 to our stack */
3477 +
3478 + /*
3479 + * The syscall clone is clone(int flags, void *child_stack) so we set
3480 + * that up now
3481 + */
3482 + move.4 d0, d2 /* Move flags to d0 */
3483 +
3484 + /* Do Clone syscall */
3485 + movei d8, #__NR_clone
3486 + moveai a5, #%hi(0x40400000)
3487 + calli a5, 0x10(a5)
3488 + move.4 a5, (sp)4++ /* pop a5 from stack */
3489 +
3490 + /* Clone Complete */
3491 + cmpi d0, #0 /* Test if d0 is less than zero. If it is we
3492 + * return the error */
3493 + jmplt.f 2f /* If return is less than we had an error */
3494 + jmpeq.f 3f /* If return is 0 we are in the clone, jump to
3495 + * thread start */
3496 + ret a5 /* d0 is pid */
3497 +
3498 + /* Invalid Value */
3499 +1: movei d0, #-22 /* EINVAL */
3500 +
3501 + /* Call syscall Error */
3502 +2: sub.4 d0, #0, d0 /* d0 = -d0 */
3503 +#if defined(__UBICOM32_FDPIC__)
3504 + call a3, __syscall_error
3505 +#else
3506 + moveai a3, #%hi(__syscall_error)
3507 + calli a3, %lo(__syscall_error)(a3)
3508 +#endif
3509 + /* Child Thread Start */
3510 +3:
3511 +#if defined(__UBICOM32_FDPIC__)
3512 + /* a5 actually contains a function descriptor for fdpic */
3513 + move.4 a0, 4(a5) /* set GOT for this function */
3514 + move.4 a5, 0(a5) /* get address of entry point */
3515 +#endif
3516 + move.4 d0, (sp)4++ /* pop 'arg' to stack */
3517 + calli a5, 0(a5)
3518 + movei d8, #__NR_exit
3519 + moveai a3, #%hi(0x40400000)
3520 + calli a3, 0x10(a3)
3521 +
3522 + .size clone, . - clone
3523 + .global __GI_clone
3524 + .hidden __GI_clone
3525 + .set __GI_clone,clone
3526 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crt1.S
3527 ===================================================================
3528 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3529 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crt1.S 2010-01-14 11:05:01.000000000 +0100
3530 @@ -0,0 +1,179 @@
3531 +/* Startup code compliant to the ELF m68k ABI.
3532 + Copyright (C) 1996, 1997, 1998, 2001, 2002 Free Software Foundation, Inc.
3533 + This file is part of the GNU C Library.
3534 +
3535 + The GNU C Library is free software; you can redistribute it and/or
3536 + modify it under the terms of the GNU Lesser General Public
3537 + License as published by the Free Software Foundation; either
3538 + version 2.1 of the License, or (at your option) any later version.
3539 +
3540 + In addition to the permissions in the GNU Lesser General Public
3541 + License, the Free Software Foundation gives you unlimited
3542 + permission to link the compiled version of this file with other
3543 + programs, and to distribute those programs without any restriction
3544 + coming from the use of this file. (The GNU Lesser General Public
3545 + License restrictions do apply in other respects; for example, they
3546 + cover modification of the file, and distribution when not linked
3547 + into another program.)
3548 +
3549 + Note that people who make modified versions of this file are not
3550 + obligated to grant this special exception for their modified
3551 + versions; it is their choice whether to do so. The GNU Lesser
3552 + General Public License gives permission to release a modified
3553 + version without this exception; this exception also makes it
3554 + possible to release a modified version which carries forward this
3555 + exception.
3556 +
3557 + The GNU C Library is distributed in the hope that it will be useful,
3558 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3559 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3560 + Lesser General Public License for more details.
3561 +
3562 + You should have received a copy of the GNU Lesser General Public
3563 + License along with the GNU C Library; if not, write to the Free
3564 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
3565 + 02111-1307 USA. */
3566 +
3567 +#include <features.h>
3568 +
3569 +/* This is the canonical entry point, usually the first thing in the text
3570 + segment. The SVR4/m68k ABI says that when the entry point runs,
3571 + most registers' values are unspecified, except for:
3572 +
3573 + %a1 Contains a function pointer to be registered with `atexit'.
3574 + This is how the dynamic linker arranges to have DT_FINI
3575 + functions called for shared libraries that have been loaded
3576 + before this code runs.
3577 +
3578 + %sp The stack contains the arguments and environment:
3579 + 0(%sp) argc
3580 + 4(%sp) argv[0]
3581 + ...
3582 + (4*argc)(%sp) NULL
3583 + (4*(argc+1))(%sp) envp[0]
3584 + ...
3585 + NULL
3586 +
3587 + The uclinux conventions are different. %a1 is not defined on entry
3588 + and the stack is laid out as follows:
3589 +
3590 + 0(%sp) argc
3591 + 4(%sp) argv
3592 + 8(%sp) envp
3593 +*/
3594 +
3595 +
3596 + .text
3597 + .type main,@function
3598 + .type _init,%function
3599 + .type _fini,%function
3600 +#ifndef __UCLIBC_CTOR_DTOR__
3601 + .weak _init
3602 + .weak _fini
3603 +#endif
3604 + .globl _start
3605 + .global __uClibc_main;
3606 + .type __uClibc_main,@function;
3607 + .type _start,@function
3608 +_start:
3609 +
3610 +#if defined(__UBICOM32_FDPIC__) && !defined(L_Scrt1)
3611 + /* P0 contains a pointer to the program's load map. */
3612 + call a3, .Lcall;
3613 +.Lcall:
3614 + move.4 d0, d1 ; load exec_map_addr
3615 + moveai a4, #%hi(.Lcall)
3616 + lea.1 d15, %lo(.Lcall)(a4)
3617 + sub.4 d15, a3, d15 ; difference between .Lcall and actual address of .Lcall
3618 + moveai a3, #%hi(__ROFIXUP_LIST__)
3619 + lea.1 d1, %lo(__ROFIXUP_LIST__)(a3)
3620 + moveai a3, #%hi(__ROFIXUP_END__)
3621 + lea.1 d2, %lo(__ROFIXUP_END__)(a3)
3622 + add.4 d1, d1, d15
3623 + add.4 d2, d2, d15
3624 + call a5, __self_reloc ; returns GOT in d0
3625 + move.4 a0, d0 ; set GOT
3626 +#endif
3627 +
3628 +/*
3629 + all this is setup to make the following call.
3630 +
3631 + void __uClibc_main(
3632 + d0 - int (*main)(int, char **, char **),
3633 + d1 - int argc, (d1)
3634 + d2 - char **argv,
3635 + d3 - void (*app_init)(void),
3636 + d4 - void (*app_fini)(void),
3637 + d5 - void (*rtld_fini)(void),
3638 + d6 - void *stack_end
3639 + );
3640 + */
3641 +
3642 + /*
3643 + * Load pointer to main into d0
3644 + */
3645 +#ifdef __UBICOM32_FDPIC__
3646 + movei d0, #%got_funcdesc_lo(main)
3647 + move.4 d0, (a0, d0)
3648 +#else
3649 + moveai a3, #%hi(main)
3650 + lea.1 d0, %lo(main)(a3)
3651 +#endif
3652 +
3653 + /*
3654 + * Grab the environment stuff from stack and set up d1, d2 with it.
3655 + */
3656 + move.4 d1, (sp)
3657 +#ifdef __UBICOM32_FDPIC__
3658 + /* For FDPIC the calling convention is different than flat */
3659 + lea.1 d2, 4(sp)
3660 +#else
3661 + move.4 d2, 4(sp)
3662 +#endif
3663 +
3664 +#ifdef __UCLIBC_CTOR_DTOR__
3665 + /*
3666 + * Load pointer to _init into d3
3667 + */
3668 +#ifdef __UBICOM32_FDPIC__
3669 + movei d3, #%got_funcdesc_lo(_init)
3670 + move.4 d3, (a0, d3)
3671 +#else
3672 + moveai a3, #%hi(_init)
3673 + lea.1 d3, %lo(_init)(a3)
3674 +#endif
3675 +
3676 + /*
3677 + * Load pointer to _fini into d4
3678 + */
3679 +#ifdef __UBICOM32_FDPIC__
3680 + movei d4, #%got_funcdesc_lo(_fini)
3681 + move.4 d4, (a0, d4)
3682 +#else
3683 + moveai a3, #%hi(_fini)
3684 + lea.1 d4, %lo(_fini)(a3)
3685 +#endif
3686 +
3687 +#else /* !__UCLIBC_CTOR_DTOR__ */
3688 + move.4 d3, #0 ; _init
3689 + move.4 d4, #0 ; _fini
3690 +#endif
3691 +
3692 +#ifdef __UBICOM32_FDPIC__
3693 + move.4 d5, a1 ; ldso _fini funcdesc (see dl-startup.h)
3694 +#else
3695 + movei d5, #0 ; rtld_fini (not used)
3696 +#endif
3697 +
3698 + move.4 d6, sp ; Stack End.
3699 +
3700 + /* Call the user's main function, and exit with its value. But
3701 + let the libc call main. */
3702 +#ifdef __UBICOM32_FDPIC__
3703 + call a5, __uClibc_main
3704 +#else
3705 + moveai a5, #%hi(__uClibc_main)
3706 + calli a5, %lo(__uClibc_main)(a5)
3707 +#endif
3708 +
3709 + bkpt #-1 ; Crash if somehow `exit' does return.
3710 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crti.S
3711 ===================================================================
3712 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3713 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crti.S 2010-01-14 11:05:01.000000000 +0100
3714 @@ -0,0 +1,54 @@
3715 +/* Specialized code needed to support construction and destruction of
3716 + file-scope objects in C++ and Java code, and to support exception handling.
3717 + Copyright (C) 1999 Free Software Foundation, Inc.
3718 + Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
3719 +
3720 +This file is part of GCC.
3721 +
3722 +GCC is free software; you can redistribute it and/or modify
3723 +it under the terms of the GNU General Public License as published by
3724 +the Free Software Foundation; either version 2, or (at your option)
3725 +any later version.
3726 +
3727 +GCC is distributed in the hope that it will be useful,
3728 +but WITHOUT ANY WARRANTY; without even the implied warranty of
3729 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3730 +GNU General Public License for more details.
3731 +
3732 +You should have received a copy of the GNU General Public License
3733 +along with GCC; see the file COPYING. If not, write to
3734 +the Free Software Foundation, 59 Temple Place - Suite 330,
3735 +Boston, MA 02111-1307, USA. */
3736 +
3737 +/* As a special exception, if you link this library with files
3738 + compiled with GCC to produce an executable, this does not cause
3739 + the resulting executable to be covered by the GNU General Public License.
3740 + This exception does not however invalidate any other reasons why
3741 + the executable file might be covered by the GNU General Public License. */
3742 +
3743 +/*
3744 + * This file just supplies function prologues for the .init and .fini
3745 + * sections. It is linked in before crtbegin.o.
3746 + */
3747 + .file "crti.o"
3748 + .ident "GNU C crti.o"
3749 +
3750 + .section .init
3751 + .align 2
3752 + .globl _init
3753 + .type _init, @function
3754 +_init:
3755 + move.4 -4(sp)++, a5
3756 +#ifdef __UBICOM32_FDPIC__
3757 + move.4 -4(sp)++, a0
3758 +#endif
3759 +
3760 + .section .fini
3761 + .align 2
3762 + .globl _fini
3763 + .type _fini, @function
3764 +_fini:
3765 + move.4 -4(sp)++, a5
3766 +#ifdef __UBICOM32_FDPIC__
3767 + move.4 -4(sp)++, a0
3768 +#endif
3769 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtn.S
3770 ===================================================================
3771 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3772 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtn.S 2010-01-14 11:05:01.000000000 +0100
3773 @@ -0,0 +1,47 @@
3774 +/* Specialized code needed to support construction and destruction of
3775 + file-scope objects in C++ and Java code, and to support exception handling.
3776 + Copyright (C) 1999 Free Software Foundation, Inc.
3777 + Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
3778 +
3779 +This file is part of GCC.
3780 +
3781 +GCC is free software; you can redistribute it and/or modify
3782 +it under the terms of the GNU General Public License as published by
3783 +the Free Software Foundation; either version 2, or (at your option)
3784 +any later version.
3785 +
3786 +GCC is distributed in the hope that it will be useful,
3787 +but WITHOUT ANY WARRANTY; without even the implied warranty of
3788 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3789 +GNU General Public License for more details.
3790 +
3791 +You should have received a copy of the GNU General Public License
3792 +along with GCC; see the file COPYING. If not, write to
3793 +the Free Software Foundation, 59 Temple Place - Suite 330,
3794 +Boston, MA 02111-1307, USA. */
3795 +
3796 +/* As a special exception, if you link this library with files
3797 + compiled with GCC to produce an executable, this does not cause
3798 + the resulting executable to be covered by the GNU General Public License.
3799 + This exception does not however invalidate any other reasons why
3800 + the executable file might be covered by the GNU General Public License. */
3801 +
3802 +/*
3803 + * This file supplies function epilogues for the .init and .fini sections.
3804 + * It is linked in after all other files.
3805 + */
3806 +
3807 + .file "crtn.o"
3808 + .ident "GNU C crtn.o"
3809 +
3810 + .section .init
3811 +#ifdef __UBICOM32_FDPIC__
3812 + move.4 a0, (sp)4++
3813 +#endif
3814 + ret (sp)4++
3815 +
3816 + .section .fini
3817 +#ifdef __UBICOM32_FDPIC__
3818 + move.4 a0, (sp)4++
3819 +#endif
3820 + ret (sp)4++
3821 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtreloc.c
3822 ===================================================================
3823 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3824 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/crtreloc.c 2010-01-14 11:05:01.000000000 +0100
3825 @@ -0,0 +1,145 @@
3826 +/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
3827 + written by Alexandre Oliva <aoliva@redhat.com>
3828 +This file is part of the GNU C Library.
3829 +
3830 +The GNU C Library is free software; you can redistribute it and/or
3831 +modify it under the terms of the GNU Lesser General Public License as
3832 +published by the Free Software Foundation; either version 2.1 of the
3833 +License, or (at your option) any later version.
3834 +
3835 +In addition to the permissions in the GNU Lesser General Public
3836 +License, the Free Software Foundation gives you unlimited
3837 +permission to link the compiled version of this file with other
3838 +programs, and to distribute those programs without any restriction
3839 +coming from the use of this file. (The GNU Lesser General Public
3840 +License restrictions do apply in other respects; for example, they
3841 +cover modification of the file, and distribution when not linked
3842 +into another program.)
3843 +
3844 +The GNU C Library is distributed in the hope that it will be useful,
3845 +but WITHOUT ANY WARRANTY; without even the implied warranty of
3846 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3847 +Library General Public License for more details.
3848 +
3849 +You should have received a copy of the GNU Lesser General Public
3850 +License along with the GNU C Library; see the file COPYING.LIB. If
3851 +not, write to the Free Software Foundation, Inc., 675 Mass Ave,
3852 +Cambridge, MA 02139, USA. */
3853 +
3854 +#ifdef __UBICOM32_FDPIC__
3855 +
3856 +#include <sys/types.h>
3857 +#include <link.h>
3858 +
3859 +/* This file is to be compiled into crt object files, to enable
3860 + executables to easily self-relocate. */
3861 +
3862 +union word {
3863 + char c[4];
3864 + void *v;
3865 +};
3866 +
3867 +/* Compute the runtime address of pointer in the range [p,e), and then
3868 + map the pointer pointed by it. */
3869 +static __always_inline void ***
3870 +reloc_range_indirect (void ***p, void ***e,
3871 + const struct elf32_fdpic_loadmap *map)
3872 +{
3873 + while (p < e)
3874 + {
3875 + if (*p != (void **)-1)
3876 + {
3877 + void *ptr = __reloc_pointer (*p, map);
3878 + if (ptr != (void *)-1)
3879 + {
3880 + void *pt;
3881 + if ((long)ptr & 3)
3882 + {
3883 + unsigned char *c = ptr;
3884 + int i;
3885 + unsigned long v = 0;
3886 + for (i = 0; i < 4; i++)
3887 + v |= c[i] << 8 * i;
3888 + pt = (void *)v;
3889 + }
3890 + else
3891 + pt = *(void**)ptr;
3892 + pt = __reloc_pointer (pt, map);
3893 + if ((long)ptr & 3)
3894 + {
3895 + unsigned char *c = ptr;
3896 + int i;
3897 + unsigned long v = (unsigned long)pt;
3898 + for (i = 0; i < 4; i++, v >>= 8)
3899 + c[i] = v;
3900 + }
3901 + else
3902 + *(void**)ptr = pt;
3903 + }
3904 + }
3905 + p++;
3906 + }
3907 + return p;
3908 +}
3909 +
3910 +/* Call __reloc_range_indirect for the given range except for the last
3911 + entry, whose contents are only relocated. It's expected to hold
3912 + the GOT value. */
3913 +void* attribute_hidden
3914 +__self_reloc (const struct elf32_fdpic_loadmap *map,
3915 + void ***p, void ***e)
3916 +{
3917 + p = reloc_range_indirect (p, e-1, map);
3918 +
3919 + if (p >= e)
3920 + return (void*)-1;
3921 +
3922 + return __reloc_pointer (*p, map);
3923 +}
3924 +
3925 +#if 0
3926 +/* These are other functions that might be useful, but that we don't
3927 + need. */
3928 +
3929 +/* Remap pointers in [p,e). */
3930 +static __always_inline void**
3931 +reloc_range (void **p, void **e,
3932 + const struct elf32_fdpic_loadmap *map)
3933 +{
3934 + while (p < e)
3935 + {
3936 + *p = __reloc_pointer (*p, map);
3937 + p++;
3938 + }
3939 + return p;
3940 +}
3941 +
3942 +/* Remap p, adjust e by the same offset, then map the pointers in the
3943 + range determined by them. */
3944 +void attribute_hidden
3945 +__reloc_range (const struct elf32_fdpic_loadmap *map,
3946 + void **p, void **e)
3947 +{
3948 + void **old = p;
3949 +
3950 + p = __reloc_pointer (p, map);
3951 + e += p - old;
3952 + reloc_range (p, e, map);
3953 +}
3954 +
3955 +/* Remap p, adjust e by the same offset, then map pointers referenced
3956 + by the (unadjusted) pointers in the range. Return the relocated
3957 + value of the last pointer in the range. */
3958 +void* attribute_hidden
3959 +__reloc_range_indirect (const struct elf32_fdpic_loadmap *map,
3960 + void ***p, void ***e)
3961 +{
3962 + void ***old = p;
3963 +
3964 + p = __reloc_pointer (p, map);
3965 + e += p - old;
3966 + return reloc_range_indirect (p, e, map);
3967 +}
3968 +#endif
3969 +
3970 +#endif /* __UBICOM32_FDPIC__ */
3971 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/setjmp.S
3972 ===================================================================
3973 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
3974 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/setjmp.S 2010-01-14 11:05:01.000000000 +0100
3975 @@ -0,0 +1,72 @@
3976 +/* Setjmp for Ubicom32 */
3977 + .text
3978 + .global _setjmp
3979 + .type _setjmp,@function
3980 +_setjmp:
3981 + movea a3, d0 ; A3 now holds the jmp buf that was passed in.
3982 + move.4 (a3)4++, d10
3983 + move.4 (a3)4++, d11
3984 + move.4 (a3)4++, d12
3985 + move.4 (a3)4++, d13
3986 + move.4 (a3)4++, a1
3987 + move.4 (a3)4++, a2
3988 + move.4 (a3)4++, a5
3989 + move.4 (a3)4++, a6
3990 + move.4 (a3)4++, a7
3991 + move.4 d0, #0
3992 +
3993 + calli a5, 0(a5)
3994 + .size _setjmp, . - _setjmp
3995 +
3996 +/*
3997 + * __sigsetjmp for Ubicom32
3998 + * d0 holds sigjmp_buf and d1 holds the savemask. We will save the frame and then just call __sigjmp_save to do the mask save.
3999 + */
4000 + .global __sigsetjmp
4001 + .type __sigsetjmp,@function
4002 +__sigsetjmp:
4003 + movea a3, d0 ; A3 now holds the jmp buf that was passed in.
4004 + move.4 (a3)4++, d10
4005 + move.4 (a3)4++, d11
4006 + move.4 (a3)4++, d12
4007 + move.4 (a3)4++, d13
4008 + move.4 (a3)4++, a1
4009 + move.4 (a3)4++, a2
4010 + move.4 (a3)4++, a5
4011 + move.4 (a3)4++, a6
4012 + move.4 (a3)4++, a7
4013 +
4014 + ;; The frame has been saved. Call _sigjmp_save to get sigmask saved. a5 still has the return address and it will go back to that.
4015 +#if defined(__UBICOM32_FDPIC__)
4016 + call a3, __sigjmp_save
4017 +#else
4018 + moveai a3, #%hi(__sigjmp_save)
4019 + calli a3, %lo(__sigjmp_save)(a3)
4020 +#endif
4021 + .size __sigjmp_save, . - __sigjmp_save
4022 +
4023 + .global __longjmp
4024 + .type __longjmp,@function
4025 +__longjmp:
4026 + movea a3, d0 ; A3 now holds the jmp buf that was passed in.
4027 + move.4 d10, (a3)4++
4028 + move.4 d11, (a3)4++
4029 + move.4 d12, (a3)4++
4030 + move.4 d13, (a3)4++
4031 + move.4 a1 , (a3)4++
4032 + move.4 a2 , (a3)4++
4033 + move.4 a5 , (a3)4++
4034 + move.4 a6 , (a3)4++
4035 + move.4 a7 , (a3)4++
4036 +
4037 + sub.4 #0, #0, d1 ; Test if d1 is zero. If it is we have to return 1 other wise return content of d1
4038 + jmpeq.t 2f
4039 + move.4 d0, d1 ; d1 is non zero load it into d0
4040 + jmpt.t 3f
4041 +
4042 +2: move.4 d0, #1
4043 +3: calli a5, 0(a5)
4044 + .size __longjmp, . - __longjmp
4045 + .global __GI___longjmp
4046 + .hidden __GI___longjmp
4047 + .set __GI___longjmp,__longjmp
4048 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/procfs.h
4049 ===================================================================
4050 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4051 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/procfs.h 2010-01-14 11:05:01.000000000 +0100
4052 @@ -0,0 +1,122 @@
4053 +/* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
4054 + This file is part of the GNU C Library.
4055 +
4056 + The GNU C Library is free software; you can redistribute it and/or
4057 + modify it under the terms of the GNU Lesser General Public
4058 + License as published by the Free Software Foundation; either
4059 + version 2.1 of the License, or (at your option) any later version.
4060 +
4061 + The GNU C Library is distributed in the hope that it will be useful,
4062 + but WITHOUT ANY WARRANTY; without even the implied warranty of
4063 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4064 + Lesser General Public License for more details.
4065 +
4066 + You should have received a copy of the GNU Lesser General Public
4067 + License along with the GNU C Library; if not, write to the Free
4068 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4069 + 02111-1307 USA. */
4070 +
4071 +#ifndef _SYS_PROCFS_H
4072 +#define _SYS_PROCFS_H 1
4073 +
4074 +/* This is somehow modelled after the file of the same name on SysVr4
4075 + systems. It provides a definition of the core file format for ELF
4076 + used on Linux. */
4077 +
4078 +#include <features.h>
4079 +#include <signal.h>
4080 +#include <sys/time.h>
4081 +#include <sys/types.h>
4082 +#include <sys/ucontext.h>
4083 +#include <bits/wordsize.h>
4084 +
4085 +__BEGIN_DECLS
4086 +
4087 +#define ELF_NGREG 38
4088 +
4089 +typedef struct
4090 + {
4091 + union
4092 + {
4093 + unsigned long pr_regs[32];
4094 + double pr_dregs[16];
4095 + } pr_fr;
4096 + unsigned long __unused;
4097 + unsigned long pr_fsr;
4098 + unsigned char pr_qcnt;
4099 + unsigned char pr_q_entrysize;
4100 + unsigned char pr_en;
4101 + unsigned int pr_q[64];
4102 + } elf_fpregset_t;
4103 +
4104 +typedef unsigned long elf_greg_t;
4105 +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
4106 +
4107 +struct elf_siginfo
4108 + {
4109 + int si_signo; /* Signal number. */
4110 + int si_code; /* Extra code. */
4111 + int si_errno; /* Errno. */
4112 + };
4113 +
4114 +/* Definitions to generate Intel SVR4-like core files. These mostly
4115 + have the same names as the SVR4 types with "elf_" tacked on the
4116 + front to prevent clashes with linux definitions, and the typedef
4117 + forms have been avoided. This is mostly like the SVR4 structure,
4118 + but more Linuxy, with things that Linux does not support and which
4119 + gdb doesn't really use excluded. Fields present but not used are
4120 + marked with "XXX". */
4121 +struct elf_prstatus
4122 + {
4123 + struct elf_siginfo pr_info; /* Info associated with signal. */
4124 + short int pr_cursig; /* Current signal. */
4125 + unsigned long int pr_sigpend; /* Set of pending signals. */
4126 + unsigned long int pr_sighold; /* Set of held signals. */
4127 + __pid_t pr_pid;
4128 + __pid_t pr_ppid;
4129 + __pid_t pr_pgrp;
4130 + __pid_t pr_sid;
4131 + struct timeval pr_utime; /* User time. */
4132 + struct timeval pr_stime; /* System time. */
4133 + struct timeval pr_cutime; /* Cumulative user time. */
4134 + struct timeval pr_cstime; /* Cumulative system time. */
4135 + elf_gregset_t pr_reg; /* GP registers. */
4136 + int pr_fpvalid; /* True if math copro being used. */
4137 + };
4138 +
4139 +
4140 +#define ELF_PRARGSZ (80) /* Number of chars for args */
4141 +
4142 +struct elf_prpsinfo
4143 + {
4144 + char pr_state; /* Numeric process state. */
4145 + char pr_sname; /* Char for pr_state. */
4146 + char pr_zomb; /* Zombie. */
4147 + char pr_nice; /* Nice val. */
4148 + unsigned long int pr_flag; /* Flags. */
4149 + unsigned short int pr_uid;
4150 + unsigned short int pr_gid;
4151 + int pr_pid, pr_ppid, pr_pgrp, pr_sid;
4152 + /* Lots missing */
4153 + char pr_fname[16]; /* Filename of executable. */
4154 + char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
4155 + };
4156 +
4157 +/* Addresses. */
4158 +typedef void *psaddr_t;
4159 +
4160 +/* Register sets. Linux has different names. */
4161 +typedef elf_gregset_t prgregset_t;
4162 +typedef elf_fpregset_t prfpregset_t;
4163 +
4164 +/* We don't have any differences between processes and threads,
4165 + therefore have only one PID type. */
4166 +typedef __pid_t lwpid_t;
4167 +
4168 +
4169 +typedef struct elf_prstatus prstatus_t;
4170 +typedef struct elf_prpsinfo prpsinfo_t;
4171 +
4172 +__END_DECLS
4173 +
4174 +#endif /* sys/procfs.h */
4175 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/ucontext.h
4176 ===================================================================
4177 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4178 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/sys/ucontext.h 2010-01-14 11:05:01.000000000 +0100
4179 @@ -0,0 +1,104 @@
4180 +/* Copyright (C) 1998, 1999 Free Software Foundation, Inc.
4181 + This file is part of the GNU C Library.
4182 +
4183 + The GNU C Library is free software; you can redistribute it and/or
4184 + modify it under the terms of the GNU Lesser General Public
4185 + License as published by the Free Software Foundation; either
4186 + version 2.1 of the License, or (at your option) any later version.
4187 +
4188 + The GNU C Library is distributed in the hope that it will be useful,
4189 + but WITHOUT ANY WARRANTY; without even the implied warranty of
4190 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4191 + Lesser General Public License for more details.
4192 +
4193 + You should have received a copy of the GNU Lesser General Public
4194 + License along with the GNU C Library; if not, write to the Free
4195 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4196 + 02111-1307 USA. */
4197 +
4198 +#ifndef _SYS_UCONTEXT_H
4199 +#define _SYS_UCONTEXT_H 1
4200 +
4201 +#include <features.h>
4202 +#include <signal.h>
4203 +/*
4204 + * Location of the users' stored registers relative to R0.
4205 + * Usage is as an index into a gregset_t array or as u.u_ar0[XX].
4206 + */
4207 +#define REG_PSR (0)
4208 +#define REG_PC (1)
4209 +#define REG_SPARE (2)
4210 +#define REG_WVALID (3)
4211 +#define REG_G1 (4)
4212 +#define REG_G2 (5)
4213 +#define REG_G3 (6)
4214 +#define REG_G4 (7)
4215 +#define REG_G5 (8)
4216 +#define REG_G6 (9)
4217 +#define REG_G7 (10)
4218 +#define REG_O0 (11)
4219 +#define REG_O1 (12)
4220 +#define REG_O2 (13)
4221 +#define REG_O3 (14)
4222 +#define REG_O4 (15)
4223 +#define REG_O5 (16)
4224 +#define REG_O6 (17)
4225 +#define REG_O7 (18)
4226 +#define REG_GLOBALS (19)
4227 +
4228 +/*
4229 + * A gregset_t is defined as an array type for compatibility with the reference
4230 + * source. This is important due to differences in the way the C language
4231 + * treats arrays and structures as parameters.
4232 + *
4233 + * Note that NGREG is really (sizeof (struct regs) / sizeof (greg_t)),
4234 + * but that the ABI defines it absolutely to be 21 (resp. 19).
4235 + */
4236 +
4237 +#define NGREG 20
4238 +typedef int greg_t;
4239 +
4240 +typedef greg_t gregset_t[NGREG];
4241 +
4242 +/*
4243 + * The following structures define how a register window can appear on the
4244 + * stack. This structure is available (when required) through the `gwins'
4245 + * field of an mcontext (nested within ucontext). NIOS_MAXWINDOW is the
4246 + * maximum number of outstanding register windows defined in the NIOS
4247 + * architecture (*not* implementation).
4248 + */
4249 +#define NIOS_MAXREGWINDOW 31 /* max windows in NIOS arch. */
4250 +struct rwindow
4251 + {
4252 + greg_t rw_local[8]; /* locals */
4253 + greg_t rw_in[8]; /* ins */
4254 + };
4255 +
4256 +#define rw_fp rw_in[6] /* frame pointer */
4257 +#define rw_rtn rw_in[7] /* return address */
4258 +
4259 +typedef struct gwindows
4260 + {
4261 + int wbcnt;
4262 + int *spbuf[NIOS_MAXREGWINDOW];
4263 + struct rwindow wbuf[NIOS_MAXREGWINDOW];
4264 + } gwindows_t;
4265 +
4266 +typedef struct
4267 + {
4268 + gregset_t gregs; /* general register set */
4269 + gwindows_t *gwins; /* POSSIBLE pointer to register windows */
4270 + } mcontext_t;
4271 +
4272 +
4273 +/* Userlevel context. */
4274 +typedef struct ucontext
4275 + {
4276 + unsigned long uc_flags;
4277 + struct ucontext *uc_link;
4278 + __sigset_t uc_sigmask;
4279 + stack_t uc_stack;
4280 + mcontext_t uc_mcontext;
4281 + } ucontext_t;
4282 +
4283 +#endif /* sys/ucontext.h */
4284 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/syscall.c
4285 ===================================================================
4286 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4287 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/syscall.c 2010-01-14 11:05:01.000000000 +0100
4288 @@ -0,0 +1,32 @@
4289 +/* vi: set sw=4 ts=4: */
4290 +/* syscall for ubicom32/uClibc
4291 + *
4292 + * Copyright (C) 2008 by Ubicom Inc.
4293 + * Copyright (C) 2002 by Erik Andersen <andersen@uclibc.org>
4294 + *
4295 + * This program is free software; you can redistribute it and/or modify it
4296 + * under the terms of the GNU Library General Public License as published by
4297 + * the Free Software Foundation; either version 2 of the License, or (at your
4298 + * option) any later version.
4299 + *
4300 + * This program is distributed in the hope that it will be useful, but WITHOUT
4301 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4302 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
4303 + * for more details.
4304 + *
4305 + * You should have received a copy of the GNU Library General Public License
4306 + * along with this program; if not, write to the Free Software Foundation,
4307 + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4308 + */
4309 +
4310 +#include <features.h>
4311 +#include <errno.h>
4312 +#include <sys/types.h>
4313 +#include <sys/syscall.h>
4314 +
4315 +extern long syscall(long sysnum, long a, long b, long c, long d, long e, long f);
4316 +long syscall(long sysnum, long a, long b, long c, long d, long e, long f)
4317 +{
4318 + int __NR_syscall_number = sysnum;
4319 + return (long) INLINE_SYSCALL(syscall_number, 6, a, b, c, d, e, f);
4320 +}
4321 Index: uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/vfork.S
4322 ===================================================================
4323 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4324 +++ uClibc-0.9.30.2/libc/sysdeps/linux/ubicom32/vfork.S 2010-01-14 11:05:01.000000000 +0100
4325 @@ -0,0 +1,35 @@
4326 +#include <sys/syscall.h>
4327 +
4328 + .text
4329 + .type vfork,@function
4330 + .global vfork
4331 +vfork:
4332 + move.4 -4(sp)++, a5 ; Save return address on the stack.
4333 + movei d8, #__NR_vfork
4334 + moveai a3, #%hi(0x40400000)
4335 + calli a5, 0x10(a3)
4336 +
4337 + /*
4338 + * You get here only if the syscall bombed. If things had worked out the
4339 + * parent and child would have both returned to the instruction after
4340 + * the vfork call.
4341 + */
4342 + move.4 a5, (sp)4++ ; Pop the return address off the stack.
4343 + movei d1, #-125
4344 + sub.4 #0, d0, d1
4345 + jmplt.t 1f
4346 +
4347 + ;; We have an error.
4348 + sub.4 d0, #0, d0 ; d0 = -res. Call __set_errno with that.
4349 +#if defined(__UBICOM32_FDPIC__)
4350 + call a3, __syscall_error
4351 +#else
4352 + moveai a3, #%hi(__syscall_error)
4353 + calli a3, %lo(__syscall_error)(a3) ; __syscall_error will return -1 and not come back here.
4354 +#endif
4355 +1:
4356 + calli a5, 0(a5)
4357 + .size vfork, . - vfork
4358 + .global __GI_vfork
4359 + .hidden __GI_vfork
4360 + .set __GI_vfork,vfork
4361 Index: uClibc-0.9.30.2/libpthread/linuxthreads.old/pthread.c
4362 ===================================================================
4363 --- uClibc-0.9.30.2.orig/libpthread/linuxthreads.old/pthread.c 2010-01-13 22:22:31.000000000 +0100
4364 +++ uClibc-0.9.30.2/libpthread/linuxthreads.old/pthread.c 2010-01-14 11:05:01.000000000 +0100
4365 @@ -393,6 +393,10 @@
4366 #endif
4367
4368 __libc_multiple_threads_ptr = __libc_pthread_init (ptr_pthread_functions);
4369 +#ifndef __ARCH_USE_MMU__
4370 + __pthread_initial_thread_tos =
4371 + (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1));
4372 +#endif /* __ARCH_USE_MMU__ */
4373 }
4374
4375
4376 @@ -461,8 +465,11 @@
4377 * __pthread_initial_thread_bos at address 0. These bounds are refined as we
4378 * malloc other stack frames such that they don't overlap. -StS
4379 */
4380 - __pthread_initial_thread_tos =
4381 - (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1));
4382 + if (__pthread_initial_thread_tos == NULL) {
4383 + __pthread_initial_thread_tos =
4384 + (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1));
4385 + }
4386 +
4387 __pthread_initial_thread_bos = (char *) 1; /* set it non-zero so we know we have been here */
4388 PDEBUG("initial thread stack bounds: bos=%p, tos=%p\n",
4389 __pthread_initial_thread_bos, __pthread_initial_thread_tos);
4390 Index: uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/pt-machine.h
4391 ===================================================================
4392 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4393 +++ uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/pt-machine.h 2010-01-14 11:05:01.000000000 +0100
4394 @@ -0,0 +1,68 @@
4395 +/* Machine-dependent pthreads configuration and inline functions.
4396 +
4397 + Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004
4398 + Free Software Foundation, Inc.
4399 + This file is part of the GNU C Library.
4400 + Contributed by Ralf Baechle <ralf@gnu.org>.
4401 + Based on the Alpha version by Richard Henderson <rth@tamu.edu>.
4402 +
4403 + The GNU C Library is free software; you can redistribute it and/or
4404 + modify it under the terms of the GNU Lesser General Public License as
4405 + published by the Free Software Foundation; either version 2.1 of the
4406 + License, or (at your option) any later version.
4407 +
4408 + The GNU C Library is distributed in the hope that it will be useful,
4409 + but WITHOUT ANY WARRANTY; without even the implied warranty of
4410 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4411 + Lesser General Public License for more details.
4412 +
4413 + You should have received a copy of the GNU Lesser General Public
4414 + License along with the GNU C Library; see the file COPYING.LIB. If
4415 + not, write to the Free Software Foundation, Inc.,
4416 + 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
4417 +
4418 +#ifndef _PT_MACHINE_H
4419 +#define _PT_MACHINE_H 1
4420 +
4421 +#include <features.h>
4422 +
4423 +/*
4424 + * XXX try to make this inline
4425 + */
4426 +extern long int testandset (int *spinlock);
4427 +
4428 +#ifndef PT_EI
4429 +#define PT_EI
4430 +#else
4431 +/* Spinlock implementation; required. */
4432 +
4433 +/*
4434 + * testandset() is the basis for the pthread spin lock.
4435 + *
4436 + * This implementation only requires that we 'set' the state of *spinlock. As
4437 + * bset is allows us to atomically 'testandset' a single bit define our 'set' is
4438 + * such that we will set bit 0 (ignoring all other bits, which should also be
4439 + * zero).
4440 + * Return value of 1 implies that the bit was already set and is still
4441 + * set.
4442 + * Return value of 0 implies that the bit was not previously set but it
4443 + * now is.
4444 + */
4445 +long int
4446 +testandset (int *spinlock)
4447 +{
4448 + int ret;
4449 + __asm__ volatile (
4450 + " move.4 %0, #0 \n\t" /* Assume that the bit is not currently set */
4451 + " bset %1, %1, #0 \n\t" /* Attempt to 'set' bit 0 */
4452 + " jmpeq.t 1f \n\t"
4453 + " move.4 %0, #1 \n\t" /* Bit was already set, so return 1 */
4454 + " 1: \n\t"
4455 + : "=r"(ret), "+U4"(*spinlock)
4456 + :
4457 + : "memory", "cc"
4458 + );
4459 + return ret;
4460 +}
4461 +#endif
4462 +#endif /* pt-machine.h */
4463 Index: uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/tls.h
4464 ===================================================================
4465 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
4466 +++ uClibc-0.9.30.2/libpthread/linuxthreads.old/sysdeps/ubicom32/tls.h 2010-01-14 11:05:01.000000000 +0100
4467 @@ -0,0 +1,26 @@
4468 +/* Definitions for thread-local data handling. linuxthreads/MIPS version.
4469 + Copyright (C) 2005 Free Software Foundation, Inc.
4470 + This file is part of the GNU C Library.
4471 +
4472 + The GNU C Library is free software; you can redistribute it and/or
4473 + modify it under the terms of the GNU Lesser General Public
4474 + License as published by the Free Software Foundation; either
4475 + version 2.1 of the License, or (at your option) any later version.
4476 +
4477 + The GNU C Library is distributed in the hope that it will be useful,
4478 + but WITHOUT ANY WARRANTY; without even the implied warranty of
4479 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4480 + Lesser General Public License for more details.
4481 +
4482 + You should have received a copy of the GNU Lesser General Public
4483 + License along with the GNU C Library; if not, write to the Free
4484 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4485 + 02111-1307 USA. */
4486 +
4487 +#ifndef _TLS_H
4488 +#define _TLS_H
4489 +#ifdef HAVE_TLS_SUPPORT
4490 +#warning no tls support
4491 +#undef USE_TLS
4492 +#endif
4493 +#endif /* tls.h */
This page took 0.224985 seconds and 5 git commands to generate.