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