busybox: additional 1.13.2 fixes
[avatt.git] / toolchain / uClibc / uClibc-0.9.28.3-arch.patch.avr32
blob2e0f541a8eb9908389b472f3392a1e5e458e501d
1 diff -Nrup a/extra/Configs/Config.avr32 b/extra/Configs/Config.avr32
2 --- a/extra/Configs/Config.avr32        1969-12-31 19:00:00.000000000 -0500
3 +++ b/extra/Configs/Config.avr32        2008-02-28 19:02:10.000000000 -0500
4 @@ -0,0 +1,42 @@
5 +#
6 +# For a description of the syntax of this configuration file,
7 +# see extra/config/Kconfig-language.txt
8 +#
10 +config HAVE_ELF
11 +       bool
12 +       default y
14 +config TARGET_ARCH
15 +       default "avr32"
17 +config ARCH_CFLAGS
18 +       string
20 +config ARCH_LDFLAGS
21 +       string
23 +config LIBGCC_CFLAGS
24 +       string
26 +config ARCH_SUPPORTS_BIG_ENDIAN
27 +       bool
28 +       default y
30 +config UCLIBC_COMPLETELY_PIC
31 +       select FORCE_SHAREABLE_TEXT_SEGMENTS
32 +       bool
33 +       default y
35 +choice
36 +       prompt "Target CPU Type"
37 +       default CONFIG_AP7000
39 +config CONFIG_AP7000
40 +       bool "AP7000"
42 +endchoice
44 +config LINKRELAX
45 +       bool "Enable linker optimizations"
46 +       default n
47 diff -Nrup a/extra/Configs/Config.in b/extra/Configs/Config.in
48 --- a/extra/Configs/Config.in   2007-01-25 19:01:55.000000000 -0500
49 +++ b/extra/Configs/Config.in   2008-02-28 19:02:10.000000000 -0500
50 @@ -16,6 +16,9 @@ config TARGET_alpha
51  config TARGET_arm
52         bool "arm"
54 +config TARGET_avr32
55 +       bool "avr32"
57  config TARGET_bfin
58         bool "bfin"
60 @@ -83,6 +86,10 @@ if TARGET_arm
61  source "extra/Configs/Config.arm"
62  endif
64 +if TARGET_avr32
65 +source "extra/Configs/Config.avr32"
66 +endif
68  if TARGET_bfin
69  source "extra/Configs/Config.bfin"
70  endif
71 diff -Nrup a/include/elf.h b/include/elf.h
72 --- a/include/elf.h     2007-01-25 19:22:03.000000000 -0500
73 +++ b/include/elf.h     2008-02-28 19:02:10.000000000 -0500
74 @@ -305,6 +305,8 @@ typedef struct
75  /* D30V backend magic number.  Written in the absence of an ABI.  */
76  #define EM_CYGNUS_D30V 0x7676
78 +#define EM_AVR32       0x18ad
80  /* V850 backend magic number.  Written in the absense of an ABI.  */
81  #define EM_CYGNUS_V850 0x9080
83 @@ -2751,6 +2753,55 @@ typedef Elf32_Addr Elf32_Conflict;
84  /* Keep this the last entry.  */
85  #define R_960_NUM      8
87 +/* Atmel AVR32 relocations.  */
88 +#define R_AVR32_NONE           0
89 +#define R_AVR32_32             1
90 +#define R_AVR32_16             2
91 +#define R_AVR32_8              3
92 +#define R_AVR32_32_PCREL       4
93 +#define R_AVR32_16_PCREL       5
94 +#define R_AVR32_8_PCREL                6
95 +#define R_AVR32_DIFF32         7
96 +#define R_AVR32_DIFF16         8
97 +#define R_AVR32_DIFF8          9
98 +#define R_AVR32_GOT32          10
99 +#define R_AVR32_GOT16          11
100 +#define R_AVR32_GOT8           12
101 +#define R_AVR32_21S            13
102 +#define R_AVR32_16U            14
103 +#define R_AVR32_16S            15
104 +#define R_AVR32_8S             16
105 +#define R_AVR32_8S_EXT         17
106 +#define R_AVR32_22H_PCREL      18
107 +#define R_AVR32_18W_PCREL      19
108 +#define R_AVR32_16B_PCREL      20
109 +#define R_AVR32_16N_PCREL      21
110 +#define R_AVR32_14UW_PCREL     22
111 +#define R_AVR32_11H_PCREL      23
112 +#define R_AVR32_10UW_PCREL     24
113 +#define R_AVR32_9H_PCREL       25
114 +#define R_AVR32_9UW_PCREL      26
115 +#define R_AVR32_HI16           27
116 +#define R_AVR32_LO16           28
117 +#define R_AVR32_GOTPC          29
118 +#define R_AVR32_GOTCALL                30
119 +#define R_AVR32_LDA_GOT                31
120 +#define R_AVR32_GOT21S         32
121 +#define R_AVR32_GOT18SW                33
122 +#define R_AVR32_GOT16S         34
123 +#define R_AVR32_GOT7UW         35
124 +#define R_AVR32_32_CPENT       36
125 +#define R_AVR32_CPCALL         37
126 +#define R_AVR32_16_CP          38
127 +#define R_AVR32_9W_CP          39
128 +#define R_AVR32_RELATIVE       40
129 +#define R_AVR32_GLOB_DAT       41
130 +#define R_AVR32_JMP_SLOT       42
131 +#define R_AVR32_ALIGN          43
132 +#define R_AVR32_NUM            44
134 +/* AVR32 dynamic tags */
135 +#define DT_AVR32_GOTSZ         0x70000001 /* Total size of GOT in bytes */
137  /* v850 relocations.  */
138  #define R_V850_NONE            0
139 diff -Nrup a/include/elf.h.orig b/include/elf.h.orig
140 --- a/include/elf.h.orig        1969-12-31 19:00:00.000000000 -0500
141 +++ b/include/elf.h.orig        2007-01-25 19:22:03.000000000 -0500
142 @@ -0,0 +1,2886 @@
143 +/* This file defines standard ELF types, structures, and macros.
144 +   Copyright (C) 1995-2003, 2004, 2005 Free Software Foundation, Inc.
145 +   This file is part of the GNU C Library.
147 +   The GNU C Library is free software; you can redistribute it and/or
148 +   modify it under the terms of the GNU Lesser General Public
149 +   License as published by the Free Software Foundation; either
150 +   version 2.1 of the License, or (at your option) any later version.
152 +   The GNU C Library is distributed in the hope that it will be useful,
153 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
154 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
155 +   Lesser General Public License for more details.
157 +   You should have received a copy of the GNU Lesser General Public
158 +   License along with the GNU C Library; if not, write to the Free
159 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
160 +   02111-1307 USA.  */
162 +#ifndef _ELF_H
163 +#define        _ELF_H 1
165 +#include <features.h>
167 +__BEGIN_DECLS
169 +/* Standard ELF types.  */
171 +#include <stdint.h>
173 +/* Type for a 16-bit quantity.  */
174 +typedef uint16_t Elf32_Half;
175 +typedef uint16_t Elf64_Half;
177 +/* Types for signed and unsigned 32-bit quantities.  */
178 +typedef uint32_t Elf32_Word;
179 +typedef        int32_t  Elf32_Sword;
180 +typedef uint32_t Elf64_Word;
181 +typedef        int32_t  Elf64_Sword;
183 +/* Types for signed and unsigned 64-bit quantities.  */
184 +typedef uint64_t Elf32_Xword;
185 +typedef        int64_t  Elf32_Sxword;
186 +typedef uint64_t Elf64_Xword;
187 +typedef        int64_t  Elf64_Sxword;
189 +/* Type of addresses.  */
190 +typedef uint32_t Elf32_Addr;
191 +typedef uint64_t Elf64_Addr;
193 +/* Type of file offsets.  */
194 +typedef uint32_t Elf32_Off;
195 +typedef uint64_t Elf64_Off;
197 +/* Type for section indices, which are 16-bit quantities.  */
198 +typedef uint16_t Elf32_Section;
199 +typedef uint16_t Elf64_Section;
201 +/* Type for version symbol information.  */
202 +typedef Elf32_Half Elf32_Versym;
203 +typedef Elf64_Half Elf64_Versym;
206 +/* The ELF file header.  This appears at the start of every ELF file.  */
208 +#define EI_NIDENT (16)
210 +typedef struct
212 +  unsigned char        e_ident[EI_NIDENT];     /* Magic number and other info */
213 +  Elf32_Half   e_type;                 /* Object file type */
214 +  Elf32_Half   e_machine;              /* Architecture */
215 +  Elf32_Word   e_version;              /* Object file version */
216 +  Elf32_Addr   e_entry;                /* Entry point virtual address */
217 +  Elf32_Off    e_phoff;                /* Program header table file offset */
218 +  Elf32_Off    e_shoff;                /* Section header table file offset */
219 +  Elf32_Word   e_flags;                /* Processor-specific flags */
220 +  Elf32_Half   e_ehsize;               /* ELF header size in bytes */
221 +  Elf32_Half   e_phentsize;            /* Program header table entry size */
222 +  Elf32_Half   e_phnum;                /* Program header table entry count */
223 +  Elf32_Half   e_shentsize;            /* Section header table entry size */
224 +  Elf32_Half   e_shnum;                /* Section header table entry count */
225 +  Elf32_Half   e_shstrndx;             /* Section header string table index */
226 +} Elf32_Ehdr;
228 +typedef struct
230 +  unsigned char        e_ident[EI_NIDENT];     /* Magic number and other info */
231 +  Elf64_Half   e_type;                 /* Object file type */
232 +  Elf64_Half   e_machine;              /* Architecture */
233 +  Elf64_Word   e_version;              /* Object file version */
234 +  Elf64_Addr   e_entry;                /* Entry point virtual address */
235 +  Elf64_Off    e_phoff;                /* Program header table file offset */
236 +  Elf64_Off    e_shoff;                /* Section header table file offset */
237 +  Elf64_Word   e_flags;                /* Processor-specific flags */
238 +  Elf64_Half   e_ehsize;               /* ELF header size in bytes */
239 +  Elf64_Half   e_phentsize;            /* Program header table entry size */
240 +  Elf64_Half   e_phnum;                /* Program header table entry count */
241 +  Elf64_Half   e_shentsize;            /* Section header table entry size */
242 +  Elf64_Half   e_shnum;                /* Section header table entry count */
243 +  Elf64_Half   e_shstrndx;             /* Section header string table index */
244 +} Elf64_Ehdr;
246 +/* Fields in the e_ident array.  The EI_* macros are indices into the
247 +   array.  The macros under each EI_* macro are the values the byte
248 +   may have.  */
250 +#define EI_MAG0                0               /* File identification byte 0 index */
251 +#define ELFMAG0                0x7f            /* Magic number byte 0 */
253 +#define EI_MAG1                1               /* File identification byte 1 index */
254 +#define ELFMAG1                'E'             /* Magic number byte 1 */
256 +#define EI_MAG2                2               /* File identification byte 2 index */
257 +#define ELFMAG2                'L'             /* Magic number byte 2 */
259 +#define EI_MAG3                3               /* File identification byte 3 index */
260 +#define ELFMAG3                'F'             /* Magic number byte 3 */
262 +/* Conglomeration of the identification bytes, for easy testing as a word.  */
263 +#define        ELFMAG          "\177ELF"
264 +#define        SELFMAG         4
266 +#define EI_CLASS       4               /* File class byte index */
267 +#define ELFCLASSNONE   0               /* Invalid class */
268 +#define ELFCLASS32     1               /* 32-bit objects */
269 +#define ELFCLASS64     2               /* 64-bit objects */
270 +#define ELFCLASSNUM    3
272 +#define EI_DATA                5               /* Data encoding byte index */
273 +#define ELFDATANONE    0               /* Invalid data encoding */
274 +#define ELFDATA2LSB    1               /* 2's complement, little endian */
275 +#define ELFDATA2MSB    2               /* 2's complement, big endian */
276 +#define ELFDATANUM     3
278 +#define EI_VERSION     6               /* File version byte index */
279 +                                       /* Value must be EV_CURRENT */
281 +#define EI_OSABI       7               /* OS ABI identification */
282 +#define ELFOSABI_NONE          0       /* UNIX System V ABI */
283 +#define ELFOSABI_SYSV          0       /* Alias.  */
284 +#define ELFOSABI_HPUX          1       /* HP-UX */
285 +#define ELFOSABI_NETBSD                2       /* NetBSD.  */
286 +#define ELFOSABI_LINUX         3       /* Linux.  */
287 +#define ELFOSABI_HURD          4       /* GNU/Hurd */
288 +#define ELFOSABI_SOLARIS       6       /* Sun Solaris.  */
289 +#define ELFOSABI_AIX           7       /* IBM AIX.  */
290 +#define ELFOSABI_IRIX          8       /* SGI Irix.  */
291 +#define ELFOSABI_FREEBSD       9       /* FreeBSD.  */
292 +#define ELFOSABI_TRU64         10      /* Compaq TRU64 UNIX.  */
293 +#define ELFOSABI_MODESTO       11      /* Novell Modesto.  */
294 +#define ELFOSABI_OPENBSD       12      /* OpenBSD.  */
295 +#define ELFOSABI_OPENVMS       13      /* OpenVMS */
296 +#define ELFOSABI_NSK           14      /* Hewlett-Packard Non-Stop Kernel */
297 +#define ELFOSABI_AROS          15      /* Amiga Research OS */
298 +#define ELFOSABI_ARM           97      /* ARM */
299 +#define ELFOSABI_STANDALONE    255     /* Standalone (embedded) application */
301 +#define EI_ABIVERSION  8               /* ABI version */
303 +#define EI_PAD         9               /* Byte index of padding bytes */
305 +/* Legal values for e_type (object file type).  */
307 +#define ET_NONE                0               /* No file type */
308 +#define ET_REL         1               /* Relocatable file */
309 +#define ET_EXEC                2               /* Executable file */
310 +#define ET_DYN         3               /* Shared object file */
311 +#define ET_CORE                4               /* Core file */
312 +#define        ET_NUM          5               /* Number of defined types */
313 +#define ET_LOOS                0xfe00          /* OS-specific range start */
314 +#define ET_HIOS                0xfeff          /* OS-specific range end */
315 +#define ET_LOPROC      0xff00          /* Processor-specific range start */
316 +#define ET_HIPROC      0xffff          /* Processor-specific range end */
318 +/* Legal values for e_machine (architecture).  */
320 +#define EM_NONE                 0              /* No machine */
321 +#define EM_M32          1              /* AT&T WE 32100 */
322 +#define EM_SPARC        2              /* SUN SPARC */
323 +#define EM_386          3              /* Intel 80386 */
324 +#define EM_68K          4              /* Motorola m68k family */
325 +#define EM_88K          5              /* Motorola m88k family */
326 +#define EM_486          6              /* Intel 80486 *//* Reserved for future use */
327 +#define EM_860          7              /* Intel 80860 */
328 +#define EM_MIPS                 8              /* MIPS R3000 big-endian */
329 +#define EM_S370                 9              /* IBM System/370 */
330 +#define EM_MIPS_RS3_LE 10              /* MIPS R3000 little-endian */
332 +#define EM_PARISC      15              /* HPPA */
333 +#define EM_VPP500      17              /* Fujitsu VPP500 */
334 +#define EM_SPARC32PLUS 18              /* Sun's "v8plus" */
335 +#define EM_960         19              /* Intel 80960 */
336 +#define EM_PPC         20              /* PowerPC */
337 +#define EM_PPC64       21              /* PowerPC 64-bit */
338 +#define EM_S390                22              /* IBM S390 */
340 +#define EM_V800                36              /* NEC V800 series */
341 +#define EM_FR20                37              /* Fujitsu FR20 */
342 +#define EM_RH32                38              /* TRW RH-32 */
343 +#define EM_MCORE       39              /* Motorola M*Core */ /* May also be taken by Fujitsu MMA */
344 +#define EM_RCE         39              /* Old name for MCore */
345 +#define EM_ARM         40              /* ARM */
346 +#define EM_FAKE_ALPHA  41              /* Digital Alpha */
347 +#define EM_SH          42              /* Renesas SH */
348 +#define EM_SPARCV9     43              /* SPARC v9 64-bit */
349 +#define EM_TRICORE     44              /* Siemens Tricore */
350 +#define EM_ARC         45              /* Argonaut RISC Core */
351 +#define EM_H8_300      46              /* Renesas H8/300 */
352 +#define EM_H8_300H     47              /* Renesas H8/300H */
353 +#define EM_H8S         48              /* Renesas H8S */
354 +#define EM_H8_500      49              /* Renesas H8/500 */
355 +#define EM_IA_64       50              /* Intel Merced */
356 +#define EM_MIPS_X      51              /* Stanford MIPS-X */
357 +#define EM_COLDFIRE    52              /* Motorola Coldfire */
358 +#define EM_68HC12      53              /* Motorola M68HC12 */
359 +#define EM_MMA         54              /* Fujitsu MMA Multimedia Accelerator*/
360 +#define EM_PCP         55              /* Siemens PCP */
361 +#define EM_NCPU                56              /* Sony nCPU embeeded RISC */
362 +#define EM_NDR1                57              /* Denso NDR1 microprocessor */
363 +#define EM_STARCORE    58              /* Motorola Start*Core processor */
364 +#define EM_ME16                59              /* Toyota ME16 processor */
365 +#define EM_ST100       60              /* STMicroelectronic ST100 processor */
366 +#define EM_TINYJ       61              /* Advanced Logic Corp. Tinyj emb.fam*/
367 +#define EM_X86_64      62              /* AMD x86-64 architecture */
368 +#define EM_PDSP                63              /* Sony DSP Processor */
370 +#define EM_FX66                66              /* Siemens FX66 microcontroller */
371 +#define EM_ST9PLUS     67              /* STMicroelectronics ST9+ 8/16 mc */
372 +#define EM_ST7         68              /* STmicroelectronics ST7 8 bit mc */
373 +#define EM_68HC16      69              /* Motorola MC68HC16 microcontroller */
374 +#define EM_68HC11      70              /* Motorola MC68HC11 microcontroller */
375 +#define EM_68HC08      71              /* Motorola MC68HC08 microcontroller */
376 +#define EM_68HC05      72              /* Motorola MC68HC05 microcontroller */
377 +#define EM_SVX         73              /* Silicon Graphics SVx */
378 +#define EM_ST19                74              /* STMicroelectronics ST19 8 bit mc */
379 +#define EM_VAX         75              /* Digital VAX */
380 +#define EM_CRIS                76              /* Axis Communications 32-bit embedded processor */
381 +#define EM_JAVELIN     77              /* Infineon Technologies 32-bit embedded processor */
382 +#define EM_FIREPATH    78              /* Element 14 64-bit DSP Processor */
383 +#define EM_ZSP         79              /* LSI Logic 16-bit DSP Processor */
384 +#define EM_MMIX                80              /* Donald Knuth's educational 64-bit processor */
385 +#define EM_HUANY       81              /* Harvard University machine-independent object files */
386 +#define EM_PRISM       82              /* SiTera Prism */
387 +#define EM_AVR         83              /* Atmel AVR 8-bit microcontroller */
388 +#define EM_FR30                84              /* Fujitsu FR30 */
389 +#define EM_D10V                85              /* Mitsubishi D10V */
390 +#define EM_D30V                86              /* Mitsubishi D30V */
391 +#define EM_V850                87              /* NEC v850 */
392 +#define EM_M32R                88              /* Renesas M32R */
393 +#define EM_MN10300     89              /* Matsushita MN10300 */
394 +#define EM_MN10200     90              /* Matsushita MN10200 */
395 +#define EM_PJ          91              /* picoJava */
396 +#define EM_OPENRISC    92              /* OpenRISC 32-bit embedded processor */
397 +#define EM_ARC_A5      93              /* ARC Cores Tangent-A5 */
398 +#define EM_XTENSA      94              /* Tensilica Xtensa Architecture */
399 +#define EM_IP2K                101             /* Ubicom IP2022 micro controller */
400 +#define EM_CR          103             /* National Semiconductor CompactRISC */
401 +#define EM_MSP430      105             /* TI msp430 micro controller */
402 +#define EM_BLACKFIN    106             /* Analog Devices Blackfin */
403 +#define EM_ALTERA_NIOS2        113     /* Altera Nios II soft-core processor */
404 +#define EM_CRX         114             /* National Semiconductor CRX */
405 +#define EM_NUM         95
407 +/* If it is necessary to assign new unofficial EM_* values, please pick large
408 +   random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
409 +   with official or non-GNU unofficial values.
411 +   NOTE: Do not just increment the most recent number by one.
412 +   Somebody else somewhere will do exactly the same thing, and you
413 +   will have a collision.  Instead, pick a random number.
415 +   Normally, each entity or maintainer responsible for a machine with an
416 +   unofficial e_machine number should eventually ask registry@caldera.com for
417 +   an officially blessed number to be added to the list above.  */
419 +/* picoJava */
420 +#define EM_PJ_OLD      99
422 +/* Cygnus PowerPC ELF backend.  Written in the absence of an ABI.  */
423 +#define EM_CYGNUS_POWERPC 0x9025
425 +/* Old version of Sparc v9, from before the ABI; this should be
426 +   removed shortly.  */
427 +#define EM_OLD_SPARCV9 11
429 +/* Old version of PowerPC, this should be removed shortly. */
430 +#define EM_PPC_OLD     17
432 +/* (Deprecated) Temporary number for the OpenRISC processor.  */
433 +#define EM_OR32                0x8472
435 +/* Renesas M32C and M16C.  */
436 +#define EM_M32C                        0xFEB0
438 +/* Cygnus M32R ELF backend.  Written in the absence of an ABI.  */
439 +#define EM_CYGNUS_M32R 0x9041
441 +/* old S/390 backend magic number. Written in the absence of an ABI.  */
442 +#define EM_S390_OLD    0xa390
444 +/* D10V backend magic number.  Written in the absence of an ABI.  */
445 +#define EM_CYGNUS_D10V 0x7650
447 +/* D30V backend magic number.  Written in the absence of an ABI.  */
448 +#define EM_CYGNUS_D30V 0x7676
450 +/* V850 backend magic number.  Written in the absense of an ABI.  */
451 +#define EM_CYGNUS_V850 0x9080
453 +/* mn10200 and mn10300 backend magic numbers.
454 +   Written in the absense of an ABI.  */
455 +#define EM_CYGNUS_MN10200      0xdead
456 +#define EM_CYGNUS_MN10300      0xbeef
458 +/* FR30 magic number - no EABI available.  */
459 +#define EM_CYGNUS_FR30         0x3330
461 +/* AVR magic number
462 +   Written in the absense of an ABI.  */
463 +#define EM_AVR_OLD             0x1057
465 +/* OpenRISC magic number
466 +   Written in the absense of an ABI.  */
467 +#define EM_OPENRISC_OLD                0x3426
469 +/* DLX magic number
470 +   Written in the absense of an ABI.  */
471 +#define EM_DLX                 0x5aa5
473 +#define EM_XSTORMY16           0xad45
475 +/* FRV magic number - no EABI available??.  */
476 +#define EM_CYGNUS_FRV  0x5441
478 +/* Ubicom IP2xxx; no ABI */
479 +#define EM_IP2K_OLD            0x8217
481 +#define EM_MT                   0x2530  /* Morpho MT; no ABI */
483 +/* MSP430 magic number
484 +      Written in the absense everything.  */
485 +#define EM_MSP430_OLD          0x1059
487 +/* Vitesse IQ2000.  */
488 +#define EM_IQ2000              0xFEBA
490 +/* Old, unofficial value for Xtensa.  */
491 +#define EM_XTENSA_OLD          0xabc7
493 +/* Alpha backend magic number.  Written in the absence of an ABI.  */
494 +#define EM_ALPHA       0x9026
496 +/* NIOS magic number - no EABI available.  */
497 +#define EM_NIOS32      0xFEBB
499 +/* V850 backend magic number.  Written in the absense of an ABI.  */
500 +#define EM_CYGNUS_V850 0x9080
502 +/* Legal values for e_version (version).  */
504 +#define EV_NONE                0               /* Invalid ELF version */
505 +#define EV_CURRENT     1               /* Current version */
506 +#define EV_NUM         2
508 +/* Section header.  */
510 +typedef struct
512 +  Elf32_Word   sh_name;                /* Section name (string tbl index) */
513 +  Elf32_Word   sh_type;                /* Section type */
514 +  Elf32_Word   sh_flags;               /* Section flags */
515 +  Elf32_Addr   sh_addr;                /* Section virtual addr at execution */
516 +  Elf32_Off    sh_offset;              /* Section file offset */
517 +  Elf32_Word   sh_size;                /* Section size in bytes */
518 +  Elf32_Word   sh_link;                /* Link to another section */
519 +  Elf32_Word   sh_info;                /* Additional section information */
520 +  Elf32_Word   sh_addralign;           /* Section alignment */
521 +  Elf32_Word   sh_entsize;             /* Entry size if section holds table */
522 +} Elf32_Shdr;
524 +typedef struct
526 +  Elf64_Word   sh_name;                /* Section name (string tbl index) */
527 +  Elf64_Word   sh_type;                /* Section type */
528 +  Elf64_Xword  sh_flags;               /* Section flags */
529 +  Elf64_Addr   sh_addr;                /* Section virtual addr at execution */
530 +  Elf64_Off    sh_offset;              /* Section file offset */
531 +  Elf64_Xword  sh_size;                /* Section size in bytes */
532 +  Elf64_Word   sh_link;                /* Link to another section */
533 +  Elf64_Word   sh_info;                /* Additional section information */
534 +  Elf64_Xword  sh_addralign;           /* Section alignment */
535 +  Elf64_Xword  sh_entsize;             /* Entry size if section holds table */
536 +} Elf64_Shdr;
538 +/* Special section indices.  */
540 +#define SHN_UNDEF      0               /* Undefined section */
541 +#define SHN_LORESERVE  0xff00          /* Start of reserved indices */
542 +#define SHN_LOPROC     0xff00          /* Start of processor-specific */
543 +#define SHN_BEFORE     0xff00          /* Order section before all others
544 +                                          (Solaris).  */
545 +#define SHN_AFTER      0xff01          /* Order section after all others
546 +                                          (Solaris).  */
547 +#define SHN_HIPROC     0xff1f          /* End of processor-specific */
548 +#define SHN_LOOS       0xff20          /* Start of OS-specific */
549 +#define SHN_HIOS       0xff3f          /* End of OS-specific */
550 +#define SHN_ABS                0xfff1          /* Associated symbol is absolute */
551 +#define SHN_COMMON     0xfff2          /* Associated symbol is common */
552 +#define SHN_XINDEX     0xffff          /* Index is in extra table.  */
553 +#define SHN_HIRESERVE  0xffff          /* End of reserved indices */
555 +/* Legal values for sh_type (section type).  */
557 +#define SHT_NULL         0             /* Section header table entry unused */
558 +#define SHT_PROGBITS     1             /* Program data */
559 +#define SHT_SYMTAB       2             /* Symbol table */
560 +#define SHT_STRTAB       3             /* String table */
561 +#define SHT_RELA         4             /* Relocation entries with addends */
562 +#define SHT_HASH         5             /* Symbol hash table */
563 +#define SHT_DYNAMIC      6             /* Dynamic linking information */
564 +#define SHT_NOTE         7             /* Notes */
565 +#define SHT_NOBITS       8             /* Program space with no data (bss) */
566 +#define SHT_REL                  9             /* Relocation entries, no addends */
567 +#define SHT_SHLIB        10            /* Reserved */
568 +#define SHT_DYNSYM       11            /* Dynamic linker symbol table */
569 +#define SHT_INIT_ARRAY   14            /* Array of constructors */
570 +#define SHT_FINI_ARRAY   15            /* Array of destructors */
571 +#define SHT_PREINIT_ARRAY 16           /* Array of pre-constructors */
572 +#define SHT_GROUP        17            /* Section group */
573 +#define SHT_SYMTAB_SHNDX  18           /* Extended section indeces */
574 +#define        SHT_NUM           19            /* Number of defined types.  */
575 +#define SHT_LOOS         0x60000000    /* Start OS-specific */
576 +#define SHT_GNU_LIBLIST          0x6ffffff7    /* Prelink library list */
577 +#define SHT_CHECKSUM     0x6ffffff8    /* Checksum for DSO content.  */
578 +#define SHT_LOSUNW       0x6ffffffa    /* Sun-specific low bound.  */
579 +#define SHT_SUNW_move    0x6ffffffa
580 +#define SHT_SUNW_COMDAT   0x6ffffffb
581 +#define SHT_SUNW_syminfo  0x6ffffffc
582 +#define SHT_GNU_verdef   0x6ffffffd    /* Version definition section.  */
583 +#define SHT_GNU_verneed          0x6ffffffe    /* Version needs section.  */
584 +#define SHT_GNU_versym   0x6fffffff    /* Version symbol table.  */
585 +#define SHT_HISUNW       0x6fffffff    /* Sun-specific high bound.  */
586 +#define SHT_HIOS         0x6fffffff    /* End OS-specific type */
587 +#define SHT_LOPROC       0x70000000    /* Start of processor-specific */
588 +#define SHT_HIPROC       0x7fffffff    /* End of processor-specific */
589 +#define SHT_LOUSER       0x80000000    /* Start of application-specific */
590 +#define SHT_HIUSER       0x8fffffff    /* End of application-specific */
592 +/* Legal values for sh_flags (section flags).  */
594 +#define SHF_WRITE           (1 << 0)   /* Writable */
595 +#define SHF_ALLOC           (1 << 1)   /* Occupies memory during execution */
596 +#define SHF_EXECINSTR       (1 << 2)   /* Executable */
597 +#define SHF_MERGE           (1 << 4)   /* Might be merged */
598 +#define SHF_STRINGS         (1 << 5)   /* Contains nul-terminated strings */
599 +#define SHF_INFO_LINK       (1 << 6)   /* `sh_info' contains SHT index */
600 +#define SHF_LINK_ORDER      (1 << 7)   /* Preserve order after combining */
601 +#define SHF_OS_NONCONFORMING (1 << 8)  /* Non-standard OS specific handling
602 +                                          required */
603 +#define SHF_GROUP           (1 << 9)   /* Section is member of a group.  */
604 +#define SHF_TLS                     (1 << 10)  /* Section hold thread-local data.  */
605 +#define SHF_MASKOS          0x0ff00000 /* OS-specific.  */
606 +#define SHF_MASKPROC        0xf0000000 /* Processor-specific */
607 +#define SHF_ORDERED         (1 << 30)  /* Special ordering requirement
608 +                                          (Solaris).  */
609 +#define SHF_EXCLUDE         (1 << 31)  /* Section is excluded unless
610 +                                          referenced or allocated (Solaris).*/
612 +/* Section group handling.  */
613 +#define GRP_COMDAT     0x1             /* Mark group as COMDAT.  */
615 +/* Symbol table entry.  */
617 +typedef struct
619 +  Elf32_Word   st_name;                /* Symbol name (string tbl index) */
620 +  Elf32_Addr   st_value;               /* Symbol value */
621 +  Elf32_Word   st_size;                /* Symbol size */
622 +  unsigned char        st_info;                /* Symbol type and binding */
623 +  unsigned char        st_other;               /* Symbol visibility */
624 +  Elf32_Section        st_shndx;               /* Section index */
625 +} Elf32_Sym;
627 +typedef struct
629 +  Elf64_Word   st_name;                /* Symbol name (string tbl index) */
630 +  unsigned char        st_info;                /* Symbol type and binding */
631 +  unsigned char st_other;              /* Symbol visibility */
632 +  Elf64_Section        st_shndx;               /* Section index */
633 +  Elf64_Addr   st_value;               /* Symbol value */
634 +  Elf64_Xword  st_size;                /* Symbol size */
635 +} Elf64_Sym;
637 +/* The syminfo section if available contains additional information about
638 +   every dynamic symbol.  */
640 +typedef struct
642 +  Elf32_Half si_boundto;               /* Direct bindings, symbol bound to */
643 +  Elf32_Half si_flags;                 /* Per symbol flags */
644 +} Elf32_Syminfo;
646 +typedef struct
648 +  Elf64_Half si_boundto;               /* Direct bindings, symbol bound to */
649 +  Elf64_Half si_flags;                 /* Per symbol flags */
650 +} Elf64_Syminfo;
652 +/* Possible values for si_boundto.  */
653 +#define SYMINFO_BT_SELF                0xffff  /* Symbol bound to self */
654 +#define SYMINFO_BT_PARENT      0xfffe  /* Symbol bound to parent */
655 +#define SYMINFO_BT_LOWRESERVE  0xff00  /* Beginning of reserved entries */
657 +/* Possible bitmasks for si_flags.  */
658 +#define SYMINFO_FLG_DIRECT     0x0001  /* Direct bound symbol */
659 +#define SYMINFO_FLG_PASSTHRU   0x0002  /* Pass-thru symbol for translator */
660 +#define SYMINFO_FLG_COPY       0x0004  /* Symbol is a copy-reloc */
661 +#define SYMINFO_FLG_LAZYLOAD   0x0008  /* Symbol bound to object to be lazy
662 +                                          loaded */
663 +/* Syminfo version values.  */
664 +#define SYMINFO_NONE           0
665 +#define SYMINFO_CURRENT                1
666 +#define SYMINFO_NUM            2
669 +/* How to extract and insert information held in the st_info field.  */
671 +#define ELF32_ST_BIND(val)             (((unsigned char) (val)) >> 4)
672 +#define ELF32_ST_TYPE(val)             ((val) & 0xf)
673 +#define ELF32_ST_INFO(bind, type)      (((bind) << 4) + ((type) & 0xf))
675 +/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field.  */
676 +#define ELF64_ST_BIND(val)             ELF32_ST_BIND (val)
677 +#define ELF64_ST_TYPE(val)             ELF32_ST_TYPE (val)
678 +#define ELF64_ST_INFO(bind, type)      ELF32_ST_INFO ((bind), (type))
680 +/* Legal values for ST_BIND subfield of st_info (symbol binding).  */
682 +#define STB_LOCAL      0               /* Local symbol */
683 +#define STB_GLOBAL     1               /* Global symbol */
684 +#define STB_WEAK       2               /* Weak symbol */
685 +#define        STB_NUM         3               /* Number of defined types.  */
686 +#define STB_LOOS       10              /* Start of OS-specific */
687 +#define STB_HIOS       12              /* End of OS-specific */
688 +#define STB_LOPROC     13              /* Start of processor-specific */
689 +#define STB_HIPROC     15              /* End of processor-specific */
691 +/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
693 +#define STT_NOTYPE     0               /* Symbol type is unspecified */
694 +#define STT_OBJECT     1               /* Symbol is a data object */
695 +#define STT_FUNC       2               /* Symbol is a code object */
696 +#define STT_SECTION    3               /* Symbol associated with a section */
697 +#define STT_FILE       4               /* Symbol's name is file name */
698 +#define STT_COMMON     5               /* Symbol is a common data object */
699 +#define STT_TLS                6               /* Symbol is thread-local data object*/
700 +#define        STT_NUM         7               /* Number of defined types.  */
701 +#define STT_LOOS       10              /* Start of OS-specific */
702 +#define STT_HIOS       12              /* End of OS-specific */
703 +#define STT_LOPROC     13              /* Start of processor-specific */
704 +#define STT_HIPROC     15              /* End of processor-specific */
707 +/* Symbol table indices are found in the hash buckets and chain table
708 +   of a symbol hash table section.  This special index value indicates
709 +   the end of a chain, meaning no further symbols are found in that bucket.  */
711 +#define STN_UNDEF      0               /* End of a chain.  */
714 +/* How to extract and insert information held in the st_other field.  */
716 +#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
718 +/* For ELF64 the definitions are the same.  */
719 +#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
721 +/* Symbol visibility specification encoded in the st_other field.  */
722 +#define STV_DEFAULT    0               /* Default symbol visibility rules */
723 +#define STV_INTERNAL   1               /* Processor specific hidden class */
724 +#define STV_HIDDEN     2               /* Sym unavailable in other modules */
725 +#define STV_PROTECTED  3               /* Not preemptible, not exported */
728 +/* Relocation table entry without addend (in section of type SHT_REL).  */
730 +typedef struct
732 +  Elf32_Addr   r_offset;               /* Address */
733 +  Elf32_Word   r_info;                 /* Relocation type and symbol index */
734 +} Elf32_Rel;
736 +/* I have seen two different definitions of the Elf64_Rel and
737 +   Elf64_Rela structures, so we'll leave them out until Novell (or
738 +   whoever) gets their act together.  */
739 +/* The following, at least, is used on Sparc v9, MIPS, and Alpha.  */
741 +typedef struct
743 +  Elf64_Addr   r_offset;               /* Address */
744 +  Elf64_Xword  r_info;                 /* Relocation type and symbol index */
745 +} Elf64_Rel;
747 +/* Relocation table entry with addend (in section of type SHT_RELA).  */
749 +typedef struct
751 +  Elf32_Addr   r_offset;               /* Address */
752 +  Elf32_Word   r_info;                 /* Relocation type and symbol index */
753 +  Elf32_Sword  r_addend;               /* Addend */
754 +} Elf32_Rela;
756 +typedef struct
758 +  Elf64_Addr   r_offset;               /* Address */
759 +  Elf64_Xword  r_info;                 /* Relocation type and symbol index */
760 +  Elf64_Sxword r_addend;               /* Addend */
761 +} Elf64_Rela;
763 +/* How to extract and insert information held in the r_info field.  */
765 +#define ELF32_R_SYM(val)               ((val) >> 8)
766 +#define ELF32_R_TYPE(val)              ((val) & 0xff)
767 +#define ELF32_R_INFO(sym, type)                (((sym) << 8) + ((type) & 0xff))
769 +#define ELF64_R_SYM(i)                 ((i) >> 32)
770 +#define ELF64_R_TYPE(i)                        ((i) & 0xffffffff)
771 +#define ELF64_R_INFO(sym,type)         ((((Elf64_Xword) (sym)) << 32) + (type))
773 +/* Program segment header.  */
775 +typedef struct
777 +  Elf32_Word   p_type;                 /* Segment type */
778 +  Elf32_Off    p_offset;               /* Segment file offset */
779 +  Elf32_Addr   p_vaddr;                /* Segment virtual address */
780 +  Elf32_Addr   p_paddr;                /* Segment physical address */
781 +  Elf32_Word   p_filesz;               /* Segment size in file */
782 +  Elf32_Word   p_memsz;                /* Segment size in memory */
783 +  Elf32_Word   p_flags;                /* Segment flags */
784 +  Elf32_Word   p_align;                /* Segment alignment */
785 +} Elf32_Phdr;
787 +typedef struct
789 +  Elf64_Word   p_type;                 /* Segment type */
790 +  Elf64_Word   p_flags;                /* Segment flags */
791 +  Elf64_Off    p_offset;               /* Segment file offset */
792 +  Elf64_Addr   p_vaddr;                /* Segment virtual address */
793 +  Elf64_Addr   p_paddr;                /* Segment physical address */
794 +  Elf64_Xword  p_filesz;               /* Segment size in file */
795 +  Elf64_Xword  p_memsz;                /* Segment size in memory */
796 +  Elf64_Xword  p_align;                /* Segment alignment */
797 +} Elf64_Phdr;
799 +/* Legal values for p_type (segment type).  */
801 +#define        PT_NULL         0               /* Program header table entry unused */
802 +#define PT_LOAD                1               /* Loadable program segment */
803 +#define PT_DYNAMIC     2               /* Dynamic linking information */
804 +#define PT_INTERP      3               /* Program interpreter */
805 +#define PT_NOTE                4               /* Auxiliary information */
806 +#define PT_SHLIB       5               /* Reserved */
807 +#define PT_PHDR                6               /* Entry for header table itself */
808 +#define PT_TLS         7               /* Thread-local storage segment */
809 +#define        PT_NUM          8               /* Number of defined types */
810 +#define PT_LOOS                0x60000000      /* Start of OS-specific */
811 +#define PT_GNU_EH_FRAME        0x6474e550      /* GCC .eh_frame_hdr segment */
812 +#define PT_GNU_STACK   0x6474e551      /* Indicates stack executability */
813 +#define PT_GNU_RELRO   0x6474e552      /* Read-only after relocation */
814 +#define PT_PAX_FLAGS   0x65041580      /* Indicates PaX flag markings */
815 +#define PT_LOSUNW      0x6ffffffa
816 +#define PT_SUNWBSS     0x6ffffffa      /* Sun Specific segment */
817 +#define PT_SUNWSTACK   0x6ffffffb      /* Stack segment */
818 +#define PT_HISUNW      0x6fffffff
819 +#define PT_HIOS                0x6fffffff      /* End of OS-specific */
820 +#define PT_LOPROC      0x70000000      /* Start of processor-specific */
821 +#define PT_HIPROC      0x7fffffff      /* End of processor-specific */
823 +/* Legal values for p_flags (segment flags).  */
825 +#define PF_X           (1 << 0)        /* Segment is executable */
826 +#define PF_W           (1 << 1)        /* Segment is writable */
827 +#define PF_R           (1 << 2)        /* Segment is readable */
828 +#define PF_PAGEEXEC    (1 << 4)        /* Enable  PAGEEXEC */
829 +#define PF_NOPAGEEXEC  (1 << 5)        /* Disable PAGEEXEC */
830 +#define PF_SEGMEXEC    (1 << 6)        /* Enable  SEGMEXEC */
831 +#define PF_NOSEGMEXEC  (1 << 7)        /* Disable SEGMEXEC */
832 +#define PF_MPROTECT    (1 << 8)        /* Enable  MPROTECT */
833 +#define PF_NOMPROTECT  (1 << 9)        /* Disable MPROTECT */
834 +#define PF_RANDEXEC    (1 << 10)       /* Enable  RANDEXEC */
835 +#define PF_NORANDEXEC  (1 << 11)       /* Disable RANDEXEC */
836 +#define PF_EMUTRAMP    (1 << 12)       /* Enable  EMUTRAMP */
837 +#define PF_NOEMUTRAMP  (1 << 13)       /* Disable EMUTRAMP */
838 +#define PF_RANDMMAP    (1 << 14)       /* Enable  RANDMMAP */
839 +#define PF_NORANDMMAP  (1 << 15)       /* Disable RANDMMAP */
840 +#define PF_MASKOS      0x0ff00000      /* OS-specific */
841 +#define PF_MASKPROC    0xf0000000      /* Processor-specific */
843 +/* Legal values for note segment descriptor types for core files. */
845 +#define NT_PRSTATUS    1               /* Contains copy of prstatus struct */
846 +#define NT_FPREGSET    2               /* Contains copy of fpregset struct */
847 +#define NT_PRPSINFO    3               /* Contains copy of prpsinfo struct */
848 +#define NT_PRXREG      4               /* Contains copy of prxregset struct */
849 +#define NT_TASKSTRUCT  4               /* Contains copy of task structure */
850 +#define NT_PLATFORM    5               /* String from sysinfo(SI_PLATFORM) */
851 +#define NT_AUXV                6               /* Contains copy of auxv array */
852 +#define NT_GWINDOWS    7               /* Contains copy of gwindows struct */
853 +#define NT_ASRS                8               /* Contains copy of asrset struct */
854 +#define NT_PSTATUS     10              /* Contains copy of pstatus struct */
855 +#define NT_PSINFO      13              /* Contains copy of psinfo struct */
856 +#define NT_PRCRED      14              /* Contains copy of prcred struct */
857 +#define NT_UTSNAME     15              /* Contains copy of utsname struct */
858 +#define NT_LWPSTATUS   16              /* Contains copy of lwpstatus struct */
859 +#define NT_LWPSINFO    17              /* Contains copy of lwpinfo struct */
860 +#define NT_PRFPXREG    20              /* Contains copy of fprxregset struct*/
862 +/* Legal values for the note segment descriptor types for object files.  */
864 +#define NT_VERSION     1               /* Contains a version string.  */
867 +/* Dynamic section entry.  */
869 +typedef struct
871 +  Elf32_Sword  d_tag;                  /* Dynamic entry type */
872 +  union
873 +    {
874 +      Elf32_Word d_val;                        /* Integer value */
875 +      Elf32_Addr d_ptr;                        /* Address value */
876 +    } d_un;
877 +} Elf32_Dyn;
879 +typedef struct
881 +  Elf64_Sxword d_tag;                  /* Dynamic entry type */
882 +  union
883 +    {
884 +      Elf64_Xword d_val;               /* Integer value */
885 +      Elf64_Addr d_ptr;                        /* Address value */
886 +    } d_un;
887 +} Elf64_Dyn;
889 +/* Legal values for d_tag (dynamic entry type).  */
891 +#define DT_NULL                0               /* Marks end of dynamic section */
892 +#define DT_NEEDED      1               /* Name of needed library */
893 +#define DT_PLTRELSZ    2               /* Size in bytes of PLT relocs */
894 +#define DT_PLTGOT      3               /* Processor defined value */
895 +#define DT_HASH                4               /* Address of symbol hash table */
896 +#define DT_STRTAB      5               /* Address of string table */
897 +#define DT_SYMTAB      6               /* Address of symbol table */
898 +#define DT_RELA                7               /* Address of Rela relocs */
899 +#define DT_RELASZ      8               /* Total size of Rela relocs */
900 +#define DT_RELAENT     9               /* Size of one Rela reloc */
901 +#define DT_STRSZ       10              /* Size of string table */
902 +#define DT_SYMENT      11              /* Size of one symbol table entry */
903 +#define DT_INIT                12              /* Address of init function */
904 +#define DT_FINI                13              /* Address of termination function */
905 +#define DT_SONAME      14              /* Name of shared object */
906 +#define DT_RPATH       15              /* Library search path (deprecated) */
907 +#define DT_SYMBOLIC    16              /* Start symbol search here */
908 +#define DT_REL         17              /* Address of Rel relocs */
909 +#define DT_RELSZ       18              /* Total size of Rel relocs */
910 +#define DT_RELENT      19              /* Size of one Rel reloc */
911 +#define DT_PLTREL      20              /* Type of reloc in PLT */
912 +#define DT_DEBUG       21              /* For debugging; unspecified */
913 +#define DT_TEXTREL     22              /* Reloc might modify .text */
914 +#define DT_JMPREL      23              /* Address of PLT relocs */
915 +#define        DT_BIND_NOW     24              /* Process relocations of object */
916 +#define        DT_INIT_ARRAY   25              /* Array with addresses of init fct */
917 +#define        DT_FINI_ARRAY   26              /* Array with addresses of fini fct */
918 +#define        DT_INIT_ARRAYSZ 27              /* Size in bytes of DT_INIT_ARRAY */
919 +#define        DT_FINI_ARRAYSZ 28              /* Size in bytes of DT_FINI_ARRAY */
920 +#define DT_RUNPATH     29              /* Library search path */
921 +#define DT_FLAGS       30              /* Flags for the object being loaded */
922 +#define DT_ENCODING    32              /* Start of encoded range */
923 +#define DT_PREINIT_ARRAY 32            /* Array with addresses of preinit fct*/
924 +#define DT_PREINIT_ARRAYSZ 33          /* size in bytes of DT_PREINIT_ARRAY */
925 +#define        DT_NUM          34              /* Number used */
926 +#define DT_LOOS                0x6000000d      /* Start of OS-specific */
927 +#define DT_HIOS                0x6ffff000      /* End of OS-specific */
928 +#define DT_LOPROC      0x70000000      /* Start of processor-specific */
929 +#define DT_HIPROC      0x7fffffff      /* End of processor-specific */
930 +#define        DT_PROCNUM      DT_MIPS_NUM     /* Most used by any processor */
932 +/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
933 +   Dyn.d_un.d_val field of the Elf*_Dyn structure.  This follows Sun's
934 +   approach.  */
935 +#define DT_VALRNGLO    0x6ffffd00
936 +#define DT_GNU_PRELINKED 0x6ffffdf5    /* Prelinking timestamp */
937 +#define DT_GNU_CONFLICTSZ 0x6ffffdf6   /* Size of conflict section */
938 +#define DT_GNU_LIBLISTSZ 0x6ffffdf7    /* Size of library list */
939 +#define DT_CHECKSUM    0x6ffffdf8
940 +#define DT_PLTPADSZ    0x6ffffdf9
941 +#define DT_MOVEENT     0x6ffffdfa
942 +#define DT_MOVESZ      0x6ffffdfb
943 +#define DT_FEATURE_1   0x6ffffdfc      /* Feature selection (DTF_*).  */
944 +#define DT_POSFLAG_1   0x6ffffdfd      /* Flags for DT_* entries, effecting
945 +                                          the following DT_* entry.  */
946 +#define DT_SYMINSZ     0x6ffffdfe      /* Size of syminfo table (in bytes) */
947 +#define DT_SYMINENT    0x6ffffdff      /* Entry size of syminfo */
948 +#define DT_VALRNGHI    0x6ffffdff
949 +#define DT_VALTAGIDX(tag)      (DT_VALRNGHI - (tag))   /* Reverse order! */
950 +#define DT_VALNUM 12
952 +/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
953 +   Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
955 +   If any adjustment is made to the ELF object after it has been
956 +   built these entries will need to be adjusted.  */
957 +#define DT_ADDRRNGLO   0x6ffffe00
958 +#define DT_GNU_CONFLICT        0x6ffffef8      /* Start of conflict section */
959 +#define DT_GNU_LIBLIST 0x6ffffef9      /* Library list */
960 +#define DT_CONFIG      0x6ffffefa      /* Configuration information.  */
961 +#define DT_DEPAUDIT    0x6ffffefb      /* Dependency auditing.  */
962 +#define DT_AUDIT       0x6ffffefc      /* Object auditing.  */
963 +#define        DT_PLTPAD       0x6ffffefd      /* PLT padding.  */
964 +#define        DT_MOVETAB      0x6ffffefe      /* Move table.  */
965 +#define DT_SYMINFO     0x6ffffeff      /* Syminfo table.  */
966 +#define DT_ADDRRNGHI   0x6ffffeff
967 +#define DT_ADDRTAGIDX(tag)     (DT_ADDRRNGHI - (tag))  /* Reverse order! */
968 +#define DT_ADDRNUM 10
970 +/* The versioning entry types.  The next are defined as part of the
971 +   GNU extension.  */
972 +#define DT_VERSYM      0x6ffffff0
974 +#define DT_RELACOUNT   0x6ffffff9
975 +#define DT_RELCOUNT    0x6ffffffa
977 +/* These were chosen by Sun.  */
978 +#define DT_FLAGS_1     0x6ffffffb      /* State flags, see DF_1_* below.  */
979 +#define        DT_VERDEF       0x6ffffffc      /* Address of version definition
980 +                                          table */
981 +#define        DT_VERDEFNUM    0x6ffffffd      /* Number of version definitions */
982 +#define        DT_VERNEED      0x6ffffffe      /* Address of table with needed
983 +                                          versions */
984 +#define        DT_VERNEEDNUM   0x6fffffff      /* Number of needed versions */
985 +#define DT_VERSIONTAGIDX(tag)  (DT_VERNEEDNUM - (tag)) /* Reverse order! */
986 +#define DT_VERSIONTAGNUM 16
988 +/* Sun added these machine-independent extensions in the "processor-specific"
989 +   range.  Be compatible.  */
990 +#define DT_AUXILIARY    0x7ffffffd      /* Shared object to load before self */
991 +#define DT_FILTER       0x7fffffff      /* Shared object to get values from */
992 +#define DT_EXTRATAGIDX(tag)    ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
993 +#define DT_EXTRANUM    3
995 +/* Values of `d_un.d_val' in the DT_FLAGS entry.  */
996 +#define DF_ORIGIN      0x00000001      /* Object may use DF_ORIGIN */
997 +#define DF_SYMBOLIC    0x00000002      /* Symbol resolutions starts here */
998 +#define DF_TEXTREL     0x00000004      /* Object contains text relocations */
999 +#define DF_BIND_NOW    0x00000008      /* No lazy binding for this object */
1000 +#define DF_STATIC_TLS  0x00000010      /* Module uses the static TLS model */
1002 +/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
1003 +   entry in the dynamic section.  */
1004 +#define DF_1_NOW       0x00000001      /* Set RTLD_NOW for this object.  */
1005 +#define DF_1_GLOBAL    0x00000002      /* Set RTLD_GLOBAL for this object.  */
1006 +#define DF_1_GROUP     0x00000004      /* Set RTLD_GROUP for this object.  */
1007 +#define DF_1_NODELETE  0x00000008      /* Set RTLD_NODELETE for this object.*/
1008 +#define DF_1_LOADFLTR  0x00000010      /* Trigger filtee loading at runtime.*/
1009 +#define DF_1_INITFIRST 0x00000020      /* Set RTLD_INITFIRST for this object*/
1010 +#define DF_1_NOOPEN    0x00000040      /* Set RTLD_NOOPEN for this object.  */
1011 +#define DF_1_ORIGIN    0x00000080      /* $ORIGIN must be handled.  */
1012 +#define DF_1_DIRECT    0x00000100      /* Direct binding enabled.  */
1013 +#define DF_1_TRANS     0x00000200
1014 +#define DF_1_INTERPOSE 0x00000400      /* Object is used to interpose.  */
1015 +#define DF_1_NODEFLIB  0x00000800      /* Ignore default lib search path.  */
1016 +#define DF_1_NODUMP    0x00001000      /* Object can't be dldump'ed.  */
1017 +#define DF_1_CONFALT   0x00002000      /* Configuration alternative created.*/
1018 +#define DF_1_ENDFILTEE 0x00004000      /* Filtee terminates filters search. */
1019 +#define        DF_1_DISPRELDNE 0x00008000      /* Disp reloc applied at build time. */
1020 +#define        DF_1_DISPRELPND 0x00010000      /* Disp reloc applied at run-time.  */
1022 +/* Flags for the feature selection in DT_FEATURE_1.  */
1023 +#define DTF_1_PARINIT  0x00000001
1024 +#define DTF_1_CONFEXP  0x00000002
1026 +/* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry.  */
1027 +#define DF_P1_LAZYLOAD 0x00000001      /* Lazyload following object.  */
1028 +#define DF_P1_GROUPPERM        0x00000002      /* Symbols from next object are not
1029 +                                          generally available.  */
1031 +/* Version definition sections.  */
1033 +typedef struct
1035 +  Elf32_Half   vd_version;             /* Version revision */
1036 +  Elf32_Half   vd_flags;               /* Version information */
1037 +  Elf32_Half   vd_ndx;                 /* Version Index */
1038 +  Elf32_Half   vd_cnt;                 /* Number of associated aux entries */
1039 +  Elf32_Word   vd_hash;                /* Version name hash value */
1040 +  Elf32_Word   vd_aux;                 /* Offset in bytes to verdaux array */
1041 +  Elf32_Word   vd_next;                /* Offset in bytes to next verdef
1042 +                                          entry */
1043 +} Elf32_Verdef;
1045 +typedef struct
1047 +  Elf64_Half   vd_version;             /* Version revision */
1048 +  Elf64_Half   vd_flags;               /* Version information */
1049 +  Elf64_Half   vd_ndx;                 /* Version Index */
1050 +  Elf64_Half   vd_cnt;                 /* Number of associated aux entries */
1051 +  Elf64_Word   vd_hash;                /* Version name hash value */
1052 +  Elf64_Word   vd_aux;                 /* Offset in bytes to verdaux array */
1053 +  Elf64_Word   vd_next;                /* Offset in bytes to next verdef
1054 +                                          entry */
1055 +} Elf64_Verdef;
1058 +/* Legal values for vd_version (version revision).  */
1059 +#define VER_DEF_NONE   0               /* No version */
1060 +#define VER_DEF_CURRENT        1               /* Current version */
1061 +#define VER_DEF_NUM    2               /* Given version number */
1063 +/* Legal values for vd_flags (version information flags).  */
1064 +#define VER_FLG_BASE   0x1             /* Version definition of file itself */
1065 +#define VER_FLG_WEAK   0x2             /* Weak version identifier */
1067 +/* Versym symbol index values.  */
1068 +#define        VER_NDX_LOCAL           0       /* Symbol is local.  */
1069 +#define        VER_NDX_GLOBAL          1       /* Symbol is global.  */
1070 +#define        VER_NDX_LORESERVE       0xff00  /* Beginning of reserved entries.  */
1071 +#define        VER_NDX_ELIMINATE       0xff01  /* Symbol is to be eliminated.  */
1073 +/* Auxialiary version information.  */
1075 +typedef struct
1077 +  Elf32_Word   vda_name;               /* Version or dependency names */
1078 +  Elf32_Word   vda_next;               /* Offset in bytes to next verdaux
1079 +                                          entry */
1080 +} Elf32_Verdaux;
1082 +typedef struct
1084 +  Elf64_Word   vda_name;               /* Version or dependency names */
1085 +  Elf64_Word   vda_next;               /* Offset in bytes to next verdaux
1086 +                                          entry */
1087 +} Elf64_Verdaux;
1090 +/* Version dependency section.  */
1092 +typedef struct
1094 +  Elf32_Half   vn_version;             /* Version of structure */
1095 +  Elf32_Half   vn_cnt;                 /* Number of associated aux entries */
1096 +  Elf32_Word   vn_file;                /* Offset of filename for this
1097 +                                          dependency */
1098 +  Elf32_Word   vn_aux;                 /* Offset in bytes to vernaux array */
1099 +  Elf32_Word   vn_next;                /* Offset in bytes to next verneed
1100 +                                          entry */
1101 +} Elf32_Verneed;
1103 +typedef struct
1105 +  Elf64_Half   vn_version;             /* Version of structure */
1106 +  Elf64_Half   vn_cnt;                 /* Number of associated aux entries */
1107 +  Elf64_Word   vn_file;                /* Offset of filename for this
1108 +                                          dependency */
1109 +  Elf64_Word   vn_aux;                 /* Offset in bytes to vernaux array */
1110 +  Elf64_Word   vn_next;                /* Offset in bytes to next verneed
1111 +                                          entry */
1112 +} Elf64_Verneed;
1115 +/* Legal values for vn_version (version revision).  */
1116 +#define VER_NEED_NONE   0              /* No version */
1117 +#define VER_NEED_CURRENT 1             /* Current version */
1118 +#define VER_NEED_NUM    2              /* Given version number */
1120 +/* Auxiliary needed version information.  */
1122 +typedef struct
1124 +  Elf32_Word   vna_hash;               /* Hash value of dependency name */
1125 +  Elf32_Half   vna_flags;              /* Dependency specific information */
1126 +  Elf32_Half   vna_other;              /* Unused */
1127 +  Elf32_Word   vna_name;               /* Dependency name string offset */
1128 +  Elf32_Word   vna_next;               /* Offset in bytes to next vernaux
1129 +                                          entry */
1130 +} Elf32_Vernaux;
1132 +typedef struct
1134 +  Elf64_Word   vna_hash;               /* Hash value of dependency name */
1135 +  Elf64_Half   vna_flags;              /* Dependency specific information */
1136 +  Elf64_Half   vna_other;              /* Unused */
1137 +  Elf64_Word   vna_name;               /* Dependency name string offset */
1138 +  Elf64_Word   vna_next;               /* Offset in bytes to next vernaux
1139 +                                          entry */
1140 +} Elf64_Vernaux;
1143 +/* Legal values for vna_flags.  */
1144 +#define VER_FLG_WEAK   0x2             /* Weak version identifier */
1147 +/* Auxiliary vector.  */
1149 +/* This vector is normally only used by the program interpreter.  The
1150 +   usual definition in an ABI supplement uses the name auxv_t.  The
1151 +   vector is not usually defined in a standard <elf.h> file, but it
1152 +   can't hurt.  We rename it to avoid conflicts.  The sizes of these
1153 +   types are an arrangement between the exec server and the program
1154 +   interpreter, so we don't fully specify them here.  */
1156 +typedef struct
1158 +  uint32_t a_type;             /* Entry type */
1159 +  union
1160 +    {
1161 +      uint32_t a_val;          /* Integer value */
1162 +      /* We use to have pointer elements added here.  We cannot do that,
1163 +        though, since it does not work when using 32-bit definitions
1164 +        on 64-bit platforms and vice versa.  */
1165 +    } a_un;
1166 +} Elf32_auxv_t;
1168 +typedef struct
1170 +  uint64_t a_type;             /* Entry type */
1171 +  union
1172 +    {
1173 +      uint64_t a_val;          /* Integer value */
1174 +      /* We use to have pointer elements added here.  We cannot do that,
1175 +        though, since it does not work when using 32-bit definitions
1176 +        on 64-bit platforms and vice versa.  */
1177 +    } a_un;
1178 +} Elf64_auxv_t;
1180 +/* Legal values for a_type (entry type).  */
1182 +#define AT_NULL                0               /* End of vector */
1183 +#define AT_IGNORE      1               /* Entry should be ignored */
1184 +#define AT_EXECFD      2               /* File descriptor of program */
1185 +#define AT_PHDR                3               /* Program headers for program */
1186 +#define AT_PHENT       4               /* Size of program header entry */
1187 +#define AT_PHNUM       5               /* Number of program headers */
1188 +#define AT_PAGESZ      6               /* System page size */
1189 +#define AT_BASE                7               /* Base address of interpreter */
1190 +#define AT_FLAGS       8               /* Flags */
1191 +#define AT_ENTRY       9               /* Entry point of program */
1192 +#define AT_NOTELF      10              /* Program is not ELF */
1193 +#define AT_UID         11              /* Real uid */
1194 +#define AT_EUID                12              /* Effective uid */
1195 +#define AT_GID         13              /* Real gid */
1196 +#define AT_EGID                14              /* Effective gid */
1197 +#define AT_CLKTCK      17              /* Frequency of times() */
1199 +/* Some more special a_type values describing the hardware.  */
1200 +#define AT_PLATFORM    15              /* String identifying platform.  */
1201 +#define AT_HWCAP       16              /* Machine dependent hints about
1202 +                                          processor capabilities.  */
1204 +/* This entry gives some information about the FPU initialization
1205 +   performed by the kernel.  */
1206 +#define AT_FPUCW       18              /* Used FPU control word.  */
1208 +/* Cache block sizes.  */
1209 +#define AT_DCACHEBSIZE 19              /* Data cache block size.  */
1210 +#define AT_ICACHEBSIZE 20              /* Instruction cache block size.  */
1211 +#define AT_UCACHEBSIZE 21              /* Unified cache block size.  */
1213 +/* A special ignored value for PPC, used by the kernel to control the
1214 +   interpretation of the AUXV. Must be > 16.  */
1215 +#define AT_IGNOREPPC   22              /* Entry should be ignored.  */
1217 +#define        AT_SECURE       23              /* Boolean, was exec setuid-like?  */
1219 +/* Pointer to the global system page used for system calls and other
1220 +   nice things.  */
1221 +#define AT_SYSINFO     32
1222 +#define AT_SYSINFO_EHDR        33
1224 +/* Shapes of the caches.  Bits 0-3 contains associativity; bits 4-7 contains
1225 +   log2 of line size; mask those to get cache size.  */
1226 +#define AT_L1I_CACHESHAPE      34
1227 +#define AT_L1D_CACHESHAPE      35
1228 +#define AT_L2_CACHESHAPE       36
1229 +#define AT_L3_CACHESHAPE       37
1231 +/* Note section contents.  Each entry in the note section begins with
1232 +   a header of a fixed form.  */
1234 +typedef struct
1236 +  Elf32_Word n_namesz;                 /* Length of the note's name.  */
1237 +  Elf32_Word n_descsz;                 /* Length of the note's descriptor.  */
1238 +  Elf32_Word n_type;                   /* Type of the note.  */
1239 +} Elf32_Nhdr;
1241 +typedef struct
1243 +  Elf64_Word n_namesz;                 /* Length of the note's name.  */
1244 +  Elf64_Word n_descsz;                 /* Length of the note's descriptor.  */
1245 +  Elf64_Word n_type;                   /* Type of the note.  */
1246 +} Elf64_Nhdr;
1248 +/* Known names of notes.  */
1250 +/* Solaris entries in the note section have this name.  */
1251 +#define ELF_NOTE_SOLARIS       "SUNW Solaris"
1253 +/* Note entries for GNU systems have this name.  */
1254 +#define ELF_NOTE_GNU           "GNU"
1257 +/* Defined types of notes for Solaris.  */
1259 +/* Value of descriptor (one word) is desired pagesize for the binary.  */
1260 +#define ELF_NOTE_PAGESIZE_HINT 1
1263 +/* Defined note types for GNU systems.  */
1265 +/* ABI information.  The descriptor consists of words:
1266 +   word 0: OS descriptor
1267 +   word 1: major version of the ABI
1268 +   word 2: minor version of the ABI
1269 +   word 3: subminor version of the ABI
1271 +#define ELF_NOTE_ABI           1
1273 +/* Known OSes.  These value can appear in word 0 of an ELF_NOTE_ABI
1274 +   note section entry.  */
1275 +#define ELF_NOTE_OS_LINUX      0
1276 +#define ELF_NOTE_OS_GNU                1
1277 +#define ELF_NOTE_OS_SOLARIS2   2
1278 +#define ELF_NOTE_OS_FREEBSD    3
1281 +/* Move records.  */
1282 +typedef struct
1284 +  Elf32_Xword m_value;         /* Symbol value.  */
1285 +  Elf32_Word m_info;           /* Size and index.  */
1286 +  Elf32_Word m_poffset;                /* Symbol offset.  */
1287 +  Elf32_Half m_repeat;         /* Repeat count.  */
1288 +  Elf32_Half m_stride;         /* Stride info.  */
1289 +} Elf32_Move;
1291 +typedef struct
1293 +  Elf64_Xword m_value;         /* Symbol value.  */
1294 +  Elf64_Xword m_info;          /* Size and index.  */
1295 +  Elf64_Xword m_poffset;       /* Symbol offset.  */
1296 +  Elf64_Half m_repeat;         /* Repeat count.  */
1297 +  Elf64_Half m_stride;         /* Stride info.  */
1298 +} Elf64_Move;
1300 +/* Macro to construct move records.  */
1301 +#define ELF32_M_SYM(info)      ((info) >> 8)
1302 +#define ELF32_M_SIZE(info)     ((unsigned char) (info))
1303 +#define ELF32_M_INFO(sym, size)        (((sym) << 8) + (unsigned char) (size))
1305 +#define ELF64_M_SYM(info)      ELF32_M_SYM (info)
1306 +#define ELF64_M_SIZE(info)     ELF32_M_SIZE (info)
1307 +#define ELF64_M_INFO(sym, size)        ELF32_M_INFO (sym, size)
1310 +/* Motorola 68k specific definitions.  */
1312 +/* Values for Elf32_Ehdr.e_flags.  */
1313 +#define EF_CPU32       0x00810000
1315 +/* m68k relocs.  */
1317 +#define R_68K_NONE     0               /* No reloc */
1318 +#define R_68K_32       1               /* Direct 32 bit  */
1319 +#define R_68K_16       2               /* Direct 16 bit  */
1320 +#define R_68K_8                3               /* Direct 8 bit  */
1321 +#define R_68K_PC32     4               /* PC relative 32 bit */
1322 +#define R_68K_PC16     5               /* PC relative 16 bit */
1323 +#define R_68K_PC8      6               /* PC relative 8 bit */
1324 +#define R_68K_GOT32    7               /* 32 bit PC relative GOT entry */
1325 +#define R_68K_GOT16    8               /* 16 bit PC relative GOT entry */
1326 +#define R_68K_GOT8     9               /* 8 bit PC relative GOT entry */
1327 +#define R_68K_GOT32O   10              /* 32 bit GOT offset */
1328 +#define R_68K_GOT16O   11              /* 16 bit GOT offset */
1329 +#define R_68K_GOT8O    12              /* 8 bit GOT offset */
1330 +#define R_68K_PLT32    13              /* 32 bit PC relative PLT address */
1331 +#define R_68K_PLT16    14              /* 16 bit PC relative PLT address */
1332 +#define R_68K_PLT8     15              /* 8 bit PC relative PLT address */
1333 +#define R_68K_PLT32O   16              /* 32 bit PLT offset */
1334 +#define R_68K_PLT16O   17              /* 16 bit PLT offset */
1335 +#define R_68K_PLT8O    18              /* 8 bit PLT offset */
1336 +#define R_68K_COPY     19              /* Copy symbol at runtime */
1337 +#define R_68K_GLOB_DAT 20              /* Create GOT entry */
1338 +#define R_68K_JMP_SLOT 21              /* Create PLT entry */
1339 +#define R_68K_RELATIVE 22              /* Adjust by program base */
1340 +/* Keep this the last entry.  */
1341 +#define R_68K_NUM      23
1343 +/* Intel 80386 specific definitions.  */
1345 +/* i386 relocs.  */
1347 +#define R_386_NONE        0            /* No reloc */
1348 +#define R_386_32          1            /* Direct 32 bit  */
1349 +#define R_386_PC32        2            /* PC relative 32 bit */
1350 +#define R_386_GOT32       3            /* 32 bit GOT entry */
1351 +#define R_386_PLT32       4            /* 32 bit PLT address */
1352 +#define R_386_COPY        5            /* Copy symbol at runtime */
1353 +#define R_386_GLOB_DAT    6            /* Create GOT entry */
1354 +#define R_386_JMP_SLOT    7            /* Create PLT entry */
1355 +#define R_386_RELATIVE    8            /* Adjust by program base */
1356 +#define R_386_GOTOFF      9            /* 32 bit offset to GOT */
1357 +#define R_386_GOTPC       10           /* 32 bit PC relative offset to GOT */
1358 +#define R_386_32PLT       11
1359 +#define R_386_TLS_TPOFF           14           /* Offset in static TLS block */
1360 +#define R_386_TLS_IE      15           /* Address of GOT entry for static TLS
1361 +                                          block offset */
1362 +#define R_386_TLS_GOTIE           16           /* GOT entry for static TLS block
1363 +                                          offset */
1364 +#define R_386_TLS_LE      17           /* Offset relative to static TLS
1365 +                                          block */
1366 +#define R_386_TLS_GD      18           /* Direct 32 bit for GNU version of
1367 +                                          general dynamic thread local data */
1368 +#define R_386_TLS_LDM     19           /* Direct 32 bit for GNU version of
1369 +                                          local dynamic thread local data
1370 +                                          in LE code */
1371 +#define R_386_16          20
1372 +#define R_386_PC16        21
1373 +#define R_386_8                   22
1374 +#define R_386_PC8         23
1375 +#define R_386_TLS_GD_32           24           /* Direct 32 bit for general dynamic
1376 +                                          thread local data */
1377 +#define R_386_TLS_GD_PUSH  25          /* Tag for pushl in GD TLS code */
1378 +#define R_386_TLS_GD_CALL  26          /* Relocation for call to
1379 +                                          __tls_get_addr() */
1380 +#define R_386_TLS_GD_POP   27          /* Tag for popl in GD TLS code */
1381 +#define R_386_TLS_LDM_32   28          /* Direct 32 bit for local dynamic
1382 +                                          thread local data in LE code */
1383 +#define R_386_TLS_LDM_PUSH 29          /* Tag for pushl in LDM TLS code */
1384 +#define R_386_TLS_LDM_CALL 30          /* Relocation for call to
1385 +                                          __tls_get_addr() in LDM code */
1386 +#define R_386_TLS_LDM_POP  31          /* Tag for popl in LDM TLS code */
1387 +#define R_386_TLS_LDO_32   32          /* Offset relative to TLS block */
1388 +#define R_386_TLS_IE_32           33           /* GOT entry for negated static TLS
1389 +                                          block offset */
1390 +#define R_386_TLS_LE_32           34           /* Negated offset relative to static
1391 +                                          TLS block */
1392 +#define R_386_TLS_DTPMOD32 35          /* ID of module containing symbol */
1393 +#define R_386_TLS_DTPOFF32 36          /* Offset in TLS block */
1394 +#define R_386_TLS_TPOFF32  37          /* Negated offset in static TLS block */
1395 +/* Keep this the last entry.  */
1396 +#define R_386_NUM         38
1398 +/* FR-V specific definitions.  */
1399 +#define R_FRV_NONE             0       /* No reloc.  */
1400 +#define R_FRV_32               1       /* Direct 32 bit.  */
1401 +/* Canonical function descriptor address.  */
1402 +#define R_FRV_FUNCDESC         14
1403 +/* Private function descriptor initialization.  */
1404 +#define R_FRV_FUNCDESC_VALUE   18
1406 +                                               /* gpr support */
1407 +#define EF_FRV_GPR_MASK                0x00000003      /* mask for # of gprs */
1408 +#define EF_FRV_GPR_32          0x00000001      /* -mgpr-32 */
1409 +#define EF_FRV_GPR_64          0x00000002      /* -mgpr-64 */
1411 +                                               /* fpr support */
1412 +#define EF_FRV_FPR_MASK                0x0000000c      /* mask for # of fprs */
1413 +#define EF_FRV_FPR_32          0x00000004      /* -mfpr-32 */
1414 +#define EF_FRV_FPR_64          0x00000008      /* -mfpr-64 */
1415 +#define EF_FRV_FPR_NONE                0x0000000c      /* -msoft-float */
1417 +#define EF_FRV_PIC   0x00000100
1418 +#define EF_FRV_FDPIC 0x00008000
1420 +/* SUN SPARC specific definitions.  */
1422 +/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
1424 +#define STT_SPARC_REGISTER     13      /* Global register reserved to app. */
1426 +/* Values for Elf64_Ehdr.e_flags.  */
1428 +#define EF_SPARCV9_MM          3
1429 +#define EF_SPARCV9_TSO         0
1430 +#define EF_SPARCV9_PSO         1
1431 +#define EF_SPARCV9_RMO         2
1432 +#define EF_SPARC_LEDATA                0x800000 /* little endian data */
1433 +#define EF_SPARC_EXT_MASK      0xFFFF00
1434 +#define EF_SPARC_32PLUS                0x000100 /* generic V8+ features */
1435 +#define EF_SPARC_SUN_US1       0x000200 /* Sun UltraSPARC1 extensions */
1436 +#define EF_SPARC_HAL_R1                0x000400 /* HAL R1 extensions */
1437 +#define EF_SPARC_SUN_US3       0x000800 /* Sun UltraSPARCIII extensions */
1439 +/* SPARC relocs.  */
1441 +#define R_SPARC_NONE           0       /* No reloc */
1442 +#define R_SPARC_8              1       /* Direct 8 bit */
1443 +#define R_SPARC_16             2       /* Direct 16 bit */
1444 +#define R_SPARC_32             3       /* Direct 32 bit */
1445 +#define R_SPARC_DISP8          4       /* PC relative 8 bit */
1446 +#define R_SPARC_DISP16         5       /* PC relative 16 bit */
1447 +#define R_SPARC_DISP32         6       /* PC relative 32 bit */
1448 +#define R_SPARC_WDISP30                7       /* PC relative 30 bit shifted */
1449 +#define R_SPARC_WDISP22                8       /* PC relative 22 bit shifted */
1450 +#define R_SPARC_HI22           9       /* High 22 bit */
1451 +#define R_SPARC_22             10      /* Direct 22 bit */
1452 +#define R_SPARC_13             11      /* Direct 13 bit */
1453 +#define R_SPARC_LO10           12      /* Truncated 10 bit */
1454 +#define R_SPARC_GOT10          13      /* Truncated 10 bit GOT entry */
1455 +#define R_SPARC_GOT13          14      /* 13 bit GOT entry */
1456 +#define R_SPARC_GOT22          15      /* 22 bit GOT entry shifted */
1457 +#define R_SPARC_PC10           16      /* PC relative 10 bit truncated */
1458 +#define R_SPARC_PC22           17      /* PC relative 22 bit shifted */
1459 +#define R_SPARC_WPLT30         18      /* 30 bit PC relative PLT address */
1460 +#define R_SPARC_COPY           19      /* Copy symbol at runtime */
1461 +#define R_SPARC_GLOB_DAT       20      /* Create GOT entry */
1462 +#define R_SPARC_JMP_SLOT       21      /* Create PLT entry */
1463 +#define R_SPARC_RELATIVE       22      /* Adjust by program base */
1464 +#define R_SPARC_UA32           23      /* Direct 32 bit unaligned */
1466 +/* Additional Sparc64 relocs.  */
1468 +#define R_SPARC_PLT32          24      /* Direct 32 bit ref to PLT entry */
1469 +#define R_SPARC_HIPLT22                25      /* High 22 bit PLT entry */
1470 +#define R_SPARC_LOPLT10                26      /* Truncated 10 bit PLT entry */
1471 +#define R_SPARC_PCPLT32                27      /* PC rel 32 bit ref to PLT entry */
1472 +#define R_SPARC_PCPLT22                28      /* PC rel high 22 bit PLT entry */
1473 +#define R_SPARC_PCPLT10                29      /* PC rel trunc 10 bit PLT entry */
1474 +#define R_SPARC_10             30      /* Direct 10 bit */
1475 +#define R_SPARC_11             31      /* Direct 11 bit */
1476 +#define R_SPARC_64             32      /* Direct 64 bit */
1477 +#define R_SPARC_OLO10          33      /* 10bit with secondary 13bit addend */
1478 +#define R_SPARC_HH22           34      /* Top 22 bits of direct 64 bit */
1479 +#define R_SPARC_HM10           35      /* High middle 10 bits of ... */
1480 +#define R_SPARC_LM22           36      /* Low middle 22 bits of ... */
1481 +#define R_SPARC_PC_HH22                37      /* Top 22 bits of pc rel 64 bit */
1482 +#define R_SPARC_PC_HM10                38      /* High middle 10 bit of ... */
1483 +#define R_SPARC_PC_LM22                39      /* Low miggle 22 bits of ... */
1484 +#define R_SPARC_WDISP16                40      /* PC relative 16 bit shifted */
1485 +#define R_SPARC_WDISP19                41      /* PC relative 19 bit shifted */
1486 +#define R_SPARC_7              43      /* Direct 7 bit */
1487 +#define R_SPARC_5              44      /* Direct 5 bit */
1488 +#define R_SPARC_6              45      /* Direct 6 bit */
1489 +#define R_SPARC_DISP64         46      /* PC relative 64 bit */
1490 +#define R_SPARC_PLT64          47      /* Direct 64 bit ref to PLT entry */
1491 +#define R_SPARC_HIX22          48      /* High 22 bit complemented */
1492 +#define R_SPARC_LOX10          49      /* Truncated 11 bit complemented */
1493 +#define R_SPARC_H44            50      /* Direct high 12 of 44 bit */
1494 +#define R_SPARC_M44            51      /* Direct mid 22 of 44 bit */
1495 +#define R_SPARC_L44            52      /* Direct low 10 of 44 bit */
1496 +#define R_SPARC_REGISTER       53      /* Global register usage */
1497 +#define R_SPARC_UA64           54      /* Direct 64 bit unaligned */
1498 +#define R_SPARC_UA16           55      /* Direct 16 bit unaligned */
1499 +#define R_SPARC_TLS_GD_HI22    56
1500 +#define R_SPARC_TLS_GD_LO10    57
1501 +#define R_SPARC_TLS_GD_ADD     58
1502 +#define R_SPARC_TLS_GD_CALL    59
1503 +#define R_SPARC_TLS_LDM_HI22   60
1504 +#define R_SPARC_TLS_LDM_LO10   61
1505 +#define R_SPARC_TLS_LDM_ADD    62
1506 +#define R_SPARC_TLS_LDM_CALL   63
1507 +#define R_SPARC_TLS_LDO_HIX22  64
1508 +#define R_SPARC_TLS_LDO_LOX10  65
1509 +#define R_SPARC_TLS_LDO_ADD    66
1510 +#define R_SPARC_TLS_IE_HI22    67
1511 +#define R_SPARC_TLS_IE_LO10    68
1512 +#define R_SPARC_TLS_IE_LD      69
1513 +#define R_SPARC_TLS_IE_LDX     70
1514 +#define R_SPARC_TLS_IE_ADD     71
1515 +#define R_SPARC_TLS_LE_HIX22   72
1516 +#define R_SPARC_TLS_LE_LOX10   73
1517 +#define R_SPARC_TLS_DTPMOD32   74
1518 +#define R_SPARC_TLS_DTPMOD64   75
1519 +#define R_SPARC_TLS_DTPOFF32   76
1520 +#define R_SPARC_TLS_DTPOFF64   77
1521 +#define R_SPARC_TLS_TPOFF32    78
1522 +#define R_SPARC_TLS_TPOFF64    79
1523 +/* Keep this the last entry.  */
1524 +#define R_SPARC_NUM            80
1526 +/* For Sparc64, legal values for d_tag of Elf64_Dyn.  */
1528 +#define DT_SPARC_REGISTER 0x70000001
1529 +#define DT_SPARC_NUM   2
1531 +/* Bits present in AT_HWCAP, primarily for Sparc32.  */
1533 +#define HWCAP_SPARC_FLUSH      1       /* The cpu supports flush insn.  */
1534 +#define HWCAP_SPARC_STBAR      2
1535 +#define HWCAP_SPARC_SWAP       4
1536 +#define HWCAP_SPARC_MULDIV     8
1537 +#define HWCAP_SPARC_V9         16      /* The cpu is v9, so v8plus is ok.  */
1538 +#define HWCAP_SPARC_ULTRA3     32
1540 +/* MIPS R3000 specific definitions.  */
1542 +/* Legal values for e_flags field of Elf32_Ehdr.  */
1544 +#define EF_MIPS_NOREORDER   1          /* A .noreorder directive was used */
1545 +#define EF_MIPS_PIC        2           /* Contains PIC code */
1546 +#define EF_MIPS_CPIC       4           /* Uses PIC calling sequence */
1547 +#define EF_MIPS_XGOT       8
1548 +#define EF_MIPS_64BIT_WHIRL 16
1549 +#define EF_MIPS_ABI2       32
1550 +#define EF_MIPS_ABI_ON32    64
1551 +#define EF_MIPS_ARCH       0xf0000000  /* MIPS architecture level */
1553 +/* Legal values for MIPS architecture level.  */
1555 +#define EF_MIPS_ARCH_1     0x00000000  /* -mips1 code.  */
1556 +#define EF_MIPS_ARCH_2     0x10000000  /* -mips2 code.  */
1557 +#define EF_MIPS_ARCH_3     0x20000000  /* -mips3 code.  */
1558 +#define EF_MIPS_ARCH_4     0x30000000  /* -mips4 code.  */
1559 +#define EF_MIPS_ARCH_5     0x40000000  /* -mips5 code.  */
1560 +#define EF_MIPS_ARCH_32            0x60000000  /* MIPS32 code.  */
1561 +#define EF_MIPS_ARCH_64            0x70000000  /* MIPS64 code.  */
1563 +/* The following are non-official names and should not be used.  */
1565 +#define E_MIPS_ARCH_1    0x00000000    /* -mips1 code.  */
1566 +#define E_MIPS_ARCH_2    0x10000000    /* -mips2 code.  */
1567 +#define E_MIPS_ARCH_3    0x20000000    /* -mips3 code.  */
1568 +#define E_MIPS_ARCH_4    0x30000000    /* -mips4 code.  */
1569 +#define E_MIPS_ARCH_5    0x40000000    /* -mips5 code.  */
1570 +#define E_MIPS_ARCH_32   0x60000000    /* MIPS32 code.  */
1571 +#define E_MIPS_ARCH_64   0x70000000    /* MIPS64 code.  */
1573 +/* Special section indices.  */
1575 +#define SHN_MIPS_ACOMMON    0xff00     /* Allocated common symbols */
1576 +#define SHN_MIPS_TEXT      0xff01      /* Allocated test symbols.  */
1577 +#define SHN_MIPS_DATA      0xff02      /* Allocated data symbols.  */
1578 +#define SHN_MIPS_SCOMMON    0xff03     /* Small common symbols */
1579 +#define SHN_MIPS_SUNDEFINED 0xff04     /* Small undefined symbols */
1581 +/* Legal values for sh_type field of Elf32_Shdr.  */
1583 +#define SHT_MIPS_LIBLIST       0x70000000 /* Shared objects used in link */
1584 +#define SHT_MIPS_MSYM         0x70000001
1585 +#define SHT_MIPS_CONFLICT      0x70000002 /* Conflicting symbols */
1586 +#define SHT_MIPS_GPTAB        0x70000003 /* Global data area sizes */
1587 +#define SHT_MIPS_UCODE        0x70000004 /* Reserved for SGI/MIPS compilers */
1588 +#define SHT_MIPS_DEBUG        0x70000005 /* MIPS ECOFF debugging information*/
1589 +#define SHT_MIPS_REGINFO       0x70000006 /* Register usage information */
1590 +#define SHT_MIPS_PACKAGE       0x70000007
1591 +#define SHT_MIPS_PACKSYM       0x70000008
1592 +#define SHT_MIPS_RELD         0x70000009
1593 +#define SHT_MIPS_IFACE         0x7000000b
1594 +#define SHT_MIPS_CONTENT       0x7000000c
1595 +#define SHT_MIPS_OPTIONS       0x7000000d /* Miscellaneous options.  */
1596 +#define SHT_MIPS_SHDR         0x70000010
1597 +#define SHT_MIPS_FDESC        0x70000011
1598 +#define SHT_MIPS_EXTSYM               0x70000012
1599 +#define SHT_MIPS_DENSE        0x70000013
1600 +#define SHT_MIPS_PDESC        0x70000014
1601 +#define SHT_MIPS_LOCSYM               0x70000015
1602 +#define SHT_MIPS_AUXSYM               0x70000016
1603 +#define SHT_MIPS_OPTSYM               0x70000017
1604 +#define SHT_MIPS_LOCSTR               0x70000018
1605 +#define SHT_MIPS_LINE         0x70000019
1606 +#define SHT_MIPS_RFDESC               0x7000001a
1607 +#define SHT_MIPS_DELTASYM      0x7000001b
1608 +#define SHT_MIPS_DELTAINST     0x7000001c
1609 +#define SHT_MIPS_DELTACLASS    0x7000001d
1610 +#define SHT_MIPS_DWARF         0x7000001e /* DWARF debugging information.  */
1611 +#define SHT_MIPS_DELTADECL     0x7000001f
1612 +#define SHT_MIPS_SYMBOL_LIB    0x70000020
1613 +#define SHT_MIPS_EVENTS               0x70000021 /* Event section.  */
1614 +#define SHT_MIPS_TRANSLATE     0x70000022
1615 +#define SHT_MIPS_PIXIE        0x70000023
1616 +#define SHT_MIPS_XLATE        0x70000024
1617 +#define SHT_MIPS_XLATE_DEBUG   0x70000025
1618 +#define SHT_MIPS_WHIRL        0x70000026
1619 +#define SHT_MIPS_EH_REGION     0x70000027
1620 +#define SHT_MIPS_XLATE_OLD     0x70000028
1621 +#define SHT_MIPS_PDR_EXCEPTION 0x70000029
1623 +/* Legal values for sh_flags field of Elf32_Shdr.  */
1625 +#define SHF_MIPS_GPREL  0x10000000     /* Must be part of global data area */
1626 +#define SHF_MIPS_MERGE  0x20000000
1627 +#define SHF_MIPS_ADDR   0x40000000
1628 +#define SHF_MIPS_STRINGS 0x80000000
1629 +#define SHF_MIPS_NOSTRIP 0x08000000
1630 +#define SHF_MIPS_LOCAL  0x04000000
1631 +#define SHF_MIPS_NAMES  0x02000000
1632 +#define SHF_MIPS_NODUPE         0x01000000
1635 +/* Symbol tables.  */
1637 +/* MIPS specific values for `st_other'.  */
1638 +#define STO_MIPS_DEFAULT               0x0
1639 +#define STO_MIPS_INTERNAL              0x1
1640 +#define STO_MIPS_HIDDEN                        0x2
1641 +#define STO_MIPS_PROTECTED             0x3
1642 +#define STO_MIPS_SC_ALIGN_UNUSED       0xff
1644 +/* MIPS specific values for `st_info'.  */
1645 +#define STB_MIPS_SPLIT_COMMON          13
1647 +/* Entries found in sections of type SHT_MIPS_GPTAB.  */
1649 +typedef union
1651 +  struct
1652 +    {
1653 +      Elf32_Word gt_current_g_value;   /* -G value used for compilation */
1654 +      Elf32_Word gt_unused;            /* Not used */
1655 +    } gt_header;                       /* First entry in section */
1656 +  struct
1657 +    {
1658 +      Elf32_Word gt_g_value;           /* If this value were used for -G */
1659 +      Elf32_Word gt_bytes;             /* This many bytes would be used */
1660 +    } gt_entry;                                /* Subsequent entries in section */
1661 +} Elf32_gptab;
1663 +/* Entry found in sections of type SHT_MIPS_REGINFO.  */
1665 +typedef struct
1667 +  Elf32_Word   ri_gprmask;             /* General registers used */
1668 +  Elf32_Word   ri_cprmask[4];          /* Coprocessor registers used */
1669 +  Elf32_Sword  ri_gp_value;            /* $gp register value */
1670 +} Elf32_RegInfo;
1672 +/* Entries found in sections of type SHT_MIPS_OPTIONS.  */
1674 +typedef struct
1676 +  unsigned char kind;          /* Determines interpretation of the
1677 +                                  variable part of descriptor.  */
1678 +  unsigned char size;          /* Size of descriptor, including header.  */
1679 +  Elf32_Section section;       /* Section header index of section affected,
1680 +                                  0 for global options.  */
1681 +  Elf32_Word info;             /* Kind-specific information.  */
1682 +} Elf_Options;
1684 +/* Values for `kind' field in Elf_Options.  */
1686 +#define ODK_NULL       0       /* Undefined.  */
1687 +#define ODK_REGINFO    1       /* Register usage information.  */
1688 +#define ODK_EXCEPTIONS 2       /* Exception processing options.  */
1689 +#define ODK_PAD                3       /* Section padding options.  */
1690 +#define ODK_HWPATCH    4       /* Hardware workarounds performed */
1691 +#define ODK_FILL       5       /* record the fill value used by the linker. */
1692 +#define ODK_TAGS       6       /* reserve space for desktop tools to write. */
1693 +#define ODK_HWAND      7       /* HW workarounds.  'AND' bits when merging. */
1694 +#define ODK_HWOR       8       /* HW workarounds.  'OR' bits when merging.  */
1696 +/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries.  */
1698 +#define OEX_FPU_MIN    0x1f    /* FPE's which MUST be enabled.  */
1699 +#define OEX_FPU_MAX    0x1f00  /* FPE's which MAY be enabled.  */
1700 +#define OEX_PAGE0      0x10000 /* page zero must be mapped.  */
1701 +#define OEX_SMM                0x20000 /* Force sequential memory mode?  */
1702 +#define OEX_FPDBUG     0x40000 /* Force floating point debug mode?  */
1703 +#define OEX_PRECISEFP  OEX_FPDBUG
1704 +#define OEX_DISMISS    0x80000 /* Dismiss invalid address faults?  */
1706 +#define OEX_FPU_INVAL  0x10
1707 +#define OEX_FPU_DIV0   0x08
1708 +#define OEX_FPU_OFLO   0x04
1709 +#define OEX_FPU_UFLO   0x02
1710 +#define OEX_FPU_INEX   0x01
1712 +/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry.  */
1714 +#define OHW_R4KEOP     0x1     /* R4000 end-of-page patch.  */
1715 +#define OHW_R8KPFETCH  0x2     /* may need R8000 prefetch patch.  */
1716 +#define OHW_R5KEOP     0x4     /* R5000 end-of-page patch.  */
1717 +#define OHW_R5KCVTL    0x8     /* R5000 cvt.[ds].l bug.  clean=1.  */
1719 +#define OPAD_PREFIX    0x1
1720 +#define OPAD_POSTFIX   0x2
1721 +#define OPAD_SYMBOL    0x4
1723 +/* Entry found in `.options' section.  */
1725 +typedef struct
1727 +  Elf32_Word hwp_flags1;       /* Extra flags.  */
1728 +  Elf32_Word hwp_flags2;       /* Extra flags.  */
1729 +} Elf_Options_Hw;
1731 +/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries.  */
1733 +#define OHWA0_R4KEOP_CHECKED   0x00000001
1734 +#define OHWA1_R4KEOP_CLEAN     0x00000002
1736 +/* MIPS relocs.  */
1738 +#define R_MIPS_NONE            0       /* No reloc */
1739 +#define R_MIPS_16              1       /* Direct 16 bit */
1740 +#define R_MIPS_32              2       /* Direct 32 bit */
1741 +#define R_MIPS_REL32           3       /* PC relative 32 bit */
1742 +#define R_MIPS_26              4       /* Direct 26 bit shifted */
1743 +#define R_MIPS_HI16            5       /* High 16 bit */
1744 +#define R_MIPS_LO16            6       /* Low 16 bit */
1745 +#define R_MIPS_GPREL16         7       /* GP relative 16 bit */
1746 +#define R_MIPS_LITERAL         8       /* 16 bit literal entry */
1747 +#define R_MIPS_GOT16           9       /* 16 bit GOT entry */
1748 +#define R_MIPS_PC16            10      /* PC relative 16 bit */
1749 +#define R_MIPS_CALL16          11      /* 16 bit GOT entry for function */
1750 +#define R_MIPS_GPREL32         12      /* GP relative 32 bit */
1752 +#define R_MIPS_SHIFT5          16
1753 +#define R_MIPS_SHIFT6          17
1754 +#define R_MIPS_64              18
1755 +#define R_MIPS_GOT_DISP                19
1756 +#define R_MIPS_GOT_PAGE                20
1757 +#define R_MIPS_GOT_OFST                21
1758 +#define R_MIPS_GOT_HI16                22
1759 +#define R_MIPS_GOT_LO16                23
1760 +#define R_MIPS_SUB             24
1761 +#define R_MIPS_INSERT_A                25
1762 +#define R_MIPS_INSERT_B                26
1763 +#define R_MIPS_DELETE          27
1764 +#define R_MIPS_HIGHER          28
1765 +#define R_MIPS_HIGHEST         29
1766 +#define R_MIPS_CALL_HI16       30
1767 +#define R_MIPS_CALL_LO16       31
1768 +#define R_MIPS_SCN_DISP                32
1769 +#define R_MIPS_REL16           33
1770 +#define R_MIPS_ADD_IMMEDIATE   34
1771 +#define R_MIPS_PJUMP           35
1772 +#define R_MIPS_RELGOT          36
1773 +#define R_MIPS_JALR            37
1774 +#define R_MIPS_TLS_DTPMOD32    38      /* Module number 32 bit */
1775 +#define R_MIPS_TLS_DTPREL32    39      /* Module-relative offset 32 bit */
1776 +#define R_MIPS_TLS_DTPMOD64    40      /* Module number 64 bit */
1777 +#define R_MIPS_TLS_DTPREL64    41      /* Module-relative offset 64 bit */
1778 +#define R_MIPS_TLS_GD          42      /* 16 bit GOT offset for GD */
1779 +#define R_MIPS_TLS_LDM         43      /* 16 bit GOT offset for LDM */
1780 +#define R_MIPS_TLS_DTPREL_HI16 44      /* Module-relative offset, high 16 bits */
1781 +#define R_MIPS_TLS_DTPREL_LO16 45      /* Module-relative offset, low 16 bits */
1782 +#define R_MIPS_TLS_GOTTPREL    46      /* 16 bit GOT offset for IE */
1783 +#define R_MIPS_TLS_TPREL32     47      /* TP-relative offset, 32 bit */
1784 +#define R_MIPS_TLS_TPREL64     48      /* TP-relative offset, 64 bit */
1785 +#define R_MIPS_TLS_TPREL_HI16  49      /* TP-relative offset, high 16 bits */
1786 +#define R_MIPS_TLS_TPREL_LO16  50      /* TP-relative offset, low 16 bits */
1787 +/* Keep this the last entry.  */
1788 +#define R_MIPS_NUM             51
1790 +/* Legal values for p_type field of Elf32_Phdr.  */
1792 +#define PT_MIPS_REGINFO        0x70000000      /* Register usage information */
1793 +#define PT_MIPS_RTPROC  0x70000001     /* Runtime procedure table. */
1794 +#define PT_MIPS_OPTIONS 0x70000002
1796 +/* Special program header types.  */
1798 +#define PF_MIPS_LOCAL  0x10000000
1800 +/* Legal values for d_tag field of Elf32_Dyn.  */
1802 +#define DT_MIPS_RLD_VERSION  0x70000001        /* Runtime linker interface version */
1803 +#define DT_MIPS_TIME_STAMP   0x70000002        /* Timestamp */
1804 +#define DT_MIPS_ICHECKSUM    0x70000003        /* Checksum */
1805 +#define DT_MIPS_IVERSION     0x70000004        /* Version string (string tbl index) */
1806 +#define DT_MIPS_FLAGS       0x70000005 /* Flags */
1807 +#define DT_MIPS_BASE_ADDRESS 0x70000006        /* Base address */
1808 +#define DT_MIPS_MSYM        0x70000007
1809 +#define DT_MIPS_CONFLICT     0x70000008        /* Address of CONFLICT section */
1810 +#define DT_MIPS_LIBLIST             0x70000009 /* Address of LIBLIST section */
1811 +#define DT_MIPS_LOCAL_GOTNO  0x7000000a        /* Number of local GOT entries */
1812 +#define DT_MIPS_CONFLICTNO   0x7000000b        /* Number of CONFLICT entries */
1813 +#define DT_MIPS_LIBLISTNO    0x70000010        /* Number of LIBLIST entries */
1814 +#define DT_MIPS_SYMTABNO     0x70000011        /* Number of DYNSYM entries */
1815 +#define DT_MIPS_UNREFEXTNO   0x70000012        /* First external DYNSYM */
1816 +#define DT_MIPS_GOTSYM      0x70000013 /* First GOT entry in DYNSYM */
1817 +#define DT_MIPS_HIPAGENO     0x70000014        /* Number of GOT page table entries */
1818 +#define DT_MIPS_RLD_MAP             0x70000016 /* Address of run time loader map.  */
1819 +#define DT_MIPS_DELTA_CLASS  0x70000017        /* Delta C++ class definition.  */
1820 +#define DT_MIPS_DELTA_CLASS_NO    0x70000018 /* Number of entries in
1821 +                                               DT_MIPS_DELTA_CLASS.  */
1822 +#define DT_MIPS_DELTA_INSTANCE    0x70000019 /* Delta C++ class instances.  */
1823 +#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
1824 +                                               DT_MIPS_DELTA_INSTANCE.  */
1825 +#define DT_MIPS_DELTA_RELOC  0x7000001b /* Delta relocations.  */
1826 +#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
1827 +                                            DT_MIPS_DELTA_RELOC.  */
1828 +#define DT_MIPS_DELTA_SYM    0x7000001d /* Delta symbols that Delta
1829 +                                          relocations refer to.  */
1830 +#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
1831 +                                          DT_MIPS_DELTA_SYM.  */
1832 +#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
1833 +                                            class declaration.  */
1834 +#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
1835 +                                               DT_MIPS_DELTA_CLASSSYM.  */
1836 +#define DT_MIPS_CXX_FLAGS    0x70000022 /* Flags indicating for C++ flavor.  */
1837 +#define DT_MIPS_PIXIE_INIT   0x70000023
1838 +#define DT_MIPS_SYMBOL_LIB   0x70000024
1839 +#define DT_MIPS_LOCALPAGE_GOTIDX 0x70000025
1840 +#define DT_MIPS_LOCAL_GOTIDX 0x70000026
1841 +#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
1842 +#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
1843 +#define DT_MIPS_OPTIONS             0x70000029 /* Address of .options.  */
1844 +#define DT_MIPS_INTERFACE    0x7000002a /* Address of .interface.  */
1845 +#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
1846 +#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
1847 +#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
1848 +                                                   function stored in GOT.  */
1849 +#define DT_MIPS_PERF_SUFFIX  0x7000002e /* Default suffix of dso to be added
1850 +                                          by rld on dlopen() calls.  */
1851 +#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
1852 +#define DT_MIPS_GP_VALUE     0x70000030 /* GP value for aux GOTs.  */
1853 +#define DT_MIPS_AUX_DYNAMIC  0x70000031 /* Address of aux .dynamic.  */
1854 +#define DT_MIPS_NUM         0x32
1856 +/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry.  */
1858 +#define RHF_NONE                  0            /* No flags */
1859 +#define RHF_QUICKSTART            (1 << 0)     /* Use quickstart */
1860 +#define RHF_NOTPOT                (1 << 1)     /* Hash size not power of 2 */
1861 +#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2)    /* Ignore LD_LIBRARY_PATH */
1862 +#define RHF_NO_MOVE               (1 << 3)
1863 +#define RHF_SGI_ONLY              (1 << 4)
1864 +#define RHF_GUARANTEE_INIT        (1 << 5)
1865 +#define RHF_DELTA_C_PLUS_PLUS     (1 << 6)
1866 +#define RHF_GUARANTEE_START_INIT   (1 << 7)
1867 +#define RHF_PIXIE                 (1 << 8)
1868 +#define RHF_DEFAULT_DELAY_LOAD    (1 << 9)
1869 +#define RHF_REQUICKSTART          (1 << 10)
1870 +#define RHF_REQUICKSTARTED        (1 << 11)
1871 +#define RHF_CORD                  (1 << 12)
1872 +#define RHF_NO_UNRES_UNDEF        (1 << 13)
1873 +#define RHF_RLD_ORDER_SAFE        (1 << 14)
1875 +/* Entries found in sections of type SHT_MIPS_LIBLIST.  */
1877 +typedef struct
1879 +  Elf32_Word l_name;           /* Name (string table index) */
1880 +  Elf32_Word l_time_stamp;     /* Timestamp */
1881 +  Elf32_Word l_checksum;       /* Checksum */
1882 +  Elf32_Word l_version;                /* Interface version */
1883 +  Elf32_Word l_flags;          /* Flags */
1884 +} Elf32_Lib;
1886 +typedef struct
1888 +  Elf64_Word l_name;           /* Name (string table index) */
1889 +  Elf64_Word l_time_stamp;     /* Timestamp */
1890 +  Elf64_Word l_checksum;       /* Checksum */
1891 +  Elf64_Word l_version;                /* Interface version */
1892 +  Elf64_Word l_flags;          /* Flags */
1893 +} Elf64_Lib;
1896 +/* Legal values for l_flags.  */
1898 +#define LL_NONE                  0
1899 +#define LL_EXACT_MATCH   (1 << 0)      /* Require exact match */
1900 +#define LL_IGNORE_INT_VER (1 << 1)     /* Ignore interface version */
1901 +#define LL_REQUIRE_MINOR  (1 << 2)
1902 +#define LL_EXPORTS       (1 << 3)
1903 +#define LL_DELAY_LOAD    (1 << 4)
1904 +#define LL_DELTA         (1 << 5)
1906 +/* Entries found in sections of type SHT_MIPS_CONFLICT.  */
1908 +typedef Elf32_Addr Elf32_Conflict;
1911 +/* HPPA specific definitions.  */
1913 +/* Legal values for e_flags field of Elf32_Ehdr.  */
1915 +#define EF_PARISC_TRAPNIL      0x00010000 /* Trap nil pointer dereference.  */
1916 +#define EF_PARISC_EXT          0x00020000 /* Program uses arch. extensions. */
1917 +#define EF_PARISC_LSB          0x00040000 /* Program expects little endian. */
1918 +#define EF_PARISC_WIDE         0x00080000 /* Program expects wide mode.  */
1919 +#define EF_PARISC_NO_KABP      0x00100000 /* No kernel assisted branch
1920 +                                             prediction.  */
1921 +#define EF_PARISC_LAZYSWAP     0x00400000 /* Allow lazy swapping.  */
1922 +#define EF_PARISC_ARCH         0x0000ffff /* Architecture version.  */
1924 +/* Defined values for `e_flags & EF_PARISC_ARCH' are:  */
1926 +#define EFA_PARISC_1_0             0x020b /* PA-RISC 1.0 big-endian.  */
1927 +#define EFA_PARISC_1_1             0x0210 /* PA-RISC 1.1 big-endian.  */
1928 +#define EFA_PARISC_2_0             0x0214 /* PA-RISC 2.0 big-endian.  */
1930 +/* Additional section indeces.  */
1932 +#define SHN_PARISC_ANSI_COMMON 0xff00     /* Section for tenatively declared
1933 +                                             symbols in ANSI C.  */
1934 +#define SHN_PARISC_HUGE_COMMON 0xff01     /* Common blocks in huge model.  */
1936 +/* Legal values for sh_type field of Elf32_Shdr.  */
1938 +#define SHT_PARISC_EXT         0x70000000 /* Contains product specific ext. */
1939 +#define SHT_PARISC_UNWIND      0x70000001 /* Unwind information.  */
1940 +#define SHT_PARISC_DOC         0x70000002 /* Debug info for optimized code. */
1942 +/* Legal values for sh_flags field of Elf32_Shdr.  */
1944 +#define SHF_PARISC_SHORT       0x20000000 /* Section with short addressing. */
1945 +#define SHF_PARISC_HUGE                0x40000000 /* Section far from gp.  */
1946 +#define SHF_PARISC_SBP         0x80000000 /* Static branch prediction code. */
1948 +/* Legal values for ST_TYPE subfield of st_info (symbol type).  */
1950 +#define STT_PARISC_MILLICODE   13      /* Millicode function entry point.  */
1952 +#define STT_HP_OPAQUE          (STT_LOOS + 0x1)
1953 +#define STT_HP_STUB            (STT_LOOS + 0x2)
1955 +/* HPPA relocs.  */
1957 +#define R_PARISC_NONE          0       /* No reloc.  */
1958 +#define R_PARISC_DIR32         1       /* Direct 32-bit reference.  */
1959 +#define R_PARISC_DIR21L                2       /* Left 21 bits of eff. address.  */
1960 +#define R_PARISC_DIR17R                3       /* Right 17 bits of eff. address.  */
1961 +#define R_PARISC_DIR17F                4       /* 17 bits of eff. address.  */
1962 +#define R_PARISC_DIR14R                6       /* Right 14 bits of eff. address.  */
1963 +#define R_PARISC_PCREL32       9       /* 32-bit rel. address.  */
1964 +#define R_PARISC_PCREL21L      10      /* Left 21 bits of rel. address.  */
1965 +#define R_PARISC_PCREL17R      11      /* Right 17 bits of rel. address.  */
1966 +#define R_PARISC_PCREL17F      12      /* 17 bits of rel. address.  */
1967 +#define R_PARISC_PCREL14R      14      /* Right 14 bits of rel. address.  */
1968 +#define R_PARISC_DPREL21L      18      /* Left 21 bits of rel. address.  */
1969 +#define R_PARISC_DPREL14R      22      /* Right 14 bits of rel. address.  */
1970 +#define R_PARISC_GPREL21L      26      /* GP-relative, left 21 bits.  */
1971 +#define R_PARISC_GPREL14R      30      /* GP-relative, right 14 bits.  */
1972 +#define R_PARISC_LTOFF21L      34      /* LT-relative, left 21 bits.  */
1973 +#define R_PARISC_LTOFF14R      38      /* LT-relative, right 14 bits.  */
1974 +#define R_PARISC_SECREL32      41      /* 32 bits section rel. address.  */
1975 +#define R_PARISC_SEGBASE       48      /* No relocation, set segment base.  */
1976 +#define R_PARISC_SEGREL32      49      /* 32 bits segment rel. address.  */
1977 +#define R_PARISC_PLTOFF21L     50      /* PLT rel. address, left 21 bits.  */
1978 +#define R_PARISC_PLTOFF14R     54      /* PLT rel. address, right 14 bits.  */
1979 +#define R_PARISC_LTOFF_FPTR32  57      /* 32 bits LT-rel. function pointer. */
1980 +#define R_PARISC_LTOFF_FPTR21L 58      /* LT-rel. fct ptr, left 21 bits. */
1981 +#define R_PARISC_LTOFF_FPTR14R 62      /* LT-rel. fct ptr, right 14 bits. */
1982 +#define R_PARISC_FPTR64                64      /* 64 bits function address.  */
1983 +#define R_PARISC_PLABEL32      65      /* 32 bits function address.  */
1984 +#define R_PARISC_PCREL64       72      /* 64 bits PC-rel. address.  */
1985 +#define R_PARISC_PCREL22F      74      /* 22 bits PC-rel. address.  */
1986 +#define R_PARISC_PCREL14WR     75      /* PC-rel. address, right 14 bits.  */
1987 +#define R_PARISC_PCREL14DR     76      /* PC rel. address, right 14 bits.  */
1988 +#define R_PARISC_PCREL16F      77      /* 16 bits PC-rel. address.  */
1989 +#define R_PARISC_PCREL16WF     78      /* 16 bits PC-rel. address.  */
1990 +#define R_PARISC_PCREL16DF     79      /* 16 bits PC-rel. address.  */
1991 +#define R_PARISC_DIR64         80      /* 64 bits of eff. address.  */
1992 +#define R_PARISC_DIR14WR       83      /* 14 bits of eff. address.  */
1993 +#define R_PARISC_DIR14DR       84      /* 14 bits of eff. address.  */
1994 +#define R_PARISC_DIR16F                85      /* 16 bits of eff. address.  */
1995 +#define R_PARISC_DIR16WF       86      /* 16 bits of eff. address.  */
1996 +#define R_PARISC_DIR16DF       87      /* 16 bits of eff. address.  */
1997 +#define R_PARISC_GPREL64       88      /* 64 bits of GP-rel. address.  */
1998 +#define R_PARISC_GPREL14WR     91      /* GP-rel. address, right 14 bits.  */
1999 +#define R_PARISC_GPREL14DR     92      /* GP-rel. address, right 14 bits.  */
2000 +#define R_PARISC_GPREL16F      93      /* 16 bits GP-rel. address.  */
2001 +#define R_PARISC_GPREL16WF     94      /* 16 bits GP-rel. address.  */
2002 +#define R_PARISC_GPREL16DF     95      /* 16 bits GP-rel. address.  */
2003 +#define R_PARISC_LTOFF64       96      /* 64 bits LT-rel. address.  */
2004 +#define R_PARISC_LTOFF14WR     99      /* LT-rel. address, right 14 bits.  */
2005 +#define R_PARISC_LTOFF14DR     100     /* LT-rel. address, right 14 bits.  */
2006 +#define R_PARISC_LTOFF16F      101     /* 16 bits LT-rel. address.  */
2007 +#define R_PARISC_LTOFF16WF     102     /* 16 bits LT-rel. address.  */
2008 +#define R_PARISC_LTOFF16DF     103     /* 16 bits LT-rel. address.  */
2009 +#define R_PARISC_SECREL64      104     /* 64 bits section rel. address.  */
2010 +#define R_PARISC_SEGREL64      112     /* 64 bits segment rel. address.  */
2011 +#define R_PARISC_PLTOFF14WR    115     /* PLT-rel. address, right 14 bits.  */
2012 +#define R_PARISC_PLTOFF14DR    116     /* PLT-rel. address, right 14 bits.  */
2013 +#define R_PARISC_PLTOFF16F     117     /* 16 bits LT-rel. address.  */
2014 +#define R_PARISC_PLTOFF16WF    118     /* 16 bits PLT-rel. address.  */
2015 +#define R_PARISC_PLTOFF16DF    119     /* 16 bits PLT-rel. address.  */
2016 +#define R_PARISC_LTOFF_FPTR64  120     /* 64 bits LT-rel. function ptr.  */
2017 +#define R_PARISC_LTOFF_FPTR14WR        123     /* LT-rel. fct. ptr., right 14 bits. */
2018 +#define R_PARISC_LTOFF_FPTR14DR        124     /* LT-rel. fct. ptr., right 14 bits. */
2019 +#define R_PARISC_LTOFF_FPTR16F 125     /* 16 bits LT-rel. function ptr.  */
2020 +#define R_PARISC_LTOFF_FPTR16WF        126     /* 16 bits LT-rel. function ptr.  */
2021 +#define R_PARISC_LTOFF_FPTR16DF        127     /* 16 bits LT-rel. function ptr.  */
2022 +#define R_PARISC_LORESERVE     128
2023 +#define R_PARISC_COPY          128     /* Copy relocation.  */
2024 +#define R_PARISC_IPLT          129     /* Dynamic reloc, imported PLT */
2025 +#define R_PARISC_EPLT          130     /* Dynamic reloc, exported PLT */
2026 +#define R_PARISC_TPREL32       153     /* 32 bits TP-rel. address.  */
2027 +#define R_PARISC_TPREL21L      154     /* TP-rel. address, left 21 bits.  */
2028 +#define R_PARISC_TPREL14R      158     /* TP-rel. address, right 14 bits.  */
2029 +#define R_PARISC_LTOFF_TP21L   162     /* LT-TP-rel. address, left 21 bits. */
2030 +#define R_PARISC_LTOFF_TP14R   166     /* LT-TP-rel. address, right 14 bits.*/
2031 +#define R_PARISC_LTOFF_TP14F   167     /* 14 bits LT-TP-rel. address.  */
2032 +#define R_PARISC_TPREL64       216     /* 64 bits TP-rel. address.  */
2033 +#define R_PARISC_TPREL14WR     219     /* TP-rel. address, right 14 bits.  */
2034 +#define R_PARISC_TPREL14DR     220     /* TP-rel. address, right 14 bits.  */
2035 +#define R_PARISC_TPREL16F      221     /* 16 bits TP-rel. address.  */
2036 +#define R_PARISC_TPREL16WF     222     /* 16 bits TP-rel. address.  */
2037 +#define R_PARISC_TPREL16DF     223     /* 16 bits TP-rel. address.  */
2038 +#define R_PARISC_LTOFF_TP64    224     /* 64 bits LT-TP-rel. address.  */
2039 +#define R_PARISC_LTOFF_TP14WR  227     /* LT-TP-rel. address, right 14 bits.*/
2040 +#define R_PARISC_LTOFF_TP14DR  228     /* LT-TP-rel. address, right 14 bits.*/
2041 +#define R_PARISC_LTOFF_TP16F   229     /* 16 bits LT-TP-rel. address.  */
2042 +#define R_PARISC_LTOFF_TP16WF  230     /* 16 bits LT-TP-rel. address.  */
2043 +#define R_PARISC_LTOFF_TP16DF  231     /* 16 bits LT-TP-rel. address.  */
2044 +#define R_PARISC_HIRESERVE     255
2046 +/* Legal values for p_type field of Elf32_Phdr/Elf64_Phdr.  */
2048 +#define PT_HP_TLS              (PT_LOOS + 0x0)
2049 +#define PT_HP_CORE_NONE                (PT_LOOS + 0x1)
2050 +#define PT_HP_CORE_VERSION     (PT_LOOS + 0x2)
2051 +#define PT_HP_CORE_KERNEL      (PT_LOOS + 0x3)
2052 +#define PT_HP_CORE_COMM                (PT_LOOS + 0x4)
2053 +#define PT_HP_CORE_PROC                (PT_LOOS + 0x5)
2054 +#define PT_HP_CORE_LOADABLE    (PT_LOOS + 0x6)
2055 +#define PT_HP_CORE_STACK       (PT_LOOS + 0x7)
2056 +#define PT_HP_CORE_SHM         (PT_LOOS + 0x8)
2057 +#define PT_HP_CORE_MMF         (PT_LOOS + 0x9)
2058 +#define PT_HP_PARALLEL         (PT_LOOS + 0x10)
2059 +#define PT_HP_FASTBIND         (PT_LOOS + 0x11)
2060 +#define PT_HP_OPT_ANNOT                (PT_LOOS + 0x12)
2061 +#define PT_HP_HSL_ANNOT                (PT_LOOS + 0x13)
2062 +#define PT_HP_STACK            (PT_LOOS + 0x14)
2064 +#define PT_PARISC_ARCHEXT      0x70000000
2065 +#define PT_PARISC_UNWIND       0x70000001
2067 +/* Legal values for p_flags field of Elf32_Phdr/Elf64_Phdr.  */
2069 +#define PF_PARISC_SBP          0x08000000
2071 +#define PF_HP_PAGE_SIZE                0x00100000
2072 +#define PF_HP_FAR_SHARED       0x00200000
2073 +#define PF_HP_NEAR_SHARED      0x00400000
2074 +#define PF_HP_CODE             0x01000000
2075 +#define PF_HP_MODIFY           0x02000000
2076 +#define PF_HP_LAZYSWAP         0x04000000
2077 +#define PF_HP_SBP              0x08000000
2080 +/* Alpha specific definitions.  */
2082 +/* Legal values for e_flags field of Elf64_Ehdr.  */
2084 +#define EF_ALPHA_32BIT         1       /* All addresses must be < 2GB.  */
2085 +#define EF_ALPHA_CANRELAX      2       /* Relocations for relaxing exist.  */
2087 +/* Legal values for sh_type field of Elf64_Shdr.  */
2089 +/* These two are primerily concerned with ECOFF debugging info.  */
2090 +#define SHT_ALPHA_DEBUG                0x70000001
2091 +#define SHT_ALPHA_REGINFO      0x70000002
2093 +/* Legal values for sh_flags field of Elf64_Shdr.  */
2095 +#define SHF_ALPHA_GPREL                0x10000000
2097 +/* Legal values for st_other field of Elf64_Sym.  */
2098 +#define STO_ALPHA_NOPV         0x80    /* No PV required.  */
2099 +#define STO_ALPHA_STD_GPLOAD   0x88    /* PV only used for initial ldgp.  */
2101 +/* Alpha relocs.  */
2103 +#define R_ALPHA_NONE           0       /* No reloc */
2104 +#define R_ALPHA_REFLONG                1       /* Direct 32 bit */
2105 +#define R_ALPHA_REFQUAD                2       /* Direct 64 bit */
2106 +#define R_ALPHA_GPREL32                3       /* GP relative 32 bit */
2107 +#define R_ALPHA_LITERAL                4       /* GP relative 16 bit w/optimization */
2108 +#define R_ALPHA_LITUSE         5       /* Optimization hint for LITERAL */
2109 +#define R_ALPHA_GPDISP         6       /* Add displacement to GP */
2110 +#define R_ALPHA_BRADDR         7       /* PC+4 relative 23 bit shifted */
2111 +#define R_ALPHA_HINT           8       /* PC+4 relative 16 bit shifted */
2112 +#define R_ALPHA_SREL16         9       /* PC relative 16 bit */
2113 +#define R_ALPHA_SREL32         10      /* PC relative 32 bit */
2114 +#define R_ALPHA_SREL64         11      /* PC relative 64 bit */
2115 +#define R_ALPHA_GPRELHIGH      17      /* GP relative 32 bit, high 16 bits */
2116 +#define R_ALPHA_GPRELLOW       18      /* GP relative 32 bit, low 16 bits */
2117 +#define R_ALPHA_GPREL16                19      /* GP relative 16 bit */
2118 +#define R_ALPHA_COPY           24      /* Copy symbol at runtime */
2119 +#define R_ALPHA_GLOB_DAT       25      /* Create GOT entry */
2120 +#define R_ALPHA_JMP_SLOT       26      /* Create PLT entry */
2121 +#define R_ALPHA_RELATIVE       27      /* Adjust by program base */
2122 +#define R_ALPHA_TLS_GD_HI      28
2123 +#define R_ALPHA_TLSGD          29
2124 +#define R_ALPHA_TLS_LDM                30
2125 +#define R_ALPHA_DTPMOD64       31
2126 +#define R_ALPHA_GOTDTPREL      32
2127 +#define R_ALPHA_DTPREL64       33
2128 +#define R_ALPHA_DTPRELHI       34
2129 +#define R_ALPHA_DTPRELLO       35
2130 +#define R_ALPHA_DTPREL16       36
2131 +#define R_ALPHA_GOTTPREL       37
2132 +#define R_ALPHA_TPREL64                38
2133 +#define R_ALPHA_TPRELHI                39
2134 +#define R_ALPHA_TPRELLO                40
2135 +#define R_ALPHA_TPREL16                41
2136 +/* Keep this the last entry.  */
2137 +#define R_ALPHA_NUM            46
2139 +/* Magic values of the LITUSE relocation addend.  */
2140 +#define LITUSE_ALPHA_ADDR      0
2141 +#define LITUSE_ALPHA_BASE      1
2142 +#define LITUSE_ALPHA_BYTOFF    2
2143 +#define LITUSE_ALPHA_JSR       3
2144 +#define LITUSE_ALPHA_TLS_GD    4
2145 +#define LITUSE_ALPHA_TLS_LDM   5
2147 +/* Legal values for d_tag of Elf64_Dyn.  */
2148 +#define DT_ALPHA_PLTRO         (DT_LOPROC + 0)
2149 +#define DT_ALPHA_NUM           1
2151 +/* PowerPC specific declarations */
2153 +/* Values for Elf32/64_Ehdr.e_flags.  */
2154 +#define EF_PPC_EMB             0x80000000      /* PowerPC embedded flag */
2156 +/* Cygnus local bits below */
2157 +#define EF_PPC_RELOCATABLE     0x00010000      /* PowerPC -mrelocatable flag*/
2158 +#define EF_PPC_RELOCATABLE_LIB 0x00008000      /* PowerPC -mrelocatable-lib
2159 +                                                  flag */
2161 +/* PowerPC relocations defined by the ABIs */
2162 +#define R_PPC_NONE             0
2163 +#define R_PPC_ADDR32           1       /* 32bit absolute address */
2164 +#define R_PPC_ADDR24           2       /* 26bit address, 2 bits ignored.  */
2165 +#define R_PPC_ADDR16           3       /* 16bit absolute address */
2166 +#define R_PPC_ADDR16_LO                4       /* lower 16bit of absolute address */
2167 +#define R_PPC_ADDR16_HI                5       /* high 16bit of absolute address */
2168 +#define R_PPC_ADDR16_HA                6       /* adjusted high 16bit */
2169 +#define R_PPC_ADDR14           7       /* 16bit address, 2 bits ignored */
2170 +#define R_PPC_ADDR14_BRTAKEN   8
2171 +#define R_PPC_ADDR14_BRNTAKEN  9
2172 +#define R_PPC_REL24            10      /* PC relative 26 bit */
2173 +#define R_PPC_REL14            11      /* PC relative 16 bit */
2174 +#define R_PPC_REL14_BRTAKEN    12
2175 +#define R_PPC_REL14_BRNTAKEN   13
2176 +#define R_PPC_GOT16            14
2177 +#define R_PPC_GOT16_LO         15
2178 +#define R_PPC_GOT16_HI         16
2179 +#define R_PPC_GOT16_HA         17
2180 +#define R_PPC_PLTREL24         18
2181 +#define R_PPC_COPY             19
2182 +#define R_PPC_GLOB_DAT         20
2183 +#define R_PPC_JMP_SLOT         21
2184 +#define R_PPC_RELATIVE         22
2185 +#define R_PPC_LOCAL24PC                23
2186 +#define R_PPC_UADDR32          24
2187 +#define R_PPC_UADDR16          25
2188 +#define R_PPC_REL32            26
2189 +#define R_PPC_PLT32            27
2190 +#define R_PPC_PLTREL32         28
2191 +#define R_PPC_PLT16_LO         29
2192 +#define R_PPC_PLT16_HI         30
2193 +#define R_PPC_PLT16_HA         31
2194 +#define R_PPC_SDAREL16         32
2195 +#define R_PPC_SECTOFF          33
2196 +#define R_PPC_SECTOFF_LO       34
2197 +#define R_PPC_SECTOFF_HI       35
2198 +#define R_PPC_SECTOFF_HA       36
2200 +/* PowerPC relocations defined for the TLS access ABI.  */
2201 +#define R_PPC_TLS              67 /* none      (sym+add)@tls */
2202 +#define R_PPC_DTPMOD32         68 /* word32    (sym+add)@dtpmod */
2203 +#define R_PPC_TPREL16          69 /* half16*   (sym+add)@tprel */
2204 +#define R_PPC_TPREL16_LO       70 /* half16    (sym+add)@tprel@l */
2205 +#define R_PPC_TPREL16_HI       71 /* half16    (sym+add)@tprel@h */
2206 +#define R_PPC_TPREL16_HA       72 /* half16    (sym+add)@tprel@ha */
2207 +#define R_PPC_TPREL32          73 /* word32    (sym+add)@tprel */
2208 +#define R_PPC_DTPREL16         74 /* half16*   (sym+add)@dtprel */
2209 +#define R_PPC_DTPREL16_LO      75 /* half16    (sym+add)@dtprel@l */
2210 +#define R_PPC_DTPREL16_HI      76 /* half16    (sym+add)@dtprel@h */
2211 +#define R_PPC_DTPREL16_HA      77 /* half16    (sym+add)@dtprel@ha */
2212 +#define R_PPC_DTPREL32         78 /* word32    (sym+add)@dtprel */
2213 +#define R_PPC_GOT_TLSGD16      79 /* half16*   (sym+add)@got@tlsgd */
2214 +#define R_PPC_GOT_TLSGD16_LO   80 /* half16    (sym+add)@got@tlsgd@l */
2215 +#define R_PPC_GOT_TLSGD16_HI   81 /* half16    (sym+add)@got@tlsgd@h */
2216 +#define R_PPC_GOT_TLSGD16_HA   82 /* half16    (sym+add)@got@tlsgd@ha */
2217 +#define R_PPC_GOT_TLSLD16      83 /* half16*   (sym+add)@got@tlsld */
2218 +#define R_PPC_GOT_TLSLD16_LO   84 /* half16    (sym+add)@got@tlsld@l */
2219 +#define R_PPC_GOT_TLSLD16_HI   85 /* half16    (sym+add)@got@tlsld@h */
2220 +#define R_PPC_GOT_TLSLD16_HA   86 /* half16    (sym+add)@got@tlsld@ha */
2221 +#define R_PPC_GOT_TPREL16      87 /* half16*   (sym+add)@got@tprel */
2222 +#define R_PPC_GOT_TPREL16_LO   88 /* half16    (sym+add)@got@tprel@l */
2223 +#define R_PPC_GOT_TPREL16_HI   89 /* half16    (sym+add)@got@tprel@h */
2224 +#define R_PPC_GOT_TPREL16_HA   90 /* half16    (sym+add)@got@tprel@ha */
2225 +#define R_PPC_GOT_DTPREL16     91 /* half16*   (sym+add)@got@dtprel */
2226 +#define R_PPC_GOT_DTPREL16_LO  92 /* half16*   (sym+add)@got@dtprel@l */
2227 +#define R_PPC_GOT_DTPREL16_HI  93 /* half16*   (sym+add)@got@dtprel@h */
2228 +#define R_PPC_GOT_DTPREL16_HA  94 /* half16*   (sym+add)@got@dtprel@ha */
2230 +/* Keep this the last entry.  */
2231 +#define R_PPC_NUM              95
2233 +/* The remaining relocs are from the Embedded ELF ABI, and are not
2234 +   in the SVR4 ELF ABI.  */
2235 +#define R_PPC_EMB_NADDR32      101
2236 +#define R_PPC_EMB_NADDR16      102
2237 +#define R_PPC_EMB_NADDR16_LO   103
2238 +#define R_PPC_EMB_NADDR16_HI   104
2239 +#define R_PPC_EMB_NADDR16_HA   105
2240 +#define R_PPC_EMB_SDAI16       106
2241 +#define R_PPC_EMB_SDA2I16      107
2242 +#define R_PPC_EMB_SDA2REL      108
2243 +#define R_PPC_EMB_SDA21                109     /* 16 bit offset in SDA */
2244 +#define R_PPC_EMB_MRKREF       110
2245 +#define R_PPC_EMB_RELSEC16     111
2246 +#define R_PPC_EMB_RELST_LO     112
2247 +#define R_PPC_EMB_RELST_HI     113
2248 +#define R_PPC_EMB_RELST_HA     114
2249 +#define R_PPC_EMB_BIT_FLD      115
2250 +#define R_PPC_EMB_RELSDA       116     /* 16 bit relative offset in SDA */
2252 +/* Diab tool relocations.  */
2253 +#define R_PPC_DIAB_SDA21_LO    180     /* like EMB_SDA21, but lower 16 bit */
2254 +#define R_PPC_DIAB_SDA21_HI    181     /* like EMB_SDA21, but high 16 bit */
2255 +#define R_PPC_DIAB_SDA21_HA    182     /* like EMB_SDA21, adjusted high 16 */
2256 +#define R_PPC_DIAB_RELSDA_LO   183     /* like EMB_RELSDA, but lower 16 bit */
2257 +#define R_PPC_DIAB_RELSDA_HI   184     /* like EMB_RELSDA, but high 16 bit */
2258 +#define R_PPC_DIAB_RELSDA_HA   185     /* like EMB_RELSDA, adjusted high 16 */
2260 +/* GNU relocs used in PIC code sequences.  */
2261 +#define R_PPC_REL16            249     /* word32   (sym-.) */
2262 +#define R_PPC_REL16_LO         250     /* half16   (sym-.)@l */
2263 +#define R_PPC_REL16_HI         251     /* half16   (sym-.)@h */
2264 +#define R_PPC_REL16_HA         252     /* half16   (sym-.)@ha */
2266 +/* This is a phony reloc to handle any old fashioned TOC16 references
2267 +   that may still be in object files.  */
2268 +#define R_PPC_TOC16            255
2270 +/* PowerPC specific values for the Dyn d_tag field.  */
2271 +#define DT_PPC_GOT             (DT_LOPROC + 0)
2272 +#define DT_PPC_NUM             1
2274 +/* PowerPC64 relocations defined by the ABIs */
2275 +#define R_PPC64_NONE           R_PPC_NONE
2276 +#define R_PPC64_ADDR32         R_PPC_ADDR32 /* 32bit absolute address */
2277 +#define R_PPC64_ADDR24         R_PPC_ADDR24 /* 26bit address, word aligned */
2278 +#define R_PPC64_ADDR16         R_PPC_ADDR16 /* 16bit absolute address */
2279 +#define R_PPC64_ADDR16_LO      R_PPC_ADDR16_LO /* lower 16bits of address */
2280 +#define R_PPC64_ADDR16_HI      R_PPC_ADDR16_HI /* high 16bits of address. */
2281 +#define R_PPC64_ADDR16_HA      R_PPC_ADDR16_HA /* adjusted high 16bits.  */
2282 +#define R_PPC64_ADDR14         R_PPC_ADDR14 /* 16bit address, word aligned */
2283 +#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
2284 +#define R_PPC64_ADDR14_BRNTAKEN        R_PPC_ADDR14_BRNTAKEN
2285 +#define R_PPC64_REL24          R_PPC_REL24 /* PC-rel. 26 bit, word aligned */
2286 +#define R_PPC64_REL14          R_PPC_REL14 /* PC relative 16 bit */
2287 +#define R_PPC64_REL14_BRTAKEN  R_PPC_REL14_BRTAKEN
2288 +#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
2289 +#define R_PPC64_GOT16          R_PPC_GOT16
2290 +#define R_PPC64_GOT16_LO       R_PPC_GOT16_LO
2291 +#define R_PPC64_GOT16_HI       R_PPC_GOT16_HI
2292 +#define R_PPC64_GOT16_HA       R_PPC_GOT16_HA
2294 +#define R_PPC64_COPY           R_PPC_COPY
2295 +#define R_PPC64_GLOB_DAT       R_PPC_GLOB_DAT
2296 +#define R_PPC64_JMP_SLOT       R_PPC_JMP_SLOT
2297 +#define R_PPC64_RELATIVE       R_PPC_RELATIVE
2299 +#define R_PPC64_UADDR32                R_PPC_UADDR32
2300 +#define R_PPC64_UADDR16                R_PPC_UADDR16
2301 +#define R_PPC64_REL32          R_PPC_REL32
2302 +#define R_PPC64_PLT32          R_PPC_PLT32
2303 +#define R_PPC64_PLTREL32       R_PPC_PLTREL32
2304 +#define R_PPC64_PLT16_LO       R_PPC_PLT16_LO
2305 +#define R_PPC64_PLT16_HI       R_PPC_PLT16_HI
2306 +#define R_PPC64_PLT16_HA       R_PPC_PLT16_HA
2308 +#define R_PPC64_SECTOFF                R_PPC_SECTOFF
2309 +#define R_PPC64_SECTOFF_LO     R_PPC_SECTOFF_LO
2310 +#define R_PPC64_SECTOFF_HI     R_PPC_SECTOFF_HI
2311 +#define R_PPC64_SECTOFF_HA     R_PPC_SECTOFF_HA
2312 +#define R_PPC64_ADDR30         37 /* word30 (S + A - P) >> 2 */
2313 +#define R_PPC64_ADDR64         38 /* doubleword64 S + A */
2314 +#define R_PPC64_ADDR16_HIGHER  39 /* half16 #higher(S + A) */
2315 +#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A) */
2316 +#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A) */
2317 +#define R_PPC64_ADDR16_HIGHESTA        42 /* half16 #highesta(S + A) */
2318 +#define R_PPC64_UADDR64                43 /* doubleword64 S + A */
2319 +#define R_PPC64_REL64          44 /* doubleword64 S + A - P */
2320 +#define R_PPC64_PLT64          45 /* doubleword64 L + A */
2321 +#define R_PPC64_PLTREL64       46 /* doubleword64 L + A - P */
2322 +#define R_PPC64_TOC16          47 /* half16* S + A - .TOC */
2323 +#define R_PPC64_TOC16_LO       48 /* half16 #lo(S + A - .TOC.) */
2324 +#define R_PPC64_TOC16_HI       49 /* half16 #hi(S + A - .TOC.) */
2325 +#define R_PPC64_TOC16_HA       50 /* half16 #ha(S + A - .TOC.) */
2326 +#define R_PPC64_TOC            51 /* doubleword64 .TOC */
2327 +#define R_PPC64_PLTGOT16       52 /* half16* M + A */
2328 +#define R_PPC64_PLTGOT16_LO    53 /* half16 #lo(M + A) */
2329 +#define R_PPC64_PLTGOT16_HI    54 /* half16 #hi(M + A) */
2330 +#define R_PPC64_PLTGOT16_HA    55 /* half16 #ha(M + A) */
2332 +#define R_PPC64_ADDR16_DS      56 /* half16ds* (S + A) >> 2 */
2333 +#define R_PPC64_ADDR16_LO_DS   57 /* half16ds  #lo(S + A) >> 2 */
2334 +#define R_PPC64_GOT16_DS       58 /* half16ds* (G + A) >> 2 */
2335 +#define R_PPC64_GOT16_LO_DS    59 /* half16ds  #lo(G + A) >> 2 */
2336 +#define R_PPC64_PLT16_LO_DS    60 /* half16ds  #lo(L + A) >> 2 */
2337 +#define R_PPC64_SECTOFF_DS     61 /* half16ds* (R + A) >> 2 */
2338 +#define R_PPC64_SECTOFF_LO_DS  62 /* half16ds  #lo(R + A) >> 2 */
2339 +#define R_PPC64_TOC16_DS       63 /* half16ds* (S + A - .TOC.) >> 2 */
2340 +#define R_PPC64_TOC16_LO_DS    64 /* half16ds  #lo(S + A - .TOC.) >> 2 */
2341 +#define R_PPC64_PLTGOT16_DS    65 /* half16ds* (M + A) >> 2 */
2342 +#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds  #lo(M + A) >> 2 */
2344 +/* PowerPC64 relocations defined for the TLS access ABI.  */
2345 +#define R_PPC64_TLS            67 /* none      (sym+add)@tls */
2346 +#define R_PPC64_DTPMOD64       68 /* doubleword64 (sym+add)@dtpmod */
2347 +#define R_PPC64_TPREL16                69 /* half16*   (sym+add)@tprel */
2348 +#define R_PPC64_TPREL16_LO     70 /* half16    (sym+add)@tprel@l */
2349 +#define R_PPC64_TPREL16_HI     71 /* half16    (sym+add)@tprel@h */
2350 +#define R_PPC64_TPREL16_HA     72 /* half16    (sym+add)@tprel@ha */
2351 +#define R_PPC64_TPREL64                73 /* doubleword64 (sym+add)@tprel */
2352 +#define R_PPC64_DTPREL16       74 /* half16*   (sym+add)@dtprel */
2353 +#define R_PPC64_DTPREL16_LO    75 /* half16    (sym+add)@dtprel@l */
2354 +#define R_PPC64_DTPREL16_HI    76 /* half16    (sym+add)@dtprel@h */
2355 +#define R_PPC64_DTPREL16_HA    77 /* half16    (sym+add)@dtprel@ha */
2356 +#define R_PPC64_DTPREL64       78 /* doubleword64 (sym+add)@dtprel */
2357 +#define R_PPC64_GOT_TLSGD16    79 /* half16*   (sym+add)@got@tlsgd */
2358 +#define R_PPC64_GOT_TLSGD16_LO 80 /* half16    (sym+add)@got@tlsgd@l */
2359 +#define R_PPC64_GOT_TLSGD16_HI 81 /* half16    (sym+add)@got@tlsgd@h */
2360 +#define R_PPC64_GOT_TLSGD16_HA 82 /* half16    (sym+add)@got@tlsgd@ha */
2361 +#define R_PPC64_GOT_TLSLD16    83 /* half16*   (sym+add)@got@tlsld */
2362 +#define R_PPC64_GOT_TLSLD16_LO 84 /* half16    (sym+add)@got@tlsld@l */
2363 +#define R_PPC64_GOT_TLSLD16_HI 85 /* half16    (sym+add)@got@tlsld@h */
2364 +#define R_PPC64_GOT_TLSLD16_HA 86 /* half16    (sym+add)@got@tlsld@ha */
2365 +#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */
2366 +#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
2367 +#define R_PPC64_GOT_TPREL16_HI 89 /* half16    (sym+add)@got@tprel@h */
2368 +#define R_PPC64_GOT_TPREL16_HA 90 /* half16    (sym+add)@got@tprel@ha */
2369 +#define R_PPC64_GOT_DTPREL16_DS        91 /* half16ds* (sym+add)@got@dtprel */
2370 +#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
2371 +#define R_PPC64_GOT_DTPREL16_HI        93 /* half16    (sym+add)@got@dtprel@h */
2372 +#define R_PPC64_GOT_DTPREL16_HA        94 /* half16    (sym+add)@got@dtprel@ha */
2373 +#define R_PPC64_TPREL16_DS     95 /* half16ds* (sym+add)@tprel */
2374 +#define R_PPC64_TPREL16_LO_DS  96 /* half16ds  (sym+add)@tprel@l */
2375 +#define R_PPC64_TPREL16_HIGHER 97 /* half16    (sym+add)@tprel@higher */
2376 +#define R_PPC64_TPREL16_HIGHERA        98 /* half16    (sym+add)@tprel@highera */
2377 +#define R_PPC64_TPREL16_HIGHEST        99 /* half16    (sym+add)@tprel@highest */
2378 +#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */
2379 +#define R_PPC64_DTPREL16_DS    101 /* half16ds* (sym+add)@dtprel */
2380 +#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */
2381 +#define R_PPC64_DTPREL16_HIGHER        103 /* half16   (sym+add)@dtprel@higher */
2382 +#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */
2383 +#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */
2384 +#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16        (sym+add)@dtprel@highesta */
2386 +/* Keep this the last entry.  */
2387 +#define R_PPC64_NUM            107
2389 +/* PowerPC64 specific values for the Dyn d_tag field.  */
2390 +#define DT_PPC64_GLINK  (DT_LOPROC + 0)
2391 +#define DT_PPC64_OPD   (DT_LOPROC + 1)
2392 +#define DT_PPC64_OPDSZ (DT_LOPROC + 2)
2393 +#define DT_PPC64_NUM    3
2396 +/* ARM specific declarations */
2398 +/* Processor specific flags for the ELF header e_flags field.  */
2399 +#define EF_ARM_RELEXEC     0x01
2400 +#define EF_ARM_HASENTRY    0x02
2401 +#define EF_ARM_INTERWORK   0x04
2402 +#define EF_ARM_APCS_26     0x08
2403 +#define EF_ARM_APCS_FLOAT  0x10
2404 +#define EF_ARM_PIC         0x20
2405 +#define EF_ARM_ALIGN8      0x40                /* 8-bit structure alignment is in use */
2406 +#define EF_ARM_NEW_ABI     0x80
2407 +#define EF_ARM_OLD_ABI     0x100
2409 +/* Other constants defined in the ARM ELF spec. version B-01.  */
2410 +/* NB. These conflict with values defined above.  */
2411 +#define EF_ARM_SYMSARESORTED   0x04
2412 +#define EF_ARM_DYNSYMSUSESEGIDX 0x08
2413 +#define EF_ARM_MAPSYMSFIRST    0x10
2414 +#define EF_ARM_EABIMASK                0XFF000000
2416 +#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
2417 +#define EF_ARM_EABI_UNKNOWN  0x00000000
2418 +#define EF_ARM_EABI_VER1     0x01000000
2419 +#define EF_ARM_EABI_VER2     0x02000000
2421 +/* Additional symbol types for Thumb */
2422 +#define STT_ARM_TFUNC      0xd
2424 +/* ARM-specific values for sh_flags */
2425 +#define SHF_ARM_ENTRYSECT  0x10000000   /* Section contains an entry point */
2426 +#define SHF_ARM_COMDEF     0x80000000   /* Section may be multiply defined
2427 +                                          in the input to a link step */
2429 +/* ARM-specific program header flags */
2430 +#define PF_ARM_SB          0x10000000   /* Segment contains the location
2431 +                                          addressed by the static base */
2433 +/* Processor specific values for the Phdr p_type field.  */
2434 +#define PT_ARM_EXIDX   0x70000001      /* .ARM.exidx segment */
2436 +/* ARM relocs.  */
2438 +#define R_ARM_NONE             0       /* No reloc */
2439 +#define R_ARM_PC24             1       /* PC relative 26 bit branch */
2440 +#define R_ARM_ABS32            2       /* Direct 32 bit  */
2441 +#define R_ARM_REL32            3       /* PC relative 32 bit */
2442 +#define R_ARM_PC13             4
2443 +#define R_ARM_ABS16            5       /* Direct 16 bit */
2444 +#define R_ARM_ABS12            6       /* Direct 12 bit */
2445 +#define R_ARM_THM_ABS5         7
2446 +#define R_ARM_ABS8             8       /* Direct 8 bit */
2447 +#define R_ARM_SBREL32          9
2448 +#define R_ARM_THM_PC22         10
2449 +#define R_ARM_THM_PC8          11
2450 +#define R_ARM_AMP_VCALL9       12
2451 +#define R_ARM_SWI24            13
2452 +#define R_ARM_THM_SWI8         14
2453 +#define R_ARM_XPC25            15
2454 +#define R_ARM_THM_XPC22                16
2455 +#define R_ARM_COPY             20      /* Copy symbol at runtime */
2456 +#define R_ARM_GLOB_DAT         21      /* Create GOT entry */
2457 +#define R_ARM_JUMP_SLOT                22      /* Create PLT entry */
2458 +#define R_ARM_RELATIVE         23      /* Adjust by program base */
2459 +#define R_ARM_GOTOFF           24      /* 32 bit offset to GOT */
2460 +#define R_ARM_GOTPC            25      /* 32 bit PC relative offset to GOT */
2461 +#define R_ARM_GOT32            26      /* 32 bit GOT entry */
2462 +#define R_ARM_PLT32            27      /* 32 bit PLT address */
2463 +#define R_ARM_ALU_PCREL_7_0    32
2464 +#define R_ARM_ALU_PCREL_15_8   33
2465 +#define R_ARM_ALU_PCREL_23_15  34
2466 +#define R_ARM_LDR_SBREL_11_0   35
2467 +#define R_ARM_ALU_SBREL_19_12  36
2468 +#define R_ARM_ALU_SBREL_27_20  37
2469 +#define R_ARM_GNU_VTENTRY      100
2470 +#define R_ARM_GNU_VTINHERIT    101
2471 +#define R_ARM_THM_PC11         102     /* thumb unconditional branch */
2472 +#define R_ARM_THM_PC9          103     /* thumb conditional branch */
2473 +#define R_ARM_RXPC25           249
2474 +#define R_ARM_RSBREL32         250
2475 +#define R_ARM_THM_RPC22                251
2476 +#define R_ARM_RREL32           252
2477 +#define R_ARM_RABS22           253
2478 +#define R_ARM_RPC24            254
2479 +#define R_ARM_RBASE            255
2480 +/* Keep this the last entry.  */
2481 +#define R_ARM_NUM              256
2483 +/* IA-64 specific declarations.  */
2485 +/* Processor specific flags for the Ehdr e_flags field.  */
2486 +#define EF_IA_64_MASKOS                0x0000000f      /* os-specific flags */
2487 +#define EF_IA_64_ABI64         0x00000010      /* 64-bit ABI */
2488 +#define EF_IA_64_ARCH          0xff000000      /* arch. version mask */
2490 +/* Processor specific values for the Phdr p_type field.  */
2491 +#define PT_IA_64_ARCHEXT       (PT_LOPROC + 0) /* arch extension bits */
2492 +#define PT_IA_64_UNWIND                (PT_LOPROC + 1) /* ia64 unwind bits */
2493 +#define PT_IA_64_HP_OPT_ANOT   (PT_LOOS + 0x12)
2494 +#define PT_IA_64_HP_HSL_ANOT   (PT_LOOS + 0x13)
2495 +#define PT_IA_64_HP_STACK      (PT_LOOS + 0x14)
2497 +/* Processor specific flags for the Phdr p_flags field.  */
2498 +#define PF_IA_64_NORECOV       0x80000000      /* spec insns w/o recovery */
2500 +/* Processor specific values for the Shdr sh_type field.  */
2501 +#define SHT_IA_64_EXT          (SHT_LOPROC + 0) /* extension bits */
2502 +#define SHT_IA_64_UNWIND       (SHT_LOPROC + 1) /* unwind bits */
2504 +/* Processor specific flags for the Shdr sh_flags field.  */
2505 +#define SHF_IA_64_SHORT                0x10000000      /* section near gp */
2506 +#define SHF_IA_64_NORECOV      0x20000000      /* spec insns w/o recovery */
2508 +/* Processor specific values for the Dyn d_tag field.  */
2509 +#define DT_IA_64_PLT_RESERVE   (DT_LOPROC + 0)
2510 +#define DT_IA_64_NUM           1
2512 +/* IA-64 relocations.  */
2513 +#define R_IA64_NONE            0x00    /* none */
2514 +#define R_IA64_IMM14           0x21    /* symbol + addend, add imm14 */
2515 +#define R_IA64_IMM22           0x22    /* symbol + addend, add imm22 */
2516 +#define R_IA64_IMM64           0x23    /* symbol + addend, mov imm64 */
2517 +#define R_IA64_DIR32MSB                0x24    /* symbol + addend, data4 MSB */
2518 +#define R_IA64_DIR32LSB                0x25    /* symbol + addend, data4 LSB */
2519 +#define R_IA64_DIR64MSB                0x26    /* symbol + addend, data8 MSB */
2520 +#define R_IA64_DIR64LSB                0x27    /* symbol + addend, data8 LSB */
2521 +#define R_IA64_GPREL22         0x2a    /* @gprel(sym + add), add imm22 */
2522 +#define R_IA64_GPREL64I                0x2b    /* @gprel(sym + add), mov imm64 */
2523 +#define R_IA64_GPREL32MSB      0x2c    /* @gprel(sym + add), data4 MSB */
2524 +#define R_IA64_GPREL32LSB      0x2d    /* @gprel(sym + add), data4 LSB */
2525 +#define R_IA64_GPREL64MSB      0x2e    /* @gprel(sym + add), data8 MSB */
2526 +#define R_IA64_GPREL64LSB      0x2f    /* @gprel(sym + add), data8 LSB */
2527 +#define R_IA64_LTOFF22         0x32    /* @ltoff(sym + add), add imm22 */
2528 +#define R_IA64_LTOFF64I                0x33    /* @ltoff(sym + add), mov imm64 */
2529 +#define R_IA64_PLTOFF22                0x3a    /* @pltoff(sym + add), add imm22 */
2530 +#define R_IA64_PLTOFF64I       0x3b    /* @pltoff(sym + add), mov imm64 */
2531 +#define R_IA64_PLTOFF64MSB     0x3e    /* @pltoff(sym + add), data8 MSB */
2532 +#define R_IA64_PLTOFF64LSB     0x3f    /* @pltoff(sym + add), data8 LSB */
2533 +#define R_IA64_FPTR64I         0x43    /* @fptr(sym + add), mov imm64 */
2534 +#define R_IA64_FPTR32MSB       0x44    /* @fptr(sym + add), data4 MSB */
2535 +#define R_IA64_FPTR32LSB       0x45    /* @fptr(sym + add), data4 LSB */
2536 +#define R_IA64_FPTR64MSB       0x46    /* @fptr(sym + add), data8 MSB */
2537 +#define R_IA64_FPTR64LSB       0x47    /* @fptr(sym + add), data8 LSB */
2538 +#define R_IA64_PCREL60B                0x48    /* @pcrel(sym + add), brl */
2539 +#define R_IA64_PCREL21B                0x49    /* @pcrel(sym + add), ptb, call */
2540 +#define R_IA64_PCREL21M                0x4a    /* @pcrel(sym + add), chk.s */
2541 +#define R_IA64_PCREL21F                0x4b    /* @pcrel(sym + add), fchkf */
2542 +#define R_IA64_PCREL32MSB      0x4c    /* @pcrel(sym + add), data4 MSB */
2543 +#define R_IA64_PCREL32LSB      0x4d    /* @pcrel(sym + add), data4 LSB */
2544 +#define R_IA64_PCREL64MSB      0x4e    /* @pcrel(sym + add), data8 MSB */
2545 +#define R_IA64_PCREL64LSB      0x4f    /* @pcrel(sym + add), data8 LSB */
2546 +#define R_IA64_LTOFF_FPTR22    0x52    /* @ltoff(@fptr(s+a)), imm22 */
2547 +#define R_IA64_LTOFF_FPTR64I   0x53    /* @ltoff(@fptr(s+a)), imm64 */
2548 +#define R_IA64_LTOFF_FPTR32MSB 0x54    /* @ltoff(@fptr(s+a)), data4 MSB */
2549 +#define R_IA64_LTOFF_FPTR32LSB 0x55    /* @ltoff(@fptr(s+a)), data4 LSB */
2550 +#define R_IA64_LTOFF_FPTR64MSB 0x56    /* @ltoff(@fptr(s+a)), data8 MSB */
2551 +#define R_IA64_LTOFF_FPTR64LSB 0x57    /* @ltoff(@fptr(s+a)), data8 LSB */
2552 +#define R_IA64_SEGREL32MSB     0x5c    /* @segrel(sym + add), data4 MSB */
2553 +#define R_IA64_SEGREL32LSB     0x5d    /* @segrel(sym + add), data4 LSB */
2554 +#define R_IA64_SEGREL64MSB     0x5e    /* @segrel(sym + add), data8 MSB */
2555 +#define R_IA64_SEGREL64LSB     0x5f    /* @segrel(sym + add), data8 LSB */
2556 +#define R_IA64_SECREL32MSB     0x64    /* @secrel(sym + add), data4 MSB */
2557 +#define R_IA64_SECREL32LSB     0x65    /* @secrel(sym + add), data4 LSB */
2558 +#define R_IA64_SECREL64MSB     0x66    /* @secrel(sym + add), data8 MSB */
2559 +#define R_IA64_SECREL64LSB     0x67    /* @secrel(sym + add), data8 LSB */
2560 +#define R_IA64_REL32MSB                0x6c    /* data 4 + REL */
2561 +#define R_IA64_REL32LSB                0x6d    /* data 4 + REL */
2562 +#define R_IA64_REL64MSB                0x6e    /* data 8 + REL */
2563 +#define R_IA64_REL64LSB                0x6f    /* data 8 + REL */
2564 +#define R_IA64_LTV32MSB                0x74    /* symbol + addend, data4 MSB */
2565 +#define R_IA64_LTV32LSB                0x75    /* symbol + addend, data4 LSB */
2566 +#define R_IA64_LTV64MSB                0x76    /* symbol + addend, data8 MSB */
2567 +#define R_IA64_LTV64LSB                0x77    /* symbol + addend, data8 LSB */
2568 +#define R_IA64_PCREL21BI       0x79    /* @pcrel(sym + add), 21bit inst */
2569 +#define R_IA64_PCREL22         0x7a    /* @pcrel(sym + add), 22bit inst */
2570 +#define R_IA64_PCREL64I                0x7b    /* @pcrel(sym + add), 64bit inst */
2571 +#define R_IA64_IPLTMSB         0x80    /* dynamic reloc, imported PLT, MSB */
2572 +#define R_IA64_IPLTLSB         0x81    /* dynamic reloc, imported PLT, LSB */
2573 +#define R_IA64_COPY            0x84    /* copy relocation */
2574 +#define R_IA64_SUB             0x85    /* Addend and symbol difference */
2575 +#define R_IA64_LTOFF22X                0x86    /* LTOFF22, relaxable.  */
2576 +#define R_IA64_LDXMOV          0x87    /* Use of LTOFF22X.  */
2577 +#define R_IA64_TPREL14         0x91    /* @tprel(sym + add), imm14 */
2578 +#define R_IA64_TPREL22         0x92    /* @tprel(sym + add), imm22 */
2579 +#define R_IA64_TPREL64I                0x93    /* @tprel(sym + add), imm64 */
2580 +#define R_IA64_TPREL64MSB      0x96    /* @tprel(sym + add), data8 MSB */
2581 +#define R_IA64_TPREL64LSB      0x97    /* @tprel(sym + add), data8 LSB */
2582 +#define R_IA64_LTOFF_TPREL22   0x9a    /* @ltoff(@tprel(s+a)), imm2 */
2583 +#define R_IA64_DTPMOD64MSB     0xa6    /* @dtpmod(sym + add), data8 MSB */
2584 +#define R_IA64_DTPMOD64LSB     0xa7    /* @dtpmod(sym + add), data8 LSB */
2585 +#define R_IA64_LTOFF_DTPMOD22  0xaa    /* @ltoff(@dtpmod(sym + add)), imm22 */
2586 +#define R_IA64_DTPREL14                0xb1    /* @dtprel(sym + add), imm14 */
2587 +#define R_IA64_DTPREL22                0xb2    /* @dtprel(sym + add), imm22 */
2588 +#define R_IA64_DTPREL64I       0xb3    /* @dtprel(sym + add), imm64 */
2589 +#define R_IA64_DTPREL32MSB     0xb4    /* @dtprel(sym + add), data4 MSB */
2590 +#define R_IA64_DTPREL32LSB     0xb5    /* @dtprel(sym + add), data4 LSB */
2591 +#define R_IA64_DTPREL64MSB     0xb6    /* @dtprel(sym + add), data8 MSB */
2592 +#define R_IA64_DTPREL64LSB     0xb7    /* @dtprel(sym + add), data8 LSB */
2593 +#define R_IA64_LTOFF_DTPREL22  0xba    /* @ltoff(@dtprel(s+a)), imm22 */
2595 +/* SH specific declarations */
2597 +/* SH specific values for `st_other'.  */
2599 +/* If set, this is a symbol pointing to SHmedia code, which will be branched
2600 +   to, so need to add 1 to the symbol value. */
2601 +#define STO_SH5_ISA32 (1 << 2)
2603 +/* SH relocs.  */
2604 +#define        R_SH_NONE               0
2605 +#define        R_SH_DIR32              1
2606 +#define        R_SH_REL32              2
2607 +#define        R_SH_DIR8WPN            3
2608 +#define        R_SH_IND12W             4
2609 +#define        R_SH_DIR8WPL            5
2610 +#define        R_SH_DIR8WPZ            6
2611 +#define        R_SH_DIR8BP             7
2612 +#define        R_SH_DIR8W              8
2613 +#define        R_SH_DIR8L              9
2614 +#define        R_SH_SWITCH16           25
2615 +#define        R_SH_SWITCH32           26
2616 +#define        R_SH_USES               27
2617 +#define        R_SH_COUNT              28
2618 +#define        R_SH_ALIGN              29
2619 +#define        R_SH_CODE               30
2620 +#define        R_SH_DATA               31
2621 +#define        R_SH_LABEL              32
2622 +#define        R_SH_SWITCH8            33
2623 +#define        R_SH_GNU_VTINHERIT      34
2624 +#define        R_SH_GNU_VTENTRY        35
2625 +#define        R_SH_TLS_GD_32          144
2626 +#define        R_SH_TLS_LD_32          145
2627 +#define        R_SH_TLS_LDO_32         146
2628 +#define        R_SH_TLS_IE_32          147
2629 +#define        R_SH_TLS_LE_32          148
2630 +#define        R_SH_TLS_DTPMOD32       149
2631 +#define        R_SH_TLS_DTPOFF32       150
2632 +#define        R_SH_TLS_TPOFF32        151
2633 +#define        R_SH_GOT32              160
2634 +#define        R_SH_PLT32              161
2635 +#define        R_SH_COPY               162
2636 +#define        R_SH_GLOB_DAT           163
2637 +#define        R_SH_JMP_SLOT           164
2638 +#define        R_SH_RELATIVE           165
2639 +#define        R_SH_GOTOFF             166
2640 +#define        R_SH_GOTPC              167
2641 +#define        R_SH_RELATIVE_LOW16     197
2642 +#define        R_SH_RELATIVE_MEDLOW16  198
2643 +#define        R_SH_IMM_LOW16          246
2644 +#define        R_SH_IMM_LOW16_PCREL    247
2645 +#define        R_SH_IMM_MEDLOW16       248
2646 +#define        R_SH_IMM_MEDLOW16_PCREL 249
2648 +/* Keep this the last entry.  */
2649 +#define        R_SH_NUM                256
2651 +/* Additional s390 relocs */
2653 +#define R_390_NONE             0       /* No reloc.  */
2654 +#define R_390_8                        1       /* Direct 8 bit.  */
2655 +#define R_390_12               2       /* Direct 12 bit.  */
2656 +#define R_390_16               3       /* Direct 16 bit.  */
2657 +#define R_390_32               4       /* Direct 32 bit.  */
2658 +#define R_390_PC32             5       /* PC relative 32 bit.  */
2659 +#define R_390_GOT12            6       /* 12 bit GOT offset.  */
2660 +#define R_390_GOT32            7       /* 32 bit GOT offset.  */
2661 +#define R_390_PLT32            8       /* 32 bit PC relative PLT address.  */
2662 +#define R_390_COPY             9       /* Copy symbol at runtime.  */
2663 +#define R_390_GLOB_DAT         10      /* Create GOT entry.  */
2664 +#define R_390_JMP_SLOT         11      /* Create PLT entry.  */
2665 +#define R_390_RELATIVE         12      /* Adjust by program base.  */
2666 +#define R_390_GOTOFF32         13      /* 32 bit offset to GOT.         */
2667 +#define R_390_GOTPC            14      /* 32 bit PC relative offset to GOT.  */
2668 +#define R_390_GOT16            15      /* 16 bit GOT offset.  */
2669 +#define R_390_PC16             16      /* PC relative 16 bit.  */
2670 +#define R_390_PC16DBL          17      /* PC relative 16 bit shifted by 1.  */
2671 +#define R_390_PLT16DBL         18      /* 16 bit PC rel. PLT shifted by 1.  */
2672 +#define R_390_PC32DBL          19      /* PC relative 32 bit shifted by 1.  */
2673 +#define R_390_PLT32DBL         20      /* 32 bit PC rel. PLT shifted by 1.  */
2674 +#define R_390_GOTPCDBL         21      /* 32 bit PC rel. GOT shifted by 1.  */
2675 +#define R_390_64               22      /* Direct 64 bit.  */
2676 +#define R_390_PC64             23      /* PC relative 64 bit.  */
2677 +#define R_390_GOT64            24      /* 64 bit GOT offset.  */
2678 +#define R_390_PLT64            25      /* 64 bit PC relative PLT address.  */
2679 +#define R_390_GOTENT           26      /* 32 bit PC rel. to GOT entry >> 1. */
2680 +#define R_390_GOTOFF16         27      /* 16 bit offset to GOT. */
2681 +#define R_390_GOTOFF64         28      /* 64 bit offset to GOT. */
2682 +#define R_390_GOTPLT12         29      /* 12 bit offset to jump slot.  */
2683 +#define R_390_GOTPLT16         30      /* 16 bit offset to jump slot.  */
2684 +#define R_390_GOTPLT32         31      /* 32 bit offset to jump slot.  */
2685 +#define R_390_GOTPLT64         32      /* 64 bit offset to jump slot.  */
2686 +#define R_390_GOTPLTENT                33      /* 32 bit rel. offset to jump slot.  */
2687 +#define R_390_PLTOFF16         34      /* 16 bit offset from GOT to PLT. */
2688 +#define R_390_PLTOFF32         35      /* 32 bit offset from GOT to PLT. */
2689 +#define R_390_PLTOFF64         36      /* 16 bit offset from GOT to PLT. */
2690 +#define R_390_TLS_LOAD         37      /* Tag for load insn in TLS code.  */
2691 +#define R_390_TLS_GDCALL       38      /* Tag for function call in general
2692 +                                          dynamic TLS code. */
2693 +#define R_390_TLS_LDCALL       39      /* Tag for function call in local
2694 +                                          dynamic TLS code. */
2695 +#define R_390_TLS_GD32         40      /* Direct 32 bit for general dynamic
2696 +                                          thread local data.  */
2697 +#define R_390_TLS_GD64         41      /* Direct 64 bit for general dynamic
2698 +                                         thread local data.  */
2699 +#define R_390_TLS_GOTIE12      42      /* 12 bit GOT offset for static TLS
2700 +                                          block offset.  */
2701 +#define R_390_TLS_GOTIE32      43      /* 32 bit GOT offset for static TLS
2702 +                                          block offset.  */
2703 +#define R_390_TLS_GOTIE64      44      /* 64 bit GOT offset for static TLS
2704 +                                          block offset. */
2705 +#define R_390_TLS_LDM32                45      /* Direct 32 bit for local dynamic
2706 +                                          thread local data in LE code.  */
2707 +#define R_390_TLS_LDM64                46      /* Direct 64 bit for local dynamic
2708 +                                          thread local data in LE code.  */
2709 +#define R_390_TLS_IE32         47      /* 32 bit address of GOT entry for
2710 +                                          negated static TLS block offset.  */
2711 +#define R_390_TLS_IE64         48      /* 64 bit address of GOT entry for
2712 +                                          negated static TLS block offset.  */
2713 +#define R_390_TLS_IEENT                49      /* 32 bit rel. offset to GOT entry for
2714 +                                          negated static TLS block offset.  */
2715 +#define R_390_TLS_LE32         50      /* 32 bit negated offset relative to
2716 +                                          static TLS block.  */
2717 +#define R_390_TLS_LE64         51      /* 64 bit negated offset relative to
2718 +                                          static TLS block.  */
2719 +#define R_390_TLS_LDO32                52      /* 32 bit offset relative to TLS
2720 +                                          block.  */
2721 +#define R_390_TLS_LDO64                53      /* 64 bit offset relative to TLS
2722 +                                          block.  */
2723 +#define R_390_TLS_DTPMOD       54      /* ID of module containing symbol.  */
2724 +#define R_390_TLS_DTPOFF       55      /* Offset in TLS block.  */
2725 +#define R_390_TLS_TPOFF                56      /* Negated offset in static TLS
2726 +                                          block.  */
2727 +#define R_390_20               57      /* Direct 20 bit.  */
2728 +#define R_390_GOT20            58      /* 20 bit GOT offset.  */
2729 +#define R_390_GOTPLT20         59      /* 20 bit offset to jump slot.  */
2730 +#define R_390_TLS_GOTIE20      60      /* 20 bit GOT offset for static TLS
2731 +                                          block offset.  */
2732 +/* Keep this the last entry.  */
2733 +#define R_390_NUM              61
2736 +/* CRIS flags.  */
2737 +#define EF_CRIS_VARIANT_MASK           0x0000000e
2738 +#define EF_CRIS_VARIANT_ANY_V0_V10     0x00000000
2739 +#define EF_CRIS_VARIANT_V32            0x00000002
2740 +#define EF_CRIS_VARIANT_COMMON_V10_V32 0x00000004
2742 +/* CRIS relocations.  */
2743 +#define R_CRIS_NONE            0
2744 +#define R_CRIS_8               1
2745 +#define R_CRIS_16              2
2746 +#define R_CRIS_32              3
2747 +#define R_CRIS_8_PCREL         4
2748 +#define R_CRIS_16_PCREL                5
2749 +#define R_CRIS_32_PCREL                6
2750 +#define R_CRIS_GNU_VTINHERIT   7
2751 +#define R_CRIS_GNU_VTENTRY     8
2752 +#define R_CRIS_COPY            9
2753 +#define R_CRIS_GLOB_DAT                10
2754 +#define R_CRIS_JUMP_SLOT       11
2755 +#define R_CRIS_RELATIVE                12
2756 +#define R_CRIS_16_GOT          13
2757 +#define R_CRIS_32_GOT          14
2758 +#define R_CRIS_16_GOTPLT       15
2759 +#define R_CRIS_32_GOTPLT       16
2760 +#define R_CRIS_32_GOTREL       17
2761 +#define R_CRIS_32_PLT_GOTREL   18
2762 +#define R_CRIS_32_PLT_PCREL    19
2764 +/* Keep this the last entry.  */
2765 +#define R_CRIS_NUM             20
2768 +/* AMD x86-64 relocations.  */
2769 +#define R_X86_64_NONE          0       /* No reloc */
2770 +#define R_X86_64_64            1       /* Direct 64 bit  */
2771 +#define R_X86_64_PC32          2       /* PC relative 32 bit signed */
2772 +#define R_X86_64_GOT32         3       /* 32 bit GOT entry */
2773 +#define R_X86_64_PLT32         4       /* 32 bit PLT address */
2774 +#define R_X86_64_COPY          5       /* Copy symbol at runtime */
2775 +#define R_X86_64_GLOB_DAT      6       /* Create GOT entry */
2776 +#define R_X86_64_JUMP_SLOT     7       /* Create PLT entry */
2777 +#define R_X86_64_RELATIVE      8       /* Adjust by program base */
2778 +#define R_X86_64_GOTPCREL      9       /* 32 bit signed PC relative
2779 +                                          offset to GOT */
2780 +#define R_X86_64_32            10      /* Direct 32 bit zero extended */
2781 +#define R_X86_64_32S           11      /* Direct 32 bit sign extended */
2782 +#define R_X86_64_16            12      /* Direct 16 bit zero extended */
2783 +#define R_X86_64_PC16          13      /* 16 bit sign extended pc relative */
2784 +#define R_X86_64_8             14      /* Direct 8 bit sign extended  */
2785 +#define R_X86_64_PC8           15      /* 8 bit sign extended pc relative */
2786 +#define R_X86_64_DTPMOD64      16      /* ID of module containing symbol */
2787 +#define R_X86_64_DTPOFF64      17      /* Offset in module's TLS block */
2788 +#define R_X86_64_TPOFF64       18      /* Offset in initial TLS block */
2789 +#define R_X86_64_TLSGD         19      /* 32 bit signed PC relative offset
2790 +                                          to two GOT entries for GD symbol */
2791 +#define R_X86_64_TLSLD         20      /* 32 bit signed PC relative offset
2792 +                                          to two GOT entries for LD symbol */
2793 +#define R_X86_64_DTPOFF32      21      /* Offset in TLS block */
2794 +#define R_X86_64_GOTTPOFF      22      /* 32 bit signed PC relative offset
2795 +                                          to GOT entry for IE symbol */
2796 +#define R_X86_64_TPOFF32       23      /* Offset in initial TLS block */
2798 +#define R_X86_64_NUM           24
2801 +/* AM33 relocations.  */
2802 +#define R_MN10300_NONE         0       /* No reloc.  */
2803 +#define R_MN10300_32           1       /* Direct 32 bit.  */
2804 +#define R_MN10300_16           2       /* Direct 16 bit.  */
2805 +#define R_MN10300_8            3       /* Direct 8 bit.  */
2806 +#define R_MN10300_PCREL32      4       /* PC-relative 32-bit.  */
2807 +#define R_MN10300_PCREL16      5       /* PC-relative 16-bit signed.  */
2808 +#define R_MN10300_PCREL8       6       /* PC-relative 8-bit signed.  */
2809 +#define R_MN10300_GNU_VTINHERIT        7       /* Ancient C++ vtable garbage... */
2810 +#define R_MN10300_GNU_VTENTRY  8       /* ... collection annotation.  */
2811 +#define R_MN10300_24           9       /* Direct 24 bit.  */
2812 +#define R_MN10300_GOTPC32      10      /* 32-bit PCrel offset to GOT.  */
2813 +#define R_MN10300_GOTPC16      11      /* 16-bit PCrel offset to GOT.  */
2814 +#define R_MN10300_GOTOFF32     12      /* 32-bit offset from GOT.  */
2815 +#define R_MN10300_GOTOFF24     13      /* 24-bit offset from GOT.  */
2816 +#define R_MN10300_GOTOFF16     14      /* 16-bit offset from GOT.  */
2817 +#define R_MN10300_PLT32                15      /* 32-bit PCrel to PLT entry.  */
2818 +#define R_MN10300_PLT16                16      /* 16-bit PCrel to PLT entry.  */
2819 +#define R_MN10300_GOT32                17      /* 32-bit offset to GOT entry.  */
2820 +#define R_MN10300_GOT24                18      /* 24-bit offset to GOT entry.  */
2821 +#define R_MN10300_GOT16                19      /* 16-bit offset to GOT entry.  */
2822 +#define R_MN10300_COPY         20      /* Copy symbol at runtime.  */
2823 +#define R_MN10300_GLOB_DAT     21      /* Create GOT entry.  */
2824 +#define R_MN10300_JMP_SLOT     22      /* Create PLT entry.  */
2825 +#define R_MN10300_RELATIVE     23      /* Adjust by program base.  */
2827 +#define R_MN10300_NUM          24
2830 +/* M32R relocs.  */
2831 +#define R_M32R_NONE            0       /* No reloc. */
2832 +#define R_M32R_16              1       /* Direct 16 bit. */
2833 +#define R_M32R_32              2       /* Direct 32 bit. */
2834 +#define R_M32R_24              3       /* Direct 24 bit. */
2835 +#define R_M32R_10_PCREL                4       /* PC relative 10 bit shifted. */
2836 +#define R_M32R_18_PCREL                5       /* PC relative 18 bit shifted. */
2837 +#define R_M32R_26_PCREL                6       /* PC relative 26 bit shifted. */
2838 +#define R_M32R_HI16_ULO                7       /* High 16 bit with unsigned low. */
2839 +#define R_M32R_HI16_SLO                8       /* High 16 bit with signed low. */
2840 +#define R_M32R_LO16            9       /* Low 16 bit. */
2841 +#define R_M32R_SDA16           10      /* 16 bit offset in SDA. */
2842 +#define R_M32R_GNU_VTINHERIT   11
2843 +#define R_M32R_GNU_VTENTRY     12
2844 +/* M32R relocs use SHT_RELA.  */
2845 +#define R_M32R_16_RELA         33      /* Direct 16 bit. */
2846 +#define R_M32R_32_RELA         34      /* Direct 32 bit. */
2847 +#define R_M32R_24_RELA         35      /* Direct 24 bit. */
2848 +#define R_M32R_10_PCREL_RELA   36      /* PC relative 10 bit shifted. */
2849 +#define R_M32R_18_PCREL_RELA   37      /* PC relative 18 bit shifted. */
2850 +#define R_M32R_26_PCREL_RELA   38      /* PC relative 26 bit shifted. */
2851 +#define R_M32R_HI16_ULO_RELA   39      /* High 16 bit with unsigned low */
2852 +#define R_M32R_HI16_SLO_RELA   40      /* High 16 bit with signed low */
2853 +#define R_M32R_LO16_RELA       41      /* Low 16 bit */
2854 +#define R_M32R_SDA16_RELA      42      /* 16 bit offset in SDA */
2855 +#define R_M32R_RELA_GNU_VTINHERIT      43
2856 +#define R_M32R_RELA_GNU_VTENTRY        44
2858 +#define R_M32R_GOT24           48      /* 24 bit GOT entry */
2859 +#define R_M32R_26_PLTREL       49      /* 26 bit PC relative to PLT shifted */
2860 +#define R_M32R_COPY            50      /* Copy symbol at runtime */
2861 +#define R_M32R_GLOB_DAT                51      /* Create GOT entry */
2862 +#define R_M32R_JMP_SLOT                52      /* Create PLT entry */
2863 +#define R_M32R_RELATIVE                53      /* Adjust by program base */
2864 +#define R_M32R_GOTOFF          54      /* 24 bit offset to GOT */
2865 +#define R_M32R_GOTPC24         55      /* 24 bit PC relative offset to GOT */
2866 +#define R_M32R_GOT16_HI_ULO    56      /* High 16 bit GOT entry with unsigned
2867 +                                          low */
2868 +#define R_M32R_GOT16_HI_SLO    57      /* High 16 bit GOT entry with signed
2869 +                                          low */
2870 +#define R_M32R_GOT16_LO                58      /* Low 16 bit GOT entry */
2871 +#define R_M32R_GOTPC_HI_ULO    59      /* High 16 bit PC relative offset to
2872 +                                          GOT with unsigned low */
2873 +#define R_M32R_GOTPC_HI_SLO    60      /* High 16 bit PC relative offset to
2874 +                                          GOT with signed low */
2875 +#define R_M32R_GOTPC_LO                61      /* Low 16 bit PC relative offset to
2876 +                                          GOT */
2877 +#define R_M32R_GOTOFF_HI_ULO   62      /* High 16 bit offset to GOT
2878 +                                          with unsigned low */
2879 +#define R_M32R_GOTOFF_HI_SLO   63      /* High 16 bit offset to GOT
2880 +                                          with signed low */
2881 +#define R_M32R_GOTOFF_LO       64      /* Low 16 bit offset to GOT */
2882 +#define R_M32R_NUM             256     /* Keep this the last entry. */
2884 +/* i960 Relocations */
2885 +#define R_960_NONE      0
2886 +#define R_960_12        1
2887 +#define R_960_32        2
2888 +#define R_960_IP24      3
2889 +#define R_960_SUB       4
2890 +#define R_960_OPTCALL   5
2891 +#define R_960_OPTCALLX  6
2892 +#define R_960_OPTCALLXA 7
2893 +/* Keep this the last entry.  */
2894 +#define R_960_NUM      8
2897 +/* v850 relocations.  */
2898 +#define R_V850_NONE            0
2899 +#define R_V850_9_PCREL         1
2900 +#define R_V850_22_PCREL                2
2901 +#define R_V850_HI16_S          3
2902 +#define R_V850_HI16            4
2903 +#define R_V850_LO16            5
2904 +#define R_V850_32              6
2905 +#define R_V850_16              7
2906 +#define R_V850_8               8
2907 +#define R_V850_SDA_16_16_OFFSET        9       /* For ld.b, st.b, set1, clr1,
2908 +                                          not1, tst1, movea, movhi */
2909 +#define R_V850_SDA_15_16_OFFSET        10      /* For ld.w, ld.h, ld.hu, st.w, st.h */
2910 +#define R_V850_ZDA_16_16_OFFSET        11      /* For ld.b, st.b, set1, clr1,
2911 +                                          not1, tst1, movea, movhi */
2912 +#define R_V850_ZDA_15_16_OFFSET        12      /* For ld.w, ld.h, ld.hu, st.w, st.h */
2913 +#define R_V850_TDA_6_8_OFFSET  13      /* For sst.w, sld.w */
2914 +#define R_V850_TDA_7_8_OFFSET  14      /* For sst.h, sld.h */
2915 +#define R_V850_TDA_7_7_OFFSET  15      /* For sst.b, sld.b */
2916 +#define R_V850_TDA_16_16_OFFSET        16      /* For set1, clr1, not1, tst1,
2917 +                                          movea, movhi */
2918 +/* CYGNUS LOCAL v850e */
2919 +#define R_V850_TDA_4_5_OFFSET          17      /* For sld.hu */
2920 +#define R_V850_TDA_4_4_OFFSET          18      /* For sld.bu */
2921 +#define R_V850_SDA_16_16_SPLIT_OFFSET  19      /* For ld.bu */
2922 +#define R_V850_ZDA_16_16_SPLIT_OFFSET  20      /* For ld.bu */
2923 +#define R_V850_CALLT_6_7_OFFSET                21      /* For callt */
2924 +#define R_V850_CALLT_16_16_OFFSET      22      /* For callt */
2925 +/* END CYGNUS LOCAL */
2926 +#define R_V850_GNU_VTINHERIT   23
2927 +#define R_V850_GNU_VTENTRY     24
2928 +/* Keep this the last entry.  */
2929 +#define R_V850_NUM             25
2932 +/* Renesas H8/300 Relocations */
2933 +#define R_H8_NONE       0
2934 +#define R_H8_DIR32      1
2935 +#define R_H8_DIR32_28   2
2936 +#define R_H8_DIR32_24   3
2937 +#define R_H8_DIR32_16   4
2938 +#define R_H8_DIR32U     6
2939 +#define R_H8_DIR32U_28  7
2940 +#define R_H8_DIR32U_24  8
2941 +#define R_H8_DIR32U_20  9
2942 +#define R_H8_DIR32U_16 10
2943 +#define R_H8_DIR24     11
2944 +#define R_H8_DIR24_20  12
2945 +#define R_H8_DIR24_16  13
2946 +#define R_H8_DIR24U    14
2947 +#define R_H8_DIR24U_20 15
2948 +#define R_H8_DIR24U_16 16
2949 +#define R_H8_DIR16     17
2950 +#define R_H8_DIR16U    18
2951 +#define R_H8_DIR16S_32 19
2952 +#define R_H8_DIR16S_28 20
2953 +#define R_H8_DIR16S_24 21
2954 +#define R_H8_DIR16S_20 22
2955 +#define R_H8_DIR16S    23
2956 +#define R_H8_DIR8      24
2957 +#define R_H8_DIR8U     25
2958 +#define R_H8_DIR8Z_32  26
2959 +#define R_H8_DIR8Z_28  27
2960 +#define R_H8_DIR8Z_24  28
2961 +#define R_H8_DIR8Z_20  29
2962 +#define R_H8_DIR8Z_16  30
2963 +#define R_H8_PCREL16   31
2964 +#define R_H8_PCREL8    32
2965 +#define R_H8_BPOS      33
2966 +#define R_H8_PCREL32   34
2967 +#define R_H8_GOT32O    35
2968 +#define R_H8_GOT16O    36
2969 +#define R_H8_DIR16A8   59
2970 +#define R_H8_DIR16R8   60
2971 +#define R_H8_DIR24A8   61
2972 +#define R_H8_DIR24R8   62
2973 +#define R_H8_DIR32A16  63
2974 +#define R_H8_ABS32     65
2975 +#define R_H8_ABS32A16 127
2976 +#define R_H8_NUM      128
2978 +/* NIOS relocations. */
2979 +#define R_NIOS_NONE                            0
2980 +#define R_NIOS_32                              1       /* A 32 bit absolute relocation.*/
2981 +#define R_NIOS_LO16_LO5                        2       /* A LO-16 5 bit absolute relocation.  */
2982 +#define R_NIOS_LO16_HI11               3       /* A LO-16 top 11 bit absolute relocation.  */
2983 +#define R_NIOS_HI16_LO5                        4       /* A HI-16 5 bit absolute relocation.  */
2984 +#define R_NIOS_HI16_HI11               5       /* A HI-16 top 11 bit absolute relocation.  */
2985 +#define R_NIOS_PCREL6                  6       /* A 6 bit relative relocation.  */
2986 +#define R_NIOS_PCREL8                  7       /* An 8 bit relative relocation.  */
2987 +#define R_NIOS_PCREL11                 8       /* An 11 bit relative relocation.  */
2988 +#define R_NIOS_16                              9       /* A 16 bit absolute relocation.  */
2989 +#define R_NIOS_H_LO5                   10      /* Low 5-bits of absolute relocation in halfwords.  */
2990 +#define R_NIOS_H_HI11                  11      /* Top 11 bits of 16-bit absolute relocation in halfwords.  */
2991 +#define R_NIOS_H_XLO5                  12      /* Low 5 bits of top 16-bits of 32-bit absolute relocation in halfwords.  */
2992 +#define R_NIOS_H_XHI11                 13      /* Top 11 bits of top 16-bits of 32-bit absolute relocation in halfwords.  */
2993 +#define R_NIOS_H_16                            14      /* Half-word @h value */
2994 +#define R_NIOS_H_32                            15      /* Word @h value */
2995 +#define R_NIOS_GNU_VTINHERIT   200     /* GNU extension to record C++ vtable hierarchy */
2996 +#define R_NIOS_GNU_VTENTRY             201     /* GNU extension to record C++ vtable member usage */
2997 +/* Keep this the last entry.  */
2998 +#define R_NIOS_NUM                             202
3000 +/* NIOS II relocations */
3001 +#define R_NIOS2_NONE                   0
3002 +#define R_NIOS2_S16                            1
3003 +#define R_NIOS2_U16                            2
3004 +#define R_NIOS2_PCREL16                        3
3005 +#define R_NIOS2_CALL26                 4
3006 +#define R_NIOS2_IMM5                   5
3007 +#define R_NIOS2_CACHE_OPX              6
3008 +#define R_NIOS2_IMM6                   7
3009 +#define R_NIOS2_IMM8                   8
3010 +#define R_NIOS2_HI16                   9
3011 +#define R_NIOS2_LO16                   10
3012 +#define R_NIOS2_HIADJ16                11
3013 +#define R_NIOS2_BFD_RELOC_32   12
3014 +#define R_NIOS2_BFD_RELOC_16   13
3015 +#define R_NIOS2_BFD_RELOC_8    14
3016 +#define R_NIOS2_GPREL                  15
3017 +#define R_NIOS2_GNU_VTINHERIT  16
3018 +#define R_NIOS2_GNU_VTENTRY    17
3019 +#define R_NIOS2_UJMP                   18
3020 +#define R_NIOS2_CJMP                   19
3021 +#define R_NIOS2_CALLR                  20
3022 +#define R_NIOS2_ALIGN                  21
3023 +/* Keep this the last entry.  */
3024 +#define R_NIOS2_NUM                            22
3026 +__END_DECLS
3028 +#endif /* elf.h */
3029 diff -Nrup a/ldso/include/dl-string.h b/ldso/include/dl-string.h
3030 --- a/ldso/include/dl-string.h  2007-01-25 19:22:03.000000000 -0500
3031 +++ b/ldso/include/dl-string.h  2008-02-28 19:03:13.000000000 -0500
3032 @@ -285,7 +285,9 @@ static __always_inline char * _dl_simple
3033  /* On some arches constant strings are referenced through the GOT.
3034   * This requires that load_addr must already be defined... */
3035  #if defined(mc68000)  || defined(__arm__) || defined(__thumb__) || \
3036 -    defined(__mips__) || defined(__sh__)  || defined(__powerpc__)
3037 +    defined(__mips__) || defined(__sh__)  || defined(__powerpc__) || \
3038 +       defined(__avr32__)
3040  # define CONSTANT_STRING_GOT_FIXUP(X) \
3041         if ((X) < (const char *) load_addr) (X) += load_addr
3042  # define NO_EARLY_SEND_STDERR
3043 diff -Nrup a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
3044 --- a/ldso/include/dl-syscall.h 2007-01-28 00:51:31.000000000 -0500
3045 +++ b/ldso/include/dl-syscall.h 2008-02-28 19:06:04.000000000 -0500
3046 @@ -54,69 +54,69 @@
3047     dynamic linking at all, so we cannot return any error codes.
3048     We just punt if there is an error. */
3049  #define __NR__dl_exit __NR_exit
3050 -static inline _syscall1(void, _dl_exit, int, status);
3051 +static __always_inline _syscall1(void, _dl_exit, int, status);
3053  #define __NR__dl_close __NR_close
3054 -static inline _syscall1(int, _dl_close, int, fd);
3055 +static __always_inline _syscall1(int, _dl_close, int, fd);
3057  #define __NR__dl_open __NR_open
3058 -static inline _syscall3(int, _dl_open, const char *, fn, int, flags,
3059 +static __always_inline _syscall3(int, _dl_open, const char *, fn, int, flags,
3060                          __kernel_mode_t, mode);
3062  #define __NR__dl_write __NR_write
3063 -static inline _syscall3(unsigned long, _dl_write, int, fd,
3064 +static __always_inline _syscall3(unsigned long, _dl_write, int, fd,
3065                          const void *, buf, unsigned long, count);
3067  #define __NR__dl_read __NR_read
3068 -static inline _syscall3(unsigned long, _dl_read, int, fd,
3069 +static __always_inline _syscall3(unsigned long, _dl_read, int, fd,
3070                          const void *, buf, unsigned long, count);
3072  #define __NR__dl_mprotect __NR_mprotect
3073 -static inline _syscall3(int, _dl_mprotect, const void *, addr,
3074 +static __always_inline _syscall3(int, _dl_mprotect, const void *, addr,
3075                          unsigned long, len, int, prot);
3077  #define __NR__dl_stat __NR_stat
3078 -static inline _syscall2(int, _dl_stat, const char *, file_name,
3079 +static __always_inline _syscall2(int, _dl_stat, const char *, file_name,
3080                          struct stat *, buf);
3082  #define __NR__dl_fstat __NR_fstat
3083 -static inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
3084 +static __always_inline _syscall2(int, _dl_fstat, int, fd, struct stat *, buf);
3086  #define __NR__dl_munmap __NR_munmap
3087 -static inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
3088 +static __always_inline _syscall2(int, _dl_munmap, void *, start, unsigned long, length);
3090  #ifdef __NR_getxuid
3091  # define __NR_getuid __NR_getxuid
3092  #endif
3093  #define __NR__dl_getuid __NR_getuid
3094 -static inline _syscall0(uid_t, _dl_getuid);
3095 +static __always_inline _syscall0(uid_t, _dl_getuid);
3097  #ifndef __NR_geteuid
3098  # define __NR_geteuid __NR_getuid
3099  #endif
3100  #define __NR__dl_geteuid __NR_geteuid
3101 -static inline _syscall0(uid_t, _dl_geteuid);
3102 +static __always_inline _syscall0(uid_t, _dl_geteuid);
3104  #ifdef __NR_getxgid
3105  # define __NR_getgid __NR_getxgid
3106  #endif
3107  #define __NR__dl_getgid __NR_getgid
3108 -static inline _syscall0(gid_t, _dl_getgid);
3109 +static __always_inline _syscall0(gid_t, _dl_getgid);
3111  #ifndef __NR_getegid
3112  # define __NR_getegid __NR_getgid
3113  #endif
3114  #define __NR__dl_getegid __NR_getegid
3115 -static inline _syscall0(gid_t, _dl_getegid);
3116 +static __always_inline _syscall0(gid_t, _dl_getegid);
3118  #ifdef __NR_getxpid
3119  # define __NR_getpid __NR_getxpid
3120  #endif
3121  #define __NR__dl_getpid __NR_getpid
3122 -static inline _syscall0(gid_t, _dl_getpid);
3123 +static __always_inline _syscall0(gid_t, _dl_getpid);
3125  #define __NR__dl_readlink __NR_readlink
3126 -static inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
3127 +static __always_inline _syscall3(int, _dl_readlink, const char *, path, char *, buf,
3128                          size_t, bufsiz);
3131 @@ -134,14 +134,14 @@ static inline _syscall3(int, _dl_readlin
3132  #if defined(__UCLIBC_MMAP_HAS_6_ARGS__) && defined(__NR_mmap)
3134  # define __NR__dl_mmap __NR_mmap
3135 -static inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
3136 +static __always_inline _syscall6(void *, _dl_mmap, void *, start, size_t, length,
3137                          int, prot, int, flags, int, fd, off_t, offset);
3139  /* then try mmap2() */
3140  #elif defined(__NR_mmap2)
3142  # define __NR___syscall_mmap2       __NR_mmap2
3143 -static inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
3144 +static __always_inline _syscall6(__ptr_t, __syscall_mmap2, __ptr_t, addr, size_t, len,
3145                          int, prot, int, flags, int, fd, off_t, offset);
3147  /* Some architectures always use 12 as page shift for mmap2() eventhough the
3148 @@ -152,7 +152,7 @@ static inline _syscall6(__ptr_t, __sysca
3149  # define MMAP2_PAGE_SHIFT 12
3150  #endif
3152 -static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
3153 +static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
3154                                int flags, int fd, unsigned long offset)
3156         if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1))
3157 @@ -165,8 +165,8 @@ static inline void * _dl_mmap(void * add
3158  #elif defined(__NR_mmap)
3160  # define __NR__dl_mmap_real __NR_mmap
3161 -static inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
3162 -static inline void * _dl_mmap(void * addr, unsigned long size, int prot,
3163 +static __always_inline _syscall1(void *, _dl_mmap_real, unsigned long *, buffer);
3164 +static __always_inline void * _dl_mmap(void * addr, unsigned long size, int prot,
3165                                int flags, int fd, unsigned long offset)
3167         unsigned long buffer[6];
3168 diff -Nrup a/ldso/ldso/avr32/dl-debug.h b/ldso/ldso/avr32/dl-debug.h
3169 --- a/ldso/ldso/avr32/dl-debug.h        1969-12-31 19:00:00.000000000 -0500
3170 +++ b/ldso/ldso/avr32/dl-debug.h        2008-02-28 19:02:10.000000000 -0500
3171 @@ -0,0 +1,45 @@
3173 + * AVR32 ELF shared libary loader support
3174 + *
3175 + * Copyright (C) 2005 Atmel Norway
3176 + * All rights reserved.
3177 + *
3178 + * Redistribution and use in source and binary forms, with or without
3179 + * modification, are permitted provided that the following conditions
3180 + * are met:
3181 + * 1. Redistributions of source code must retain the above copyright
3182 + *    notice, this list of conditions and the following disclaimer.
3183 + * 2. The name of the above contributors may not be
3184 + *    used to endorse or promote products derived from this software
3185 + *    without specific prior written permission.
3186 + *
3187 + * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
3188 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3189 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3190 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
3191 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3192 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3193 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3194 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3195 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3196 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3197 + * SUCH DAMAGE.
3198 + */
3200 +static const char *_dl_reltypes_tab[] = {
3201 +    "R_AVR32_NONE",
3202 +    "R_AVR32_32", "R_AVR32_16", "R_AVR32_8",
3203 +    "R_AVR32_32_PCREL", "R_AVR32_16_PCREL", "R_AVR32_8_PCREL",
3204 +    "R_AVR32_DIFF32", "R_AVR32_DIFF16", "R_AVR32_DIFF8",
3205 +    "R_AVR32_GOT32", "R_AVR32_GOT16", "R_AVR32_GOT8",
3206 +    "R_AVR32_21S", "R_AVR32_16U", "R_AVR32_16S", "R_AVR32_8S", "R_AVR32_8S_EXT",
3207 +    "R_AVR32_22H_PCREL", "R_AVR32_18W_PCREL", "R_AVR32_16B_PCREL",
3208 +    "R_AVR32_16N_PCREL", "R_AVR32_14UW_PCREL", "R_AVR32_11H_PCREL",
3209 +    "R_AVR32_10UW_PCREL", "R_AVR32_9H_PCREL", "R_AVR32_9UW_PCREL",
3210 +    "R_AVR32_HI16", "R_AVR32_LO16",
3211 +    "R_AVR32_GOTPC", "R_AVR32_GOTCALL", "R_AVR32_LDA_GOT",
3212 +    "R_AVR32_GOT21S", "R_AVR32_GOT18SW", "R_AVR32_GOT16S", "R_AVR32_GOT7UW",
3213 +    "R_AVR32_32_CPENT", "R_AVR32_CPCALL", "R_AVR32_16_CP", "R_AVR32_9W_CP",
3214 +    "R_AVR32_RELATIVE", "R_AVR32_GLOB_DAT", "R_AVR32_JMP_SLOT",
3215 +    "R_AVR32_ALIGN",
3217 diff -Nrup a/ldso/ldso/avr32/dl-startup.h b/ldso/ldso/avr32/dl-startup.h
3218 --- a/ldso/ldso/avr32/dl-startup.h      1969-12-31 19:00:00.000000000 -0500
3219 +++ b/ldso/ldso/avr32/dl-startup.h      2008-02-28 19:02:10.000000000 -0500
3220 @@ -0,0 +1,110 @@
3221 +/* vi: set sw=4 ts=4: */
3223 + * Architecture specific code used by dl-startup.c
3224 + * Copyright (C) 2005 Atmel Norway
3225 + */
3227 +/* This is the library loader's main entry point. Let _dl_boot2 do its
3228 + * initializations and jump to the application's entry point
3229 + * afterwards. */
3230 +asm(   "       .text\n"
3231 +       "       .global _start\n"
3232 +       "       .type   _start,@function\n"
3233 +       "_start:\n"
3234 +       /* All arguments are on the stack initially */
3235 +       "       mov     r12, sp\n"
3236 +       "       rcall   _dl_start\n"
3237 +       /* Returns user entry point in r12. Save it. */
3238 +       "       mov     r0, r12\n"
3239 +       /* We're PIC, so get the Global Offset Table */
3240 +       "       lddpc   r6, .L_GOT\n"
3241 +       ".L_RGOT:\n"
3242 +       "       rsub    r6, pc\n"
3243 +       /* Adjust argc and argv according to _dl_skip_args */
3244 +       "       ld.w    r1, r6[_dl_skip_args@got]\n"
3245 +       "       ld.w    r1, r1[0]\n"
3246 +       "       ld.w    r2, sp++\n"
3247 +       "       sub     r2, r1\n"
3248 +       "       add     sp, sp, r1 << 2\n"
3249 +       "       st.w    --sp, r2\n"
3250 +       /* Load the finalizer function */
3251 +       "       ld.w    r12, r6[_dl_fini@got]\n"
3252 +       /* Jump to the user's entry point */
3253 +       "       mov     pc, r0\n\n"
3255 +       "       .align  2\n"
3256 +       ".L_GOT:"
3257 +       "       .long   .L_RGOT - _GLOBAL_OFFSET_TABLE_\n"
3258 +       "       .size   _start, . - _start\n"
3259 +       "       .previous\n");
3261 +/* Get a pointer to the argv array.  On many platforms this can be just
3262 + * the address if the first argument, on other platforms we need to
3263 + * do something a little more subtle here. */
3264 +#define GET_ARGV(ARGVP, ARGS) ARGVP = ((unsigned long *)ARGS + 1)
3267 +/* We can't call functions before the GOT has been initialized */
3268 +#define NO_FUNCS_BEFORE_BOOTSTRAP
3271 + * Relocate the GOT during dynamic loader bootstrap.  This will add
3272 + * the load address to all entries in the GOT, which is necessary
3273 + * because the linker doesn't generate R_AVR32_RELATIVE relocs for the
3274 + * GOT.
3275 + */
3276 +static __always_inline
3277 +void PERFORM_BOOTSTRAP_GOT(struct elf_resolve *tpnt)
3279 +       Elf32_Addr i, nr_got;
3280 +       register Elf32_Addr *__r6 __asm__("r6");
3281 +       Elf32_Addr *got = __r6;
3283 +       nr_got = tpnt->dynamic_info[DT_AVR32_GOTSZ_IDX] / sizeof(*got);
3284 +       for (i = 2; i < nr_got; i++)
3285 +               got[i] += tpnt->loadaddr;
3288 +#define PERFORM_BOOTSTRAP_GOT(tpnt) PERFORM_BOOTSTRAP_GOT(tpnt)
3290 +/* Handle relocation of the symbols in the dynamic loader. */
3291 +static __always_inline
3292 +void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, unsigned long *reloc_addr,
3293 +                            unsigned long symbol_addr,
3294 +                            unsigned long load_addr, Elf32_Sym *symtab)
3296 +       switch(ELF32_R_TYPE(rpnt->r_info)) {
3297 +       case R_AVR32_NONE:
3298 +               break;
3299 +       case R_AVR32_GLOB_DAT:
3300 +       case R_AVR32_JMP_SLOT:
3301 +               *reloc_addr = symbol_addr;
3302 +               break;
3303 +       case R_AVR32_RELATIVE:
3304 +               SEND_STDERR_DEBUG("Applying RELATIVE relocation: ");
3305 +               SEND_ADDRESS_STDERR_DEBUG(load_addr, 0);
3306 +               SEND_STDERR_DEBUG(" + ");
3307 +               SEND_ADDRESS_STDERR_DEBUG(rpnt->r_addend, 1);
3308 +               *reloc_addr = load_addr + rpnt->r_addend;
3309 +               break;
3310 +       default:
3311 +               SEND_STDERR("BOOTSTRAP_RELOC: unhandled reloc_type ");
3312 +               SEND_NUMBER_STDERR(ELF32_R_TYPE(rpnt->r_info), 1);
3313 +               SEND_STDERR("REL, SYMBOL, LOAD: ");
3314 +               SEND_ADDRESS_STDERR(reloc_addr, 0);
3315 +               SEND_STDERR(", ");
3316 +               SEND_ADDRESS_STDERR(symbol_addr, 0);
3317 +               SEND_STDERR(", ");
3318 +               SEND_ADDRESS_STDERR(load_addr, 1);
3319 +               _dl_exit(1);
3320 +       }
3323 +/* Transfer control to the user's application, once the dynamic loader
3324 + * is done. This routine has to exit the current function, then call
3325 + * the _dl_elf_main function.
3326 + *
3327 + * Since our _dl_boot will simply call whatever is returned by
3328 + * _dl_boot2, we can just return the address we're supposed to
3329 + * call.  */
3330 +#define START()        return _dl_elf_main;
3331 diff -Nrup a/ldso/ldso/avr32/dl-syscalls.h b/ldso/ldso/avr32/dl-syscalls.h
3332 --- a/ldso/ldso/avr32/dl-syscalls.h     1969-12-31 19:00:00.000000000 -0500
3333 +++ b/ldso/ldso/avr32/dl-syscalls.h     2008-02-28 19:02:10.000000000 -0500
3334 @@ -0,0 +1,5 @@
3335 +/* We can't use the real errno in ldso, since it has not yet
3336 + * been dynamicly linked in yet. */
3337 +extern int _dl_errno;
3338 +#define __set_errno(X) {(_dl_errno) = (X);}
3339 +#include "sys/syscall.h"
3340 diff -Nrup a/ldso/ldso/avr32/dl-sysdep.h b/ldso/ldso/avr32/dl-sysdep.h
3341 --- a/ldso/ldso/avr32/dl-sysdep.h       1969-12-31 19:00:00.000000000 -0500
3342 +++ b/ldso/ldso/avr32/dl-sysdep.h       2008-02-28 19:02:10.000000000 -0500
3343 @@ -0,0 +1,103 @@
3344 +/* vi: set sw=4 ts=4: */
3346 + * Various assembly language/system dependent hacks that are required
3347 + * so that we can minimize the amount of platform specific code.
3348 + * Copyright (C) 2004-2005 Atmel Norway
3349 + */
3351 +/* Define this if the system uses RELOCA. */
3352 +#define ELF_USES_RELOCA
3354 +#include <elf.h>
3356 +#define ARCH_NUM 1
3357 +#define DT_AVR32_GOTSZ_IDX     (DT_NUM + OS_NUM)
3359 +#define ARCH_DYNAMIC_INFO(dpnt, dynamic, debug_addr)                   \
3360 +       do {                                                            \
3361 +               if (dpnt->d_tag == DT_AVR32_GOTSZ)                      \
3362 +                       dynamic[DT_AVR32_GOTSZ_IDX] = dpnt->d_un.d_val; \
3363 +       } while (0)
3365 +/* Initialization sequence for the application/library GOT. */
3366 +#define INIT_GOT(GOT_BASE,MODULE)                                      \
3367 +       do {                                                            \
3368 +               unsigned long i, nr_got;                                \
3369 +                                                                       \
3370 +               GOT_BASE[0] = (unsigned long) _dl_linux_resolve;        \
3371 +               GOT_BASE[1] = (unsigned long) MODULE;                   \
3372 +                                                                       \
3373 +               /* Add load address displacement to all GOT entries */  \
3374 +               nr_got = MODULE->dynamic_info[DT_AVR32_GOTSZ_IDX] / 4;  \
3375 +               for (i = 2; i < nr_got; i++)                            \
3376 +                       GOT_BASE[i] += (unsigned long)MODULE->loadaddr; \
3377 +       } while (0)
3379 +#define do_rem(result, n, base)        ((result) = (n) % (base))
3381 +/* Here we define the magic numbers that this dynamic loader should accept */
3382 +#define MAGIC1 EM_AVR32
3383 +#undef MAGIC2
3385 +/* Used for error messages */
3386 +#define ELF_TARGET "AVR32"
3388 +unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
3390 +/* 4096 bytes alignment */
3391 +#define PAGE_ALIGN 0xfffff000
3392 +#define ADDR_ALIGN 0xfff
3393 +#define OFFS_ALIGN 0x7ffff000
3395 +#define elf_machine_type_class(type)                           \
3396 +       ((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)
3398 +/* AVR32 doesn't need any COPY relocs */
3399 +#define DL_NO_COPY_RELOCS
3401 +/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
3402 +   first element of the GOT.  This must be inlined in a function which
3403 +   uses global data.  */
3404 +static inline Elf32_Addr
3405 +elf_machine_dynamic (void)
3407 +       register Elf32_Addr *got asm ("r6");
3408 +       return *got;
3411 +/* Return the run-time load address of the shared object.  */
3412 +static inline Elf32_Addr
3413 +elf_machine_load_address (void)
3415 +       extern void __dl_start asm("_dl_start");
3416 +       Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
3417 +       Elf32_Addr pcrel_addr;
3419 +       asm   ("        lddpc   %0, 2f\n"
3420 +              "1:      add     %0, pc\n"
3421 +              "        rjmp    3f\n"
3422 +              "        .align  2\n"
3423 +              "2:      .long   _dl_start - 1b\n"
3424 +              "3:\n"
3425 +              : "=r"(pcrel_addr) : : "cc");
3427 +       return pcrel_addr - got_addr;
3431 + * Perform any RELATIVE relocations specified by DT_RELCOUNT.
3432 + * Currently, we don't use that tag, but we might in the future as
3433 + * this would reduce the startup time somewhat (although probably not by much).
3434 + */
3435 +static inline void
3436 +elf_machine_relative (Elf32_Addr load_off, const Elf32_Addr rel_addr,
3437 +                     Elf32_Word relative_count)
3439 +       Elf32_Rela *rpnt = (void *)rel_addr;
3441 +       do {
3442 +               Elf32_Addr *reloc_addr;
3443 +               reloc_addr = (void *)(load_off + (rpnt++)->r_offset);
3444 +               *reloc_addr = load_off + rpnt->r_addend;
3445 +       } while (--relative_count);
3447 diff -Nrup a/ldso/ldso/avr32/elfinterp.c b/ldso/ldso/avr32/elfinterp.c
3448 --- a/ldso/ldso/avr32/elfinterp.c       1969-12-31 19:00:00.000000000 -0500
3449 +++ b/ldso/ldso/avr32/elfinterp.c       2008-02-28 19:02:10.000000000 -0500
3450 @@ -0,0 +1,191 @@
3452 + * AVR32 ELF shared library loader suppport
3453 + *
3454 + * Copyright (C) 2004-2006 Atmel Corporation
3455 + *
3456 + * All rights reserved.
3457 + *
3458 + * Redistribution and use in source and binary forms, with or without
3459 + * modification, are permitted provided that the following conditions
3460 + * are met:
3461 + * 1. Redistributions of source code must retain the above copyright
3462 + *    notice, this list of conditions and the following disclaimer.
3463 + * 2. The name of the above contributors may not be
3464 + *    used to endorse or promote products derived from this software
3465 + *    without specific prior written permission.
3466 + *
3467 + * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
3468 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3469 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3470 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
3471 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3472 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3473 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3474 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3475 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3476 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3477 + * SUCH DAMAGE.
3478 + */
3480 +unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got)
3482 +       struct elf_resolve *tpnt = (struct elf_resolve *)got[1];
3483 +       Elf32_Sym *sym;
3484 +       unsigned long local_gotno;
3485 +       unsigned long gotsym;
3486 +       unsigned long new_addr;
3487 +       char *strtab, *symname;
3488 +       unsigned long *entry;
3489 +       unsigned long sym_index = got_offset / 4;
3491 +#if 0
3492 +       local_gotno = tpnt->dynamic_info[DT_AVR32_LOCAL_GOTNO];
3493 +       gotsym = tpnt->dynamic_info[DT_AVR32_GOTSYM];
3495 +       sym = ((Elf32_Sym *)(tpnt->dynamic_info[DT_SYMTAB] + tpnt->loadaddr))
3496 +               + sym_index;
3497 +       strtab = (char *)(tpnt->dynamic_info[DT_STRTAB] + tpnt->loadaddr);
3498 +       symname = strtab + sym->st_name;
3500 +#if 0
3501 +       new_addr = (unsigned long) _dl_find_hash(strtab + sym->st_name,
3502 +                                                tpnt->symbol_scope, tpnt,
3503 +                                                resolver);
3504 +#endif
3506 +       entry = (unsigned long *)(got + local_gotno + sym_index - gotsym);
3507 +       *entry = new_addr;
3508 +#endif
3510 +       return new_addr;
3513 +static int
3514 +_dl_parse(struct elf_resolve *tpnt, struct dyn_elf *scope,
3515 +         unsigned long rel_addr, unsigned long rel_size,
3516 +         int (*reloc_func)(struct elf_resolve *tpnt, struct dyn_elf *scope,
3517 +                           Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab))
3519 +       Elf32_Sym *symtab;
3520 +       Elf32_Rela *rpnt;
3521 +       char *strtab;
3522 +       int i;
3524 +       rpnt = (Elf32_Rela *)rel_addr;
3525 +       rel_size /= sizeof(Elf32_Rela);
3526 +       symtab = (Elf32_Sym *)tpnt->dynamic_info[DT_SYMTAB];
3527 +       strtab = (char *)tpnt->dynamic_info[DT_STRTAB];
3529 +       for (i = 0; i < rel_size; i++, rpnt++) {
3530 +               int symtab_index, res;
3532 +               symtab_index = ELF32_R_SYM(rpnt->r_info);
3534 +               debug_sym(symtab, strtab, symtab_index);
3535 +               debug_reloc(symtab, strtab, rpnt);
3537 +               res = reloc_func(tpnt, scope, rpnt, symtab, strtab);
3539 +               if (res == 0)
3540 +                       continue;
3542 +               _dl_dprintf(2, "\n%s: ", _dl_progname);
3544 +               if (symtab_index)
3545 +                       _dl_dprintf(2, "symbol '%s': ",
3546 +                                   strtab + symtab[symtab_index].st_name);
3548 +               if (res < 0) {
3549 +                       int reloc_type = ELF32_R_TYPE(rpnt->r_info);
3550 +#if defined(__SUPPORT_LD_DEBUG__)
3551 +                       _dl_dprintf(2, "can't handle reloc type %s\n",
3552 +                                   _dl_reltypes(reloc_type));
3553 +#else
3554 +                       _dl_dprintf(2, "can't handle reloc type %x\n",
3555 +                                   reloc_type);
3556 +#endif
3557 +                       _dl_exit(-res);
3558 +               } else {
3559 +                       _dl_dprintf(2, "can't resolve symbol\n");
3560 +                       return res;
3561 +               }
3562 +       }
3564 +       return 0;
3567 +static int _dl_do_reloc(struct elf_resolve *tpnt, struct dyn_elf *scope,
3568 +                       Elf32_Rela *rpnt, Elf32_Sym *symtab, char *strtab)
3570 +       int reloc_type;
3571 +       int symtab_index;
3572 +       char *symname;
3573 +       unsigned long *reloc_addr;
3574 +       unsigned long symbol_addr;
3575 +#if defined(__SUPPORT_LD_DEBUG__)
3576 +       unsigned long old_val;
3577 +#endif
3579 +       reloc_addr = (unsigned long *)(tpnt->loadaddr + rpnt->r_offset);
3580 +       reloc_type = ELF32_R_TYPE(rpnt->r_info);
3581 +       symtab_index = ELF32_R_SYM(rpnt->r_info);
3582 +       symbol_addr = 0;
3583 +       symname = strtab + symtab[symtab_index].st_name;
3585 +       if (symtab_index) {
3586 +               symbol_addr = (unsigned long)
3587 +                       _dl_find_hash(strtab + symtab[symtab_index].st_name,
3588 +                                     tpnt->symbol_scope, tpnt,
3589 +                                     elf_machine_type_class(reloc_type));
3591 +               /* Allow undefined references to weak symbols */
3592 +               if (!symbol_addr &&
3593 +                   ELF32_ST_BIND(symtab[symtab_index].st_info) != STB_WEAK) {
3594 +                       _dl_dprintf(2, "%s: can't resolve symbol '%s'\n",
3595 +                                   _dl_progname, symname);
3596 +                       return 0;
3597 +               }
3598 +       }
3600 +#if defined(__SUPPORT_LD_DEBUG__)
3601 +       old_val = *reloc_addr;
3602 +#endif
3603 +       switch (reloc_type) {
3604 +       case R_AVR32_NONE:
3605 +               break;
3606 +       case R_AVR32_GLOB_DAT:
3607 +       case R_AVR32_JMP_SLOT:
3608 +               *reloc_addr = symbol_addr + rpnt->r_addend;
3609 +               break;
3610 +       case R_AVR32_RELATIVE:
3611 +               *reloc_addr = (unsigned long)tpnt->loadaddr
3612 +                       + rpnt->r_addend;
3613 +               break;
3614 +       default:
3615 +               return -1;
3616 +       }
3618 +#if defined(__SUPPORT_LD_DEBUG__)
3619 +       if (_dl_debug_reloc && _dl_debug_detail)
3620 +               _dl_dprintf(_dl_debug_file, "\tpatched: %x ==> %x @ %x\n",
3621 +                           old_val, *reloc_addr);
3622 +#endif
3624 +       return 0;
3627 +void _dl_parse_lazy_relocation_information(struct dyn_elf *rpnt,
3628 +                                          unsigned long rel_addr,
3629 +                                          unsigned long rel_size)
3631 +       /* TODO: Might want to support this in order to get faster
3632 +        * startup times... */
3635 +int _dl_parse_relocation_information(struct dyn_elf *rpnt,
3636 +                                    unsigned long rel_addr,
3637 +                                    unsigned long rel_size)
3639 +       return _dl_parse(rpnt->dyn, rpnt->dyn->symbol_scope, rel_addr, rel_size,
3640 +                        _dl_do_reloc);
3642 diff -Nrup a/ldso/ldso/avr32/resolve.S b/ldso/ldso/avr32/resolve.S
3643 --- a/ldso/ldso/avr32/resolve.S 1969-12-31 19:00:00.000000000 -0500
3644 +++ b/ldso/ldso/avr32/resolve.S 2008-02-28 19:02:10.000000000 -0500
3645 @@ -0,0 +1,28 @@
3647 + * Linux dynamic resolving code for AVR32. Fixes up the GOT entry as
3648 + * indicated in register r12 and jumps to the resolved address.
3649 + *
3650 + * This file is subject to the terms and conditions of the GNU Lesser General
3651 + * Public License.  See the file "COPYING.LIB" in the main directory of this
3652 + * archive for more details.
3653 + *
3654 + * Copyright (C) 2004 Atmel Norway
3655 + */
3657 +#define ip r5
3659 +       .text
3660 +       .global _dl_linux_resolve
3661 +       .type   _dl_linux_resolve,@function
3662 +_dl_linux_resolve:
3663 +       /* The PLT code pushed r8 for us. It contains the address of this
3664 +          function's GOT entry, that is entry 0. ip contains the address
3665 +          of the GOT entry of the function we wanted to call. */
3666 +       stm     --sp, r9-r12, lr
3667 +       mov     r11, r8
3668 +       sub     r12, ip, r8
3669 +       rcall   _dl_linux_resolver
3670 +       mov     ip, r12
3671 +       popm    r8-r12,lr
3672 +       mov     pc, ip
3673 +       .size   _dl_linux_resolve, . - _dl_linux_resolve
3674 diff -Nrup a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
3675 --- a/ldso/ldso/dl-startup.c    2007-01-25 19:22:03.000000000 -0500
3676 +++ b/ldso/ldso/dl-startup.c    2008-02-28 19:02:10.000000000 -0500
3677 @@ -217,7 +217,9 @@ static void * __attribute_used__ _dl_sta
3678         /* some arches (like MIPS) we have to tweak the GOT before relocations */
3679         PERFORM_BOOTSTRAP_GOT(tpnt);
3681 -#else
3682 +#endif
3684 +#if !defined(PERFORM_BOOTSTRAP_GOT) || defined(__avr32__)
3686         /* OK, now do the relocations.  We do not do a lazy binding here, so
3687            that once we are done, we have considerably more flexibility. */
3688 @@ -259,7 +261,7 @@ static void * __attribute_used__ _dl_sta
3689                                 rel_addr += relative_count * sizeof(ELF_RELOC);;
3690                         }
3692 -                       rpnt = (ELF_RELOC *) (rel_addr + load_addr);
3693 +                       rpnt = (ELF_RELOC *) (rel_addr /* + load_addr */);
3694                         for (i = 0; i < rel_size; i += sizeof(ELF_RELOC), rpnt++) {
3695                                 reloc_addr = (unsigned long *) (load_addr + (unsigned long) rpnt->r_offset);
3696                                 symtab_index = ELF_R_SYM(rpnt->r_info);
3697 diff -Nrup a/libc/Makefile b/libc/Makefile
3698 --- a/libc/Makefile     2007-02-28 16:23:09.000000000 -0500
3699 +++ b/libc/Makefile     2008-02-28 19:02:10.000000000 -0500
3700 @@ -59,7 +59,7 @@ $(LIBNAME) shared_$(LIBNAME) ar-target: 
3701         $(AR) dN 2 $(LIBNAME) $$objs && \
3702         $(AR) dN 2 $(LIBNAME) $$objs
3703         @for objfile in obj.signal \
3704 -                       obj.string.generic obj.string.$(TARGET_ARCH) obj.string \
3705 +                       obj.string obj.string.generic obj.string.$(TARGET_ARCH) \
3706                         obj.sysdeps.common obj.sysdeps.$(TARGET_ARCH) ; do \
3707                 if [ -e $$objfile ] ; then \
3708                         if [ "$(MAKE_IS_SILENT)" = "n" ] ; then \
3709 diff -Nrup a/libc/string/avr32/bcopy.S b/libc/string/avr32/bcopy.S
3710 --- a/libc/string/avr32/bcopy.S 1969-12-31 19:00:00.000000000 -0500
3711 +++ b/libc/string/avr32/bcopy.S 2008-02-28 19:02:10.000000000 -0500
3712 @@ -0,0 +1,15 @@
3714 + * Copyright (C) 2004 Atmel Norway
3715 + */
3717 +       .text
3718 +       .global bcopy
3719 +       .type   bcopy, @function
3720 +       .align  1
3721 +bcopy:
3722 +       /* Swap the first two arguments */
3723 +       eor     r11, r12
3724 +       eor     r12, r11
3725 +       eor     r11, r12
3726 +       rjmp    __memmove
3727 +       .size   bcopy, . - bcopy
3728 diff -Nrup a/libc/string/avr32/bzero.S b/libc/string/avr32/bzero.S
3729 --- a/libc/string/avr32/bzero.S 1969-12-31 19:00:00.000000000 -0500
3730 +++ b/libc/string/avr32/bzero.S 2008-02-28 19:02:10.000000000 -0500
3731 @@ -0,0 +1,12 @@
3733 + * Copyright (C) 2004 Atmel Norway
3734 + */
3736 +       .text
3737 +       .global bzero
3738 +       .type   bzero, @function
3739 +       .align  1
3740 +bzero:
3741 +       mov     r10, r11
3742 +       mov     r11, 0
3743 +       rjmp    __memset
3744 diff -Nrup a/libc/string/avr32/Makefile b/libc/string/avr32/Makefile
3745 --- a/libc/string/avr32/Makefile        1969-12-31 19:00:00.000000000 -0500
3746 +++ b/libc/string/avr32/Makefile        2008-02-28 19:02:10.000000000 -0500
3747 @@ -0,0 +1,40 @@
3748 +# Makefile for uClibc
3750 +# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
3752 +# This program is free software; you can redistribute it and/or modify it under
3753 +# the terms of the GNU Library General Public License as published by the Free
3754 +# Software Foundation; either version 2 of the License, or (at your option) any
3755 +# later version.
3757 +# This program is distributed in the hope that it will be useful, but WITHOUT
3758 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3759 +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
3760 +# details.
3762 +# You should have received a copy of the GNU Library General Public License
3763 +# along with this program; if not, write to the Free Software Foundation, Inc.,
3764 +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3766 +TOPDIR=../../../
3767 +include $(TOPDIR)Rules.mak
3769 +SSRC   := bcopy.S bzero.S memcmp.S memcpy.S memmove.S
3770 +SSRC   += memset.S strcmp.S strlen.S
3771 +# memchr.S, strcat.S, strcpy.S, strncpy.S is broken
3772 +SOBJS  := $(patsubst %.S,%.o, $(SSRC))
3773 +OBJS   := $(SOBJS)
3775 +OBJ_LIST:= ../../obj.string.$(TARGET_ARCH)
3777 +all: $(OBJ_LIST)
3779 +$(OBJ_LIST): $(OBJS)
3780 +       echo $(addprefix string/$(TARGET_ARCH)/, $(OBJS)) > $@
3782 +$(SOBJS): %.o: %.S
3783 +       $(CC) $(ASFLAGS) -c $< -o $@
3784 +       $(STRIPTOOL) -x -R .note -R .comment $@
3786 +clean:
3787 +       $(RM) *.[oa] *~ core
3788 diff -Nrup a/libc/string/avr32/memchr.S b/libc/string/avr32/memchr.S
3789 --- a/libc/string/avr32/memchr.S        1969-12-31 19:00:00.000000000 -0500
3790 +++ b/libc/string/avr32/memchr.S        2008-02-28 19:02:10.000000000 -0500
3791 @@ -0,0 +1,62 @@
3793 + * Copyright (C) 2004 Atmel Norway
3794 + */
3796 +#define str r12
3797 +#define chr r11
3798 +#define len r10
3800 +       .text
3801 +       .global memchr
3802 +       .type   memchr, @function
3803 +memchr:
3804 +       or      chr, chr, chr << 8
3805 +       or      chr, chr, chr << 16
3807 +       mov     r9, str
3808 +       andl    r9, 3, COH
3809 +       brne    .Lunaligned_str
3811 +1:     sub     len, 4
3812 +       brlt    2f
3813 +       ld.w    r8, str++
3814 +       psub.b  r9, r8, r11
3815 +       tnbz    r9
3816 +       brne    1b
3818 +       sub     str, 4
3819 +       bfextu  r9, r8, 24, 8
3820 +       cp.b    r9, r11
3821 +       reteq   str
3822 +       sub     str, -1
3823 +       bfextu  r9, r8, 16, 8
3824 +       cp.b    r9, r11
3825 +       reteq   str
3826 +       sub     str, -1
3827 +       bfextu  r9, r8, 8, 8
3828 +       cp.b    r9, r11
3829 +       reteq   str
3830 +       sub     str, -1
3831 +       retal   str
3833 +2:     sub     len, -4
3834 +       reteq   0
3836 +3:     ld.ub   r8, str++
3837 +       cp.w    r8, 0
3838 +       reteq   str
3839 +       sub     len, 1
3840 +       brne    3b
3842 +       retal   0
3844 +.Lunaligned_str:
3845 +1:     sub     len, 1
3846 +       retlt   0
3847 +       ld.ub   r8, str++
3848 +       cp.b    r8, r11
3849 +       reteq   str
3850 +       sub     r9, 1
3851 +       brge    1b
3853 +       rjmp    .Laligned_search
3854 diff -Nrup a/libc/string/avr32/memcmp.S b/libc/string/avr32/memcmp.S
3855 --- a/libc/string/avr32/memcmp.S        1969-12-31 19:00:00.000000000 -0500
3856 +++ b/libc/string/avr32/memcmp.S        2008-02-28 19:02:10.000000000 -0500
3857 @@ -0,0 +1,50 @@
3859 + * Copyright (C) 2004 Atmel Norway.
3860 + */
3862 +#define s1 r12
3863 +#define s2 r11
3864 +#define len r10
3866 +       .text
3867 +       .global memcmp
3868 +       .type   memcmp, @function
3869 +       .align  1
3870 +memcmp:
3871 +       sub     len, 4
3872 +       brlt    .Lless_than_4
3874 +1:     ld.w    r8, s1++
3875 +       ld.w    r9, s2++
3876 +       cp.w    r8, r9
3877 +       brne    .Lfound_word
3878 +       sub     len, 4
3879 +       brge    1b
3881 +.Lless_than_4:
3882 +       sub     len, -4
3883 +       reteq   0
3885 +1:     ld.ub   r8, s1++
3886 +       ld.ub   r9, s2++
3887 +       sub     r8, r9
3888 +       retne   r8
3889 +       sub     len, 1
3890 +       brgt    1b
3892 +       retal   0
3894 +.Lfound_word:
3895 +       psub.b  r9, r8, r9
3896 +       bfextu  r8, r9, 24, 8
3897 +       retne   r8
3898 +       bfextu  r8, r9, 16, 8
3899 +       retne   r8
3900 +       bfextu  r8, r9, 8, 8
3901 +       retne   r8
3902 +       retal   r9
3904 +       .size   memcmp, . - memcmp
3906 +       .weak   bcmp
3907 +       bcmp = memcmp
3908 diff -Nrup a/libc/string/avr32/memcpy.S b/libc/string/avr32/memcpy.S
3909 --- a/libc/string/avr32/memcpy.S        1969-12-31 19:00:00.000000000 -0500
3910 +++ b/libc/string/avr32/memcpy.S        2008-02-28 19:02:10.000000000 -0500
3911 @@ -0,0 +1,110 @@
3913 + * Copyright (C) 2004 Atmel Norway
3914 + */
3916 +/* Don't use r12 as dst since we must return it unmodified */
3917 +#define dst r9
3918 +#define src r11
3919 +#define len r10
3921 +       .text
3922 +       .global memcpy
3923 +       .type   memcpy, @function
3925 +       .global __memcpy
3926 +       .hidden __memcpy
3927 +       .type   __memcpy, @function
3928 +memcpy:
3929 +__memcpy:
3930 +       pref    src[0]
3931 +       mov     dst, r12
3933 +       /* If we have less than 32 bytes, don't do anything fancy */
3934 +       cp.w    len, 32
3935 +       brge    .Lmore_than_31
3937 +       sub     len, 1
3938 +       retlt   r12
3939 +1:     ld.ub   r8, src++
3940 +       st.b    dst++, r8
3941 +       sub     len, 1
3942 +       brge    1b
3943 +       retal   r12
3945 +.Lmore_than_31:
3946 +       pushm   r0-r7, lr
3948 +       /* Check alignment */
3949 +       mov     r8, src
3950 +       andl    r8, 31, COH
3951 +       brne    .Lunaligned_src
3952 +       mov     r8, dst
3953 +       andl    r8, 3, COH
3954 +       brne    .Lunaligned_dst
3956 +.Laligned_copy:
3957 +       sub     len, 32
3958 +       brlt    .Lless_than_32
3960 +1:     /* Copy 32 bytes at a time */
3961 +       ldm     src, r0-r7
3962 +       sub     src, -32
3963 +       stm     dst, r0-r7
3964 +       sub     dst, -32
3965 +       sub     len, 32
3966 +       brge    1b
3968 +.Lless_than_32:
3969 +       /* Copy 16 more bytes if possible */
3970 +       sub     len, -16
3971 +       brlt    .Lless_than_16
3972 +       ldm     src, r0-r3
3973 +       sub     src, -16
3974 +       sub     len, 16
3975 +       stm     dst, r0-r3
3976 +       sub     dst, -16
3978 +.Lless_than_16:
3979 +       /* Do the remaining as byte copies */
3980 +       neg     len
3981 +       add     pc, pc, len << 2
3982 +       .rept   15
3983 +       ld.ub   r0, src++
3984 +       st.b    dst++, r0
3985 +       .endr
3987 +       popm    r0-r7, pc
3989 +.Lunaligned_src:
3990 +       /* Make src cacheline-aligned. r8 = (src & 31) */
3991 +       rsub    r8, r8, 32
3992 +       sub     len, r8
3993 +1:     ld.ub   r0, src++
3994 +       st.b    dst++, r0
3995 +       sub     r8, 1
3996 +       brne    1b
3998 +       /* If dst is word-aligned, we're ready to go */
3999 +       pref    src[0]
4000 +       mov     r8, 3
4001 +       tst     dst, r8
4002 +       breq    .Laligned_copy
4004 +.Lunaligned_dst:
4005 +       /* src is aligned, but dst is not. Expect bad performance */
4006 +       sub     len, 4
4007 +       brlt    2f
4008 +1:     ld.w    r0, src++
4009 +       st.w    dst++, r0
4010 +       sub     len, 4
4011 +       brge    1b
4013 +2:     neg     len
4014 +       add     pc, pc, len << 2
4015 +       .rept   3
4016 +       ld.ub   r0, src++
4017 +       st.b    dst++, r0
4018 +       .endr
4020 +       popm    r0-r7, pc
4021 +       .size   memcpy, . - memcpy
4022 diff -Nrup a/libc/string/avr32/memmove.S b/libc/string/avr32/memmove.S
4023 --- a/libc/string/avr32/memmove.S       1969-12-31 19:00:00.000000000 -0500
4024 +++ b/libc/string/avr32/memmove.S       2008-02-28 19:02:10.000000000 -0500
4025 @@ -0,0 +1,114 @@
4027 + * Copyright (C) 2004 Atmel Norway
4028 + */
4030 +#define dst r12
4031 +#define src r11
4032 +#define len r10
4034 +       .text
4035 +       .global memmove
4036 +       .type   memmove, @function
4038 +       .global __memmove
4039 +       .hidden __memmove
4040 +       .type   __memmove, @function
4041 +memmove:
4042 +__memmove:
4043 +       cp.w    src, dst
4044 +       brge    __memcpy
4046 +       add     dst, len
4047 +       add     src, len
4048 +       pref    src[-1]
4050 +       /*
4051 +        * The rest is basically the same as in memcpy.S except that
4052 +        * the direction is reversed.
4053 +        */
4054 +       cp.w    len, 32
4055 +       brge    .Lmore_than_31
4057 +       sub     len, 1
4058 +       retlt   r12
4059 +1:     ld.ub   r8, --src
4060 +       st.b    --dst, r8
4061 +       sub     len, 1
4062 +       brge    1b
4063 +       retal   r12
4065 +.Lmore_than_31:
4066 +       pushm   r0-r7, lr
4068 +       /* Check alignment */
4069 +       mov     r8, src
4070 +       andl    r8, 31, COH
4071 +       brne    .Lunaligned_src
4072 +       mov     r8, r12
4073 +       andl    r8, 3, COH
4074 +       brne    .Lunaligned_dst
4076 +.Laligned_copy:
4077 +       sub     len, 32
4078 +       brlt    .Lless_than_32
4080 +1:     /* Copy 32 bytes at a time */
4081 +       sub     src, 32
4082 +       ldm     src, r0-r7
4083 +       sub     dst, 32
4084 +       sub     len, 32
4085 +       stm     dst, r0-r7
4086 +       brge    1b
4088 +.Lless_than_32:
4089 +       /* Copy 16 more bytes if possible */
4090 +       sub     len, -16
4091 +       brlt    .Lless_than_16
4092 +       sub     src, 16
4093 +       ldm     src, r0-r3
4094 +       sub     dst, 16
4095 +       sub     len, 16
4096 +       stm     dst, r0-r3
4098 +.Lless_than_16:
4099 +       /* Do the remaining as byte copies */
4100 +       sub     len, -16
4101 +       breq    2f
4102 +1:     ld.ub   r0, --src
4103 +       st.b    --dst, r0
4104 +       sub     len, 1
4105 +       brne    1b
4107 +2:     popm    r0-r7, pc
4109 +.Lunaligned_src:
4110 +       /* Make src cacheline-aligned. r8 = (src & 31) */
4111 +       sub     len, r8
4112 +1:     ld.ub   r0, --src
4113 +       st.b    --dst, r0
4114 +       sub     r8, 1
4115 +       brne    1b
4117 +       /* If dst is word-aligned, we're ready to go */
4118 +       pref    src[-4]
4119 +       mov     r8, 3
4120 +       tst     dst, r8
4121 +       breq    .Laligned_copy
4123 +.Lunaligned_dst:
4124 +       /* src is aligned, but dst is not. Expect bad performance */
4125 +       sub     len, 4
4126 +       brlt    2f
4127 +1:     ld.w    r0, --src
4128 +       st.w    --dst, r0
4129 +       sub     len, 4
4130 +       brge    1b
4132 +2:     neg     len
4133 +       add     pc, pc, len << 2
4134 +       .rept   3
4135 +       ld.ub   r0, --src
4136 +       st.b    --dst, r0
4137 +       .endr
4139 +       popm    r0-r7, pc
4140 diff -Nrup a/libc/string/avr32/memset.S b/libc/string/avr32/memset.S
4141 --- a/libc/string/avr32/memset.S        1969-12-31 19:00:00.000000000 -0500
4142 +++ b/libc/string/avr32/memset.S        2008-02-28 19:02:10.000000000 -0500
4143 @@ -0,0 +1,60 @@
4145 + * Copyright (C) 2004 Atmel Norway.
4146 + */
4148 +#define s r12
4149 +#define c r11
4150 +#define n r10
4152 +       .text
4153 +       .global memset
4154 +       .type   memset, @function
4156 +       .global __memset
4157 +       .hidden __memset
4158 +       .type   __memset, @function
4160 +       .align  1
4161 +memset:
4162 +__memset:
4163 +       cp.w    n, 32
4164 +       mov     r9, s
4165 +       brge    .Llarge_memset
4167 +       sub     n, 1
4168 +       retlt   s
4169 +1:     st.b    s++, c
4170 +       sub     n, 1
4171 +       brge    1b
4173 +       retal   r9
4175 +.Llarge_memset:
4176 +       mov     r8, r11
4177 +       mov     r11, 3
4178 +       bfins   r8, r8, 8, 8
4179 +       bfins   r8, r8, 16, 16
4180 +       tst     s, r11
4181 +       breq    2f
4183 +1:     st.b    s++, r8
4184 +       sub     n, 1
4185 +       tst     s, r11
4186 +       brne    1b
4188 +2:     mov     r11, r9
4189 +       mov     r9, r8
4190 +       sub     n, 8
4192 +3:     st.d    s++, r8
4193 +       sub     n, 8
4194 +       brge    3b
4196 +       /* If we are done, n == -8 and we'll skip all st.b insns below */
4197 +       neg     n
4198 +       lsl     n, 1
4199 +       add     pc, n
4200 +       .rept   7
4201 +       st.b    s++, r8
4202 +       .endr
4203 +       retal   r11
4204 diff -Nrup a/libc/string/avr32/strcat.S b/libc/string/avr32/strcat.S
4205 --- a/libc/string/avr32/strcat.S        1969-12-31 19:00:00.000000000 -0500
4206 +++ b/libc/string/avr32/strcat.S        2008-02-28 19:02:10.000000000 -0500
4207 @@ -0,0 +1,95 @@
4209 + * Copyright (C) 2004 Atmel Norway
4210 + */
4212 +#define s1 r9
4213 +#define s2 r11
4215 +       .text
4216 +       .global strcat
4217 +       .type   strcat, @function
4218 +       .align  1
4219 +strcat:
4220 +       mov     s1, r12
4222 +       /* Make sure s1 is word-aligned */
4223 +       mov     r10, s1
4224 +       andl    r10, 3, COH
4225 +       breq    2f
4227 +       add     pc, pc, r10 << 3
4228 +       sub     r0, r0, 0       /* 4-byte nop */
4229 +       ld.ub   r8, s1++
4230 +       sub     r8, r8, 0
4231 +       breq    2f
4232 +       ld.ub   r8, s1++
4233 +       sub     r8, r8, 0
4234 +       breq    3f
4235 +       ld.ub   r8, s1++
4236 +       sub     r8, r8, 0
4237 +       breq    4f
4239 +       /* Find the end of the first string */
4240 +5:     ld.w    r8, s1++
4241 +       tnbz    r8
4242 +       brne    5b
4244 +       sub     s1, 4
4246 +       bfextu  r10, r8, 24, 8
4247 +       cp.w    r10, 0
4248 +       breq    1f
4249 +       sub     s1, -1
4250 +       bfextu  r10, r8, 16, 8
4251 +       cp.w    r10, 0
4252 +       breq    2f
4253 +       sub     s1, -1
4254 +       bfextu  r10, r8, 8, 8
4255 +       cp.w    r10, 0
4256 +       breq    3f
4257 +       sub     s1, -1
4258 +       rjmp    4f
4260 +       /* Now, append s2 */
4261 +1:     ld.ub   r8, s2++
4262 +       st.b    s1++, r8
4263 +       cp.w    r8, 0
4264 +       reteq   r12
4265 +2:     ld.ub   r8, s2++
4266 +       st.b    s1++, r8
4267 +       cp.w    r8, 0
4268 +       reteq   r12
4269 +3:     ld.ub   r8, s2++
4270 +       st.b    s1++, r8
4271 +       cp.w    r8, 0
4272 +       reteq   r12
4273 +4:     ld.ub   r8, s2++
4274 +       st.b    s1++, r8
4275 +       cp.w    r8, 0
4276 +       reteq   r12
4278 +       /* Copy one word at a time */
4279 +       ld.w    r8, s2++
4280 +       tnbz    r8
4281 +       breq    2f
4282 +1:     st.w    r8, s2++
4283 +       ld.w    r8, s2++
4284 +       tnbz    r8
4285 +       brne    1b
4287 +       /* Copy the remaining bytes */
4288 +       bfextu  r10, r8, 24, 8
4289 +       st.b    s1++, r10
4290 +       cp.w    r10, 0
4291 +       reteq   r12
4292 +       bfextu  r10, r8, 16, 8
4293 +       st.b    s1++, r10
4294 +       cp.w    r10, 0
4295 +       reteq   r12
4296 +       bfextu  r10, r8, 8, 8
4297 +       st.b    s1++, r10
4298 +       cp.w    r10, 0
4299 +       reteq   r12
4300 +       st.b    s1++, r8
4301 +       retal   r12
4302 +       .size   strcat, . - strcat
4303 diff -Nrup a/libc/string/avr32/strcmp.S b/libc/string/avr32/strcmp.S
4304 --- a/libc/string/avr32/strcmp.S        1969-12-31 19:00:00.000000000 -0500
4305 +++ b/libc/string/avr32/strcmp.S        2008-02-28 19:02:10.000000000 -0500
4306 @@ -0,0 +1,80 @@
4308 + * Copyright (C) 2004 Atmel Norway.
4309 + */
4311 +#define s1 r12
4312 +#define s2 r11
4313 +#define len r10
4315 +       .text
4316 +       .global strcmp
4317 +       .type   strcmp, @function
4318 +       .align  1
4319 +strcmp:
4320 +       mov     r8, 3
4321 +       tst     s1, r8
4322 +       brne    .Lunaligned_s1
4323 +       tst     s2, r8
4324 +       brne    .Lunaligned_s2
4326 +1:     ld.w    r8, s1++
4327 +       ld.w    r9, s2++
4328 +       cp.w    r8, r9
4329 +       brne    2f
4330 +       tnbz    r8
4331 +       brne    1b
4332 +       retal   0
4334 +2:     bfextu  r12, r8, 24, 8
4335 +       bfextu  r11, r9, 24, 8
4336 +       sub     r12, r11
4337 +       retne   r12
4338 +       cp.w    r11, 0
4339 +       reteq   0
4340 +       bfextu  r12, r8, 16, 8
4341 +       bfextu  r11, r9, 16, 8
4342 +       sub     r12, r11
4343 +       retne   r12
4344 +       cp.w    r11, 0
4345 +       reteq   0
4346 +       bfextu  r12, r8, 8, 8
4347 +       bfextu  r11, r9, 8, 8
4348 +       sub     r12, r11
4349 +       retne   r12
4350 +       cp.w    r11, 0
4351 +       reteq   0
4352 +       bfextu  r12, r8, 0, 8
4353 +       bfextu  r11, r9, 0, 8
4354 +       sub     r12, r11
4355 +       retal   r12
4357 +.Lunaligned_s1:
4358 +3:     tst     s1, r8
4359 +       breq    4f
4360 +       ld.ub   r10, s1++
4361 +       ld.ub   r9, s2++
4362 +       sub     r10, r9
4363 +       retne   r10
4364 +       cp.w    r9, 0
4365 +       brne    3b
4366 +       retal   r10
4368 +4:     tst     s2, r8
4369 +       breq    1b
4371 +.Lunaligned_s2:
4372 +       /*
4373 +        * s1 and s2 can't both be aligned, and unaligned word loads
4374 +        * can trigger spurious exceptions if we cross a page boundary.
4375 +        * Do it the slow way...
4376 +        */
4377 +1:     ld.ub   r8, s1++
4378 +       ld.ub   r9, s2++
4379 +       sub     r8, r9
4380 +       retne   r8
4381 +       cp.w    r9, 0
4382 +       brne    1b
4383 +       retal   0
4385 +       .weak   strcoll
4386 +       strcoll = strcmp
4387 diff -Nrup a/libc/string/avr32/strcpy.S b/libc/string/avr32/strcpy.S
4388 --- a/libc/string/avr32/strcpy.S        1969-12-31 19:00:00.000000000 -0500
4389 +++ b/libc/string/avr32/strcpy.S        2008-02-28 19:02:10.000000000 -0500
4390 @@ -0,0 +1,63 @@
4392 + * Copyright (C) 2004 Atmel Norway
4393 + *
4394 + * To reduce the size, this one might simply call strncpy with len = -1.
4395 + */
4397 +#define dst r9
4398 +#define src r11
4400 +       .text
4401 +       .global strcpy
4402 +       .type   strcpy, @function
4403 +strcpy:
4404 +       mov     dst, r12
4406 +       pref    src[0]
4408 +       /*
4409 +        * Check alignment. If src is aligned but dst isn't, we can't
4410 +        * do much about it...
4411 +        */
4412 +       mov     r8, src
4413 +       andl    r8, 3 COH
4414 +       brne    .Lunaligned_src
4416 +.Laligned_copy:
4417 +1:     ld.w    r8, src++
4418 +       tnbz    r8
4419 +       breq    2f
4420 +       st.w    dst++, r8
4421 +       rjmp    1b
4423 +2:     /*
4424 +        * Ok, r8 now contains the terminating '\0'. Copy the
4425 +        * remaining bytes individually.
4426 +        */
4427 +       bfextu  r10, r8, 24, 8
4428 +       st.b    dst++, r10
4429 +       cp.w    r10, 0
4430 +       reteq   r12
4431 +       bfextu  r10, r8, 16, 8
4432 +       st.b    dst++, r10
4433 +       cp.w    r10, 0
4434 +       reteq   r12
4435 +       bfextu  r10, r8, 8, 8
4436 +       st.b    dst++, r10
4437 +       cp.w    r10, 0
4438 +       reteq   r12
4439 +       st.b    dst++, r8
4440 +       retal   r12
4442 +.Lunaligned_src:
4443 +       /* Copy bytes until we're aligned */
4444 +       rsub    r8, r8, 4
4445 +       add     pc, pc, r8 << 3
4446 +       nop
4447 +       nop
4448 +       ld.ub   r10, src++
4449 +       st.b    dst++, r10
4450 +       cp.w    r10, 0
4451 +       reteq   r12
4453 +       rjmp    .Laligned_copy
4454 diff -Nrup a/libc/string/avr32/stringtest.c b/libc/string/avr32/stringtest.c
4455 --- a/libc/string/avr32/stringtest.c    1969-12-31 19:00:00.000000000 -0500
4456 +++ b/libc/string/avr32/stringtest.c    2008-02-28 19:02:10.000000000 -0500
4457 @@ -0,0 +1,144 @@
4459 +#include <stdio.h>
4460 +#include <string.h>
4461 +#include <time.h>
4462 +#include <sys/mman.h>
4464 +#define BUF_SIZE (8 * 1024)
4466 +static char *buf1;
4467 +static char *buf1_ref;
4468 +static char *buf2;
4470 +extern void *optimized_memcpy(void *dest, void *src, size_t len);
4471 +extern void *optimized_memmove(void *dest, void *src, size_t len);
4472 +extern char *optimized_strcpy(char *dest, char *src);
4473 +extern char *optimized_strncpy(char *dest, char *src, size_t len);
4475 +void dump_mismatch(char *buf, char *ref, size_t len)
4477 +       int i, j;
4479 +       for (i = 0; i < len; i += 16) {
4480 +               if (memcmp(buf + i, ref + i, 16) == 0)
4481 +                       continue;
4483 +               printf("%4x buf:", i);
4484 +               for (j = i; j < (i + 16); j++)
4485 +                       printf(" %02x", buf[j]);
4486 +               printf("\n     ref:");
4487 +               for (j = i; j < (i + 16); j++)
4488 +                       printf(" %02x", ref[j]);
4489 +               printf("\n");
4490 +       }
4493 +static void test_memcpy(int src_offset, int dst_offset, int len)
4495 +       clock_t start, old, new;
4496 +       int i;
4498 +       memset(buf1, 0x55, BUF_SIZE);
4499 +       memset(buf1_ref, 0x55, BUF_SIZE);
4500 +       memset(buf2, 0xaa, BUF_SIZE);
4502 +       printf("Testing memcpy with offsets %d => %d and len %d...",
4503 +              src_offset, dst_offset, len);
4505 +       start = clock();
4506 +       for (i = 0; i < 8192; i++)
4507 +               optimized_memcpy(buf1 + dst_offset, buf2 + src_offset, len);
4508 +       new = clock() - start;
4509 +       start = clock();
4510 +       for ( i = 0; i < 8192; i++)
4511 +               memcpy(buf1_ref + dst_offset, buf2 + src_offset, len);
4512 +       old = clock() - start;
4514 +       if (memcmp(buf1, buf1_ref, BUF_SIZE) == 0)
4515 +               printf("OK\n");
4516 +       else {
4517 +               printf("FAILED\n");
4518 +               dump_mismatch(buf1, buf1_ref, BUF_SIZE);
4519 +       }
4520 +       printf("CPU time used: %d vs. %d\n", new, old);
4523 +static void test_memmove(int src_offset, int dst_offset, int len)
4525 +       clock_t start, old, new;
4527 +       memset(buf1, 0x55, BUF_SIZE);
4528 +       memset(buf1_ref, 0x55, BUF_SIZE);
4529 +       memset(buf2, 0xaa, BUF_SIZE);
4531 +       printf("Testing memmove with offsets %d => %d and len %d...",
4532 +              src_offset, dst_offset, len);
4534 +       start = clock();
4535 +       optimized_memmove(buf1 + dst_offset, buf2 + src_offset, len);
4536 +       new = clock() - start;
4537 +       start = clock();
4538 +       memmove(buf1_ref + dst_offset, buf2 + src_offset, len);
4539 +       old = clock() - start;
4541 +       if (memcmp(buf1, buf1_ref, BUF_SIZE) == 0)
4542 +               printf("OK\n");
4543 +       else {
4544 +               printf("FAILED\n");
4545 +               dump_mismatch(buf1, buf1_ref, BUF_SIZE);
4546 +       }
4547 +       printf("CPU time used: %d vs. %d\n", new, old);
4550 +int main(int argc, char *argv[])
4552 +       buf2 = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
4553 +                   MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
4554 +       if (buf2 == MAP_FAILED) {
4555 +               perror("Failed to allocate memory for buf2");
4556 +               return 1;
4557 +       }
4558 +       buf1 = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
4559 +                   MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
4560 +       if (buf1 == MAP_FAILED) {
4561 +               perror("Failed to allocate memory for buf1");
4562 +               return 1;
4563 +       }
4564 +       buf1_ref = mmap(NULL, BUF_SIZE, PROT_READ | PROT_WRITE,
4565 +                       MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
4566 +       if (buf1_ref == MAP_FAILED) {
4567 +               perror("Failed to allocate memory for buf1_ref");
4568 +               return 1;
4569 +       }
4570 +       printf("\n === MEMCPY ===\n\n");
4572 +       test_memcpy(0, 0, BUF_SIZE - 32);
4573 +       test_memcpy(0, 0, 1);
4574 +       test_memcpy(0, 0, 31);
4575 +       test_memcpy(0, 0, 32);
4576 +       test_memcpy(0, 0, 127);
4577 +       test_memcpy(0, 0, 128);
4578 +       test_memcpy(4, 4, BUF_SIZE - 32 - 4);
4579 +       test_memcpy(1, 1, BUF_SIZE - 32 - 1);
4580 +       test_memcpy(1, 1, 126);
4581 +       test_memcpy(0, 3, 128);
4582 +       test_memcpy(1, 4, 128);
4583 +       test_memcpy(0, 0, 0);
4585 +       printf("\n === MEMMOVE ===\n\n");
4587 +       test_memmove(0, 0, BUF_SIZE - 32);
4588 +       test_memmove(0, 0, 1);
4589 +       test_memmove(0, 0, 31);
4590 +       test_memmove(0, 0, 32);
4591 +       test_memmove(0, 0, BUF_SIZE - 33);
4592 +       test_memmove(0, 0, 128);
4593 +       test_memmove(4, 4, BUF_SIZE - 32 - 4);
4594 +       test_memmove(1, 1, BUF_SIZE - 32 - 1);
4595 +       test_memmove(1, 1, BUF_SIZE - 130);
4596 +       test_memmove(0, 3, BUF_SIZE - 128);
4597 +       test_memmove(1, 4, BUF_SIZE - 128);
4598 +       test_memmove(0, 0, 0);
4600 +       return 0;
4602 diff -Nrup a/libc/string/avr32/strlen.S b/libc/string/avr32/strlen.S
4603 --- a/libc/string/avr32/strlen.S        1969-12-31 19:00:00.000000000 -0500
4604 +++ b/libc/string/avr32/strlen.S        2008-02-28 19:02:10.000000000 -0500
4605 @@ -0,0 +1,52 @@
4607 + * Copyright (C) 2004 Atmel Norway
4608 + */
4610 +#define str r12
4612 +       .text
4613 +       .global strlen
4614 +       .type   strlen, @function
4615 +strlen:
4616 +       mov     r11, r12
4618 +       mov     r9, str
4619 +       andl    r9, 3, COH
4620 +       brne    .Lunaligned_str
4622 +1:     ld.w    r8, str++
4623 +       tnbz    r8
4624 +       brne    1b
4626 +       sub     r12, r11
4627 +       bfextu  r9, r8, 24, 8
4628 +       cp.w    r9, 0
4629 +       subeq   r12, 4
4630 +       reteq   r12
4631 +       bfextu  r9, r8, 16, 8
4632 +       cp.w    r9, 0
4633 +       subeq   r12, 3
4634 +       reteq   r12
4635 +       bfextu  r9, r8, 8, 8
4636 +       cp.w    r9, 0
4637 +       subeq   r12, 2
4638 +       reteq   r12
4639 +       sub     r12, 1
4640 +       retal   r12
4642 +.Lunaligned_str:
4643 +       add     pc, pc, r9 << 3
4644 +       sub     r0, r0, 0       /* 4-byte nop */
4645 +       ld.ub   r8, str++
4646 +       sub     r8, r8, 0
4647 +       breq    1f
4648 +       ld.ub   r8, str++
4649 +       sub     r8, r8, 0
4650 +       breq    1f
4651 +       ld.ub   r8, str++
4652 +       sub     r8, r8, 0
4653 +       brne    1b
4655 +1:     sub     r12, 1
4656 +       sub     r12, r11
4657 +       retal   r12
4658 diff -Nrup a/libc/string/avr32/strncpy.S b/libc/string/avr32/strncpy.S
4659 --- a/libc/string/avr32/strncpy.S       1969-12-31 19:00:00.000000000 -0500
4660 +++ b/libc/string/avr32/strncpy.S       2008-02-28 19:02:10.000000000 -0500
4661 @@ -0,0 +1,77 @@
4663 + * Copyright (C) 2004 Atmel Norway
4664 + */
4666 +#define dst r9
4667 +#define src r11
4669 +       .text
4670 +       .global strcpy
4671 +       .type   strncpy, @function
4672 +strncpy:
4673 +       mov     dst, r12
4675 +       pref    src[0]
4676 +       mov     dst, r12
4678 +       /*
4679 +        * Check alignment. If src is aligned but dst isn't, we can't
4680 +        * do much about it...
4681 +        */
4682 +       mov     r8, src
4683 +       andl    r8, 3 COH
4684 +       brne    .Lunaligned_src
4686 +.Laligned_copy:
4687 +       sub     r10, 4
4688 +       brlt    3f
4689 +1:     ld.w    r8, src++
4690 +       tnbz    r8
4691 +       breq    2f
4692 +       st.w    dst++, r8
4693 +       sub     r10, 4
4694 +       brne    1b
4696 +3:     sub     r10, -4
4697 +       reteq   r12
4699 +       /* This is safe as long as src is word-aligned and r10 > 0 */
4700 +       ld.w    r8, src++
4702 +2:     /*
4703 +        * Ok, r8 now contains the terminating '\0'. Copy the
4704 +        * remaining bytes individually.
4705 +        */
4706 +       bfextu  r11, r8, 24, 8
4707 +       st.b    dst++, r11
4708 +       cp.w    r11, 0
4709 +       reteq   r12
4710 +       sub     r10, 1
4711 +       reteq   r12
4712 +       bfextu  r11, r8, 16, 8
4713 +       st.b    dst++, r11
4714 +       cp.w    r11, 0
4715 +       reteq   r12
4716 +       sub     r10, 1
4717 +       reteq   r12
4718 +       bfextu  r11, r8, 8, 8
4719 +       st.b    dst++, r11
4720 +       cp.w    r11, 0
4721 +       reteq   r12
4722 +       sub     r10, 1
4723 +       reteq   r12
4724 +       st.b    dst++, r8
4725 +       retal   r12
4727 +.Lunaligned_src:
4728 +       /* Copy bytes until we're aligned */
4729 +       min     r8, r8, r10
4730 +       sub     r10, r8
4731 +       sub     r8, 1
4732 +       retlt   r12
4733 +1:     ld.ub   r10, src++
4734 +       st.b    dst++, r10
4735 +       sub     r8, 1
4736 +       brge    1b
4738 +       rjmp    .Laligned_copy
4739 diff -Nrup a/libc/string/avr32/test_memcpy.c b/libc/string/avr32/test_memcpy.c
4740 --- a/libc/string/avr32/test_memcpy.c   1969-12-31 19:00:00.000000000 -0500
4741 +++ b/libc/string/avr32/test_memcpy.c   2008-02-28 19:02:10.000000000 -0500
4742 @@ -0,0 +1,66 @@
4744 +#include <stdio.h>
4745 +#include <string.h>
4747 +#define BUF_SIZE 32768
4749 +static char buf1[BUF_SIZE] __attribute__((aligned(32)));
4750 +static char buf1_ref[BUF_SIZE] __attribute__((aligned(32)));
4751 +static char buf2[BUF_SIZE] __attribute__((aligned(32)));
4753 +extern void *new_memcpy(void *dest, void *src, size_t len);
4755 +void dump_mismatch(char *buf, char *ref, size_t len)
4757 +       int i, j;
4759 +       for (i = 0; i < len; i += 16) {
4760 +               if (memcmp(buf + i, ref + i, 16) == 0)
4761 +                       continue;
4763 +               printf("% 4x buf:", i);
4764 +               for (j = i; j < (i + 16); j++)
4765 +                       printf(" %02x", buf[j]);
4766 +               printf("\n     ref:");
4767 +               for (j = i; j < (i + 16); j++)
4768 +                       printf(" %02x", ref[j]);
4769 +               printf("\n");
4770 +       }
4773 +void test(int src_offset, int dst_offset, int len)
4775 +       memset(buf1, 0x55, sizeof(buf1));
4776 +       memset(buf1_ref, 0x55, sizeof(buf1_ref));
4777 +       memset(buf2, 0xaa, sizeof(buf2));
4779 +       printf("Testing with offsets %d => %d and len %d...",
4780 +              src_offset, dst_offset, len);
4782 +       new_memcpy(buf1 + dst_offset, buf2 + src_offset, len);
4783 +       memcpy(buf1_ref + dst_offset, buf2 + src_offset, len);
4785 +       if (memcmp(buf1, buf1_ref, sizeof(buf1)) == 0)
4786 +               printf("OK\n");
4787 +       else {
4788 +               printf("FAILED\n");
4789 +               dump_mismatch(buf1, buf1_ref, sizeof(buf1));
4790 +       }
4793 +int main(int argc, char *argv[])
4795 +       test(0, 0, BUF_SIZE);
4796 +       test(0, 0, 1);
4797 +       test(0, 0, 31);
4798 +       test(0, 0, 32);
4799 +       test(0, 0, 127);
4800 +       test(0, 0, 128);
4801 +       test(4, 4, BUF_SIZE - 4);
4802 +       test(1, 1, BUF_SIZE - 1);
4803 +       test(1, 1, 126);
4804 +       test(0, 3, 128);
4805 +       test(1, 4, 128);
4807 +       return 0;
4809 diff -Nrup a/libc/sysdeps/linux/avr32/bits/atomicity.h b/libc/sysdeps/linux/avr32/bits/atomicity.h
4810 --- a/libc/sysdeps/linux/avr32/bits/atomicity.h 1969-12-31 19:00:00.000000000 -0500
4811 +++ b/libc/sysdeps/linux/avr32/bits/atomicity.h 2008-02-28 19:02:10.000000000 -0500
4812 @@ -0,0 +1,86 @@
4813 +/* Low-level functions for atomic operations.  AVR32 version.
4814 +   Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4815 +   This file is part of the GNU C Library.
4817 +   The GNU C Library is free software; you can redistribute it and/or
4818 +   modify it under the terms of the GNU Lesser General Public
4819 +   License as published by the Free Software Foundation; either
4820 +   version 2.1 of the License, or (at your option) any later version.
4822 +   The GNU C Library is distributed in the hope that it will be useful,
4823 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4824 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4825 +   Lesser General Public License for more details.
4827 +   You should have received a copy of the GNU Lesser General Public
4828 +   License along with the GNU C Library; if not, write to the Free
4829 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4830 +   02111-1307 USA.  */
4832 +#ifndef _ATOMICITY_H
4833 +#define _ATOMICITY_H 1
4835 +#include <inttypes.h>
4837 +static inline int
4838 +__attribute__((unused))
4839 +exchange_and_add (volatile uint32_t *mem, int val)
4841 +       int tmp, result;
4843 +       __asm__ __volatile__(
4844 +               "/* Inline exchange and add */\n"
4845 +               "1:     ssrf    5\n"
4846 +               "       ld.w    %0, %3\n"
4847 +               "       add     %1, %0, %4\n"
4848 +               "       stcond  %2, %1\n"
4849 +               "       brne    1b"
4850 +               : "=&r"(result), "=&r"(tmp), "=m"(*mem)
4851 +               : "m"(*mem), "r"(val)
4852 +               : "cc", "memory");
4854 +       return result;
4857 +static inline void
4858 +__attribute__((unused))
4859 +atomic_add (volatile uin32_t *mem, int val)
4861 +       int result;
4863 +       __asm__ __volatile__(
4864 +               "/* Inline atomic add */\n"
4865 +               "1:     ssrf    5\n"
4866 +               "       ld.w    %0, %2\n"
4867 +               "       add     %0, %3\n"
4868 +               "       stcond  %2, %0\n"
4869 +               "       brne    1b"
4870 +               : "=&r"(result), "=m"(*mem)
4871 +               : "m"(*mem), "r"(val)
4872 +               : "cc", "memory");
4875 +static inline int
4876 +__attribute__((unused))
4877 +compare_and_swap(volatile long int *p, long int oldval, long int newval)
4879 +       long int result, tmp;
4881 +       __asm__ __volatile__(
4882 +               "/* Inline compare and swap */\n"
4883 +               "1:     ssrf    5\n"
4884 +               "       ld.w    %1, %3\n"
4885 +               "       cp.w    %1, %5\n"
4886 +               "       sreq    %0\n"
4887 +               "       brne    2f\n"
4888 +               "       stcond  %2, %4\n"
4889 +               "       brne    1b\n"
4890 +               "2:"
4891 +               : "=&r"(result), "=&r"(tmp), "=m"(*p)
4892 +               : "m"(*p), "r"(newval), "r"(oldval)
4893 +               : "cc", "memory");
4895 +       return result;
4898 +#endif /* atomicity.h */
4899 diff -Nrup a/libc/sysdeps/linux/avr32/bits/byteswap.h b/libc/sysdeps/linux/avr32/bits/byteswap.h
4900 --- a/libc/sysdeps/linux/avr32/bits/byteswap.h  1969-12-31 19:00:00.000000000 -0500
4901 +++ b/libc/sysdeps/linux/avr32/bits/byteswap.h  2008-02-28 19:02:10.000000000 -0500
4902 @@ -0,0 +1,80 @@
4903 +/* Macros to swap the order of bytes in integer values.
4904 +   Copyright (C) 2005 Atmel Norway.
4906 +   The GNU C Library is free software; you can redistribute it and/or
4907 +   modify it under the terms of the GNU Lesser General Public
4908 +   License as published by the Free Software Foundation; either
4909 +   version 2.1 of the License, or (at your option) any later version.
4911 +   The GNU C Library is distributed in the hope that it will be useful,
4912 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
4913 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4914 +   Lesser General Public License for more details.
4916 +   You should have received a copy of the GNU Lesser General Public
4917 +   License along with the GNU C Library; if not, write to the Free
4918 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4919 +   02111-1307 USA.  */
4921 +#if !defined _BYTESWAP_H && !defined _NETINET_IN_H
4922 +# error "Never use <bits/byteswap.h> directly; include <byteswap.h> instead."
4923 +#endif
4925 +#ifndef _BITS_BYTESWAP_H
4926 +#define _BITS_BYTESWAP_H 1
4928 +/* Swap bytes in 16 bit value.  */
4929 +#if defined __GNUC__
4930 +# define __bswap_16(x) (__extension__ __builtin_bswap_16(x))
4931 +#else
4932 +/* This is better than nothing.  */
4933 +static __inline unsigned short int
4934 +__bswap_16 (unsigned short int __bsx)
4936 +       return ((((__bsx) >> 8) & 0xff) | (((__bsx) & 0xff) << 8));
4938 +#endif
4940 +/* Swap bytes in 32 bit value.  */
4941 +#if defined __GNUC__
4942 +# define __bswap_32(x) (__extension__ __builtin_bswap_32(x))
4943 +#else
4944 +static __inline unsigned int
4945 +__bswap_32 (unsigned int __bsx)
4947 +  return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >>  8) |
4948 +         (((__bsx) & 0x0000ff00) <<  8) | (((__bsx) & 0x000000ff) << 24));
4950 +#endif
4952 +#if defined __GNUC__
4953 +/* Swap bytes in 64 bit value.  */
4954 +# define __bswap_constant_64(x)                                \
4955 +       ((((x) & 0xff00000000000000ull) >> 56)          \
4956 +        | (((x) & 0x00ff000000000000ull) >> 40)        \
4957 +        | (((x) & 0x0000ff0000000000ull) >> 24)        \
4958 +        | (((x) & 0x000000ff00000000ull) >> 8)         \
4959 +        | (((x) & 0x00000000ff000000ull) << 8)         \
4960 +        | (((x) & 0x0000000000ff0000ull) << 24)        \
4961 +        | (((x) & 0x000000000000ff00ull) << 40)        \
4962 +        | (((x) & 0x00000000000000ffull) << 56))
4964 +# define __bswap_64(x)                                                 \
4965 +       (__extension__                                                  \
4966 +        ({                                                             \
4967 +                union {                                                \
4968 +                        __extension__ unsigned long long int __ll;     \
4969 +                        unsigned int __l[2];                           \
4970 +                } __w, __r;                                            \
4971 +                if (__builtin_constant_p(x))                           \
4972 +                        __r.__ll = __bswap_constant_64(x);             \
4973 +                else {                                                 \
4974 +                        __w.__ll = (x);                                \
4975 +                        __r.__l[0] = __bswap_32(__w.__l[1]);           \
4976 +                        __r.__l[1] = __bswap_32(__w.__l[0]);           \
4977 +                }                                                      \
4978 +                __r.__ll;                                              \
4979 +        }))
4980 +#endif
4982 +#endif /* _BITS_BYTESWAP_H */
4983 diff -Nrup a/libc/sysdeps/linux/avr32/bits/endian.h b/libc/sysdeps/linux/avr32/bits/endian.h
4984 --- a/libc/sysdeps/linux/avr32/bits/endian.h    1969-12-31 19:00:00.000000000 -0500
4985 +++ b/libc/sysdeps/linux/avr32/bits/endian.h    2008-02-28 19:02:10.000000000 -0500
4986 @@ -0,0 +1,7 @@
4987 +/* AVR32 is big-endian */
4989 +#ifndef _ENDIAN_H
4990 +# error "Never use <bits/endian.h> directly; include <endian.h> instead."
4991 +#endif
4993 +#define __BYTE_ORDER __BIG_ENDIAN
4994 diff -Nrup a/libc/sysdeps/linux/avr32/bits/fcntl.h b/libc/sysdeps/linux/avr32/bits/fcntl.h
4995 --- a/libc/sysdeps/linux/avr32/bits/fcntl.h     1969-12-31 19:00:00.000000000 -0500
4996 +++ b/libc/sysdeps/linux/avr32/bits/fcntl.h     2008-02-28 19:02:10.000000000 -0500
4997 @@ -0,0 +1,168 @@
4999 + * Copyright (C) 2004 Atmel Norway AS
5000 + *
5001 + * This file is part of the Linux kernel
5002 + */
5003 +#ifndef _FCNTL_H
5004 +# error "Never use <bits/fcntl.h> directly; include <fcntl.h> instead."
5005 +#endif
5007 +#include <sys/types.h>
5009 +/* open/fcntl - O_SYNC is only implemented on blocks devices and on files
5010 +   located on an ext2 file system */
5011 +#define O_ACCMODE      00000003
5012 +#define O_RDONLY       00000000
5013 +#define O_WRONLY       00000001
5014 +#define O_RDWR         00000002
5015 +#define O_CREAT                00000100        /* not fcntl */
5016 +#define O_EXCL         00000200        /* not fcntl */
5017 +#define O_NOCTTY       00000400        /* not fcntl */
5018 +#define O_TRUNC                00001000        /* not fcntl */
5019 +#define O_APPEND       00002000
5020 +#define O_NONBLOCK     00004000
5021 +#define O_NDELAY       O_NONBLOCK
5022 +#define O_SYNC         00010000
5023 +#define O_ASYNC                00020000
5025 +#ifdef __USE_GNU
5026 +# define O_DIRECT      00040000        /* must be a directory */
5027 +# define O_DIRECTORY   00200000        /* direct disk access */
5028 +# define O_NOFOLLOW    00400000        /* don't follow links */
5029 +# define O_NOATIME     01000000        /* don't set atime */
5030 +#endif
5032 +#ifdef __USE_LARGEFILE64
5033 +# define O_LARGEFILE   00100000
5034 +#endif
5036 +/* For now Linux has synchronisity options for data and read operations.
5037 +   We define the symbols here but let them do the same as O_SYNC since
5038 +   this is a superset. */
5039 +#if defined __USE_POSIX199309 || defined __USE_UNIX98
5040 +# define O_DSYNC       O_SYNC  /* Synchronize data.  */
5041 +# define O_RSYNC       O_SYNC  /* Synchronize read operations.  */
5042 +#endif
5044 +#define F_DUPFD                0       /* dup */
5045 +#define F_GETFD                1       /* get close_on_exec */
5046 +#define F_SETFD                2       /* set/clear close_on_exec */
5047 +#define F_GETFL                3       /* get file->f_flags */
5048 +#define F_SETFL                4       /* set file->f_flags */
5050 +#ifndef __USE_FILE_OFFSET64
5051 +# define F_GETLK       5
5052 +# define F_SETLK       6
5053 +# define F_SETLKW      7
5054 +#else
5055 +# define F_GETLK       F_GETLK64
5056 +# define F_SETLK       F_SETLK64
5057 +# define F_SETLKW      F_SETLKW64
5058 +#endif
5059 +#define F_GETLK64      12      /*  using 'struct flock64' */
5060 +#define F_SETLK64      13
5061 +#define F_SETLKW64     14
5063 +#if defined __USE_BSD || defined __USE_XOPEN2K
5064 +# define F_SETOWN      8       /*  for sockets. */
5065 +# define F_GETOWN      9       /*  for sockets. */
5066 +#endif
5068 +#ifdef __USE_GNU
5069 +# define F_SETSIG      10      /*  for sockets. */
5070 +# define F_GETSIG      11      /*  for sockets. */
5071 +#endif
5073 +#ifdef __USE_GNU
5074 +# define F_SETLEASE    1024    /* Set a lease.  */
5075 +# define F_GETLEASE    1025    /* Enquire what lease is active.  */
5076 +# define F_NOTIFY      1026    /* Request notfications on a directory.  */
5077 +#endif
5079 +/* for F_[GET|SET]FL */
5080 +#define FD_CLOEXEC     1       /* actually anything with low bit set goes */
5082 +/* for posix fcntl() and lockf() */
5083 +#define F_RDLCK                0
5084 +#define F_WRLCK                1
5085 +#define F_UNLCK                2
5087 +/* for old implementation of bsd flock () */
5088 +#define F_EXLCK                4       /* or 3 */
5089 +#define F_SHLCK                8       /* or 4 */
5091 +/* for leases */
5092 +#define F_INPROGRESS   16
5094 +#ifdef __USE_BSD
5095 +/* operations for bsd flock(), also used by the kernel implementation */
5096 +# define LOCK_SH       1       /* shared lock */
5097 +# define LOCK_EX       2       /* exclusive lock */
5098 +# define LOCK_NB       4       /* or'd with one of the above to prevent
5099 +                                  blocking */
5100 +# define LOCK_UN       8       /* remove lock */
5101 +#endif
5103 +#ifdef __USE_GNU
5104 +# define LOCK_MAND     32      /* This is a mandatory flock */
5105 +# define LOCK_READ     64      /* ... Which allows concurrent
5106 +                                      read operations */
5107 +# define LOCK_WRITE    128     /* ... Which allows concurrent
5108 +                                      write operations */
5109 +# define LOCK_RW       192     /* ... Which allows concurrent
5110 +                                      read & write ops */
5111 +#endif
5113 +#ifdef __USE_GNU
5114 +/* Types of directory notifications that may be requested with F_NOTIFY.  */
5115 +# define DN_ACCESS     0x00000001      /* File accessed.  */
5116 +# define DN_MODIFY     0x00000002      /* File modified.  */
5117 +# define DN_CREATE     0x00000004      /* File created.  */
5118 +# define DN_DELETE     0x00000008      /* File removed.  */
5119 +# define DN_RENAME     0x00000010      /* File renamed.  */
5120 +# define DN_ATTRIB     0x00000020      /* File changed attibutes.  */
5121 +# define DN_MULTISHOT  0x80000000      /* Don't remove notifier.  */
5122 +#endif
5124 +struct flock {
5125 +       short l_type;
5126 +       short l_whence;
5127 +#ifndef __USE_FILE_OFFSET64
5128 +       __off_t l_start;
5129 +       __off_t l_len;
5130 +#else
5131 +       __off64_t l_start;
5132 +       __off64_t l_len;
5133 +#endif
5134 +       __pid_t l_pid;
5137 +#ifdef __USE_LARGEFILE64
5138 +struct flock64 {
5139 +       short  l_type;
5140 +       short  l_whence;
5141 +       __off64_t l_start;
5142 +       __off64_t l_len;
5143 +       __pid_t  l_pid;
5145 +#endif
5147 +/* Define some more compatibility macros to be backward compatible with
5148 + *    BSD systems which did not managed to hide these kernel macros.  */
5149 +#ifdef  __USE_BSD
5150 +# define FAPPEND        O_APPEND
5151 +# define FFSYNC         O_FSYNC
5152 +# define FASYNC         O_ASYNC
5153 +# define FNONBLOCK      O_NONBLOCK
5154 +# define FNDELAY        O_NDELAY
5155 +#endif /* Use BSD.  */
5157 +/* Advise to `posix_fadvise'.  */
5158 +#ifdef __USE_XOPEN2K
5159 +# define POSIX_FADV_NORMAL      0 /* No further special treatment.  */
5160 +# define POSIX_FADV_RANDOM      1 /* Expect random page references.  */
5161 +# define POSIX_FADV_SEQUENTIAL  2 /* Expect sequential page references.  */
5162 +# define POSIX_FADV_WILLNEED    3 /* Will need these pages.  */
5163 +# define POSIX_FADV_DONTNEED    4 /* Don't need these pages.  */
5164 +# define POSIX_FADV_NOREUSE     5 /* Data will be accessed once.  */
5165 +#endif
5166 diff -Nrup a/libc/sysdeps/linux/avr32/bits/kernel_stat.h b/libc/sysdeps/linux/avr32/bits/kernel_stat.h
5167 --- a/libc/sysdeps/linux/avr32/bits/kernel_stat.h       1969-12-31 19:00:00.000000000 -0500
5168 +++ b/libc/sysdeps/linux/avr32/bits/kernel_stat.h       2008-02-28 19:02:10.000000000 -0500
5169 @@ -0,0 +1,63 @@
5170 +#ifndef _BITS_STAT_STRUCT_H
5171 +#define _BITS_STAT_STRUCT_H
5174 + * This file provides struct stat, taken from kernel 2.6.4
5175 + * (include/asm-avr32/stat.h revision 1.1).
5176 + */
5178 +struct kernel_stat {
5179 +        unsigned long st_dev;
5180 +        unsigned long st_ino;
5181 +        unsigned short st_mode;
5182 +        unsigned short st_nlink;
5183 +        unsigned short st_uid;
5184 +        unsigned short st_gid;
5185 +        unsigned long  st_rdev;
5186 +        unsigned long  st_size;
5187 +        unsigned long  st_blksize;
5188 +        unsigned long  st_blocks;
5189 +        unsigned long  st_atime;
5190 +        unsigned long  st_atime_nsec;
5191 +        unsigned long  st_mtime;
5192 +        unsigned long  st_mtime_nsec;
5193 +        unsigned long  st_ctime;
5194 +        unsigned long  st_ctime_nsec;
5195 +        unsigned long  __unused4;
5196 +        unsigned long  __unused5;
5199 +#define STAT_HAVE_NSEC 1
5201 +struct kernel_stat64 {
5202 +       unsigned long long st_dev;
5204 +       unsigned long long st_ino;
5205 +       unsigned int    st_mode;
5206 +       unsigned int    st_nlink;
5208 +       unsigned long   st_uid;
5209 +       unsigned long   st_gid;
5211 +       unsigned long long st_rdev;
5213 +       long long       st_size;
5214 +       unsigned long   __pad1;
5215 +       unsigned long   st_blksize;
5217 +       unsigned long long st_blocks;
5219 +       unsigned long   st_atime;
5220 +       unsigned long   st_atime_nsec;
5222 +       unsigned long   st_mtime;
5223 +       unsigned long   st_mtime_nsec;
5225 +       unsigned long   st_ctime;
5226 +       unsigned long   st_ctime_nsec;
5228 +       unsigned long   __unused1;
5229 +       unsigned long   __unused2;
5232 +#endif /* _BITS_STAT_STRUCT_H */
5233 diff -Nrup a/libc/sysdeps/linux/avr32/bits/kernel_types.h b/libc/sysdeps/linux/avr32/bits/kernel_types.h
5234 --- a/libc/sysdeps/linux/avr32/bits/kernel_types.h      1969-12-31 19:00:00.000000000 -0500
5235 +++ b/libc/sysdeps/linux/avr32/bits/kernel_types.h      2008-02-28 19:02:10.000000000 -0500
5236 @@ -0,0 +1,56 @@
5237 +/* Note that we use the exact same include guard #define names
5238 + * as asm/posix_types.h.  This will avoid gratuitous conflicts
5239 + * with the posix_types.h kernel header, and will ensure that
5240 + * our private content, and not the kernel header, will win.
5241 + *  -Erik
5242 + */
5243 +#ifndef __ASM_AVR32_POSIX_TYPES_H
5244 +#define __ASM_AVR32_POSIX_TYPES_H
5247 + * This file is generally used by user-level software, so you need to
5248 + * be a little careful about namespace pollution etc.  Also, we cannot
5249 + * assume GCC is being used.
5250 + */
5252 +typedef unsigned long  __kernel_dev_t;
5253 +typedef unsigned long   __kernel_ino_t;
5254 +typedef unsigned short  __kernel_mode_t;
5255 +typedef unsigned short  __kernel_nlink_t;
5256 +typedef long            __kernel_off_t;
5257 +typedef int             __kernel_pid_t;
5258 +typedef unsigned short  __kernel_ipc_pid_t;
5259 +typedef unsigned int   __kernel_uid_t;
5260 +typedef unsigned int   __kernel_gid_t;
5261 +typedef unsigned long  __kernel_size_t;
5262 +typedef int             __kernel_ssize_t;
5263 +typedef int             __kernel_ptrdiff_t;
5264 +typedef long            __kernel_time_t;
5265 +typedef long            __kernel_suseconds_t;
5266 +typedef long            __kernel_clock_t;
5267 +typedef int             __kernel_timer_t;
5268 +typedef int             __kernel_clockid_t;
5269 +typedef int             __kernel_daddr_t;
5270 +typedef char *          __kernel_caddr_t;
5271 +typedef unsigned short  __kernel_uid16_t;
5272 +typedef unsigned short  __kernel_gid16_t;
5273 +typedef unsigned int    __kernel_uid32_t;
5274 +typedef unsigned int    __kernel_gid32_t;
5276 +typedef unsigned short  __kernel_old_uid_t;
5277 +typedef unsigned short  __kernel_old_gid_t;
5278 +typedef unsigned short  __kernel_old_dev_t;
5280 +#ifdef __GNUC__
5281 +typedef long long       __kernel_loff_t;
5282 +#endif
5284 +typedef struct {
5285 +#if defined(__USE_ALL)
5286 +    int     val[2];
5287 +#else
5288 +    int     __val[2];
5289 +#endif
5290 +} __kernel_fsid_t;
5292 +#endif /* __ASM_AVR32_POSIX_TYPES_H */
5293 diff -Nrup a/libc/sysdeps/linux/avr32/bits/machine-gmon.h b/libc/sysdeps/linux/avr32/bits/machine-gmon.h
5294 --- a/libc/sysdeps/linux/avr32/bits/machine-gmon.h      1969-12-31 19:00:00.000000000 -0500
5295 +++ b/libc/sysdeps/linux/avr32/bits/machine-gmon.h      2008-02-28 19:02:10.000000000 -0500
5296 @@ -0,0 +1,69 @@
5297 +/* Machine-dependent definitions for profiling support.  AVR32 version.
5298 +   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
5299 +   This file is part of the GNU C Library.
5301 +   The GNU C Library is free software; you can redistribute it and/or
5302 +   modify it under the terms of the GNU Lesser General Public
5303 +   License as published by the Free Software Foundation; either
5304 +   version 2.1 of the License, or (at your option) any later version.
5306 +   The GNU C Library is distributed in the hope that it will be useful,
5307 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
5308 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5309 +   Lesser General Public License for more details.
5311 +   You should have received a copy of the GNU Lesser General Public
5312 +   License along with the GNU C Library; if not, write to the Free
5313 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5314 +   02111-1307 USA.  */
5316 +#define mcount_internal __mcount_internal
5318 +#define _MCOUNT_DECL(frompc, selfpc) \
5319 +static void __attribute((used)) mcount_internal(unsigned long frompc, unsigned long selfpc)
5322 + * This mcount implementation expects to get called after the prologue
5323 + * has been run. It also expects that r7 contains a valid frame
5324 + * pointer.
5325 + *
5326 + * When profiling, the compiler should generate something like this at
5327 + * each function entry:
5328 + *
5329 + *     pushm   r0-r7,lr        // lr mandatory, others optional
5330 + *     mov     r7, sp
5331 + *     // rest of prologue goes here
5332 + *     mcall   pc[.LC1 - .]
5333 + *      // rest of function goes here
5334 + * .LC1:
5335 + *     .long   mcount
5336 + *
5337 + * or for PIC:
5338 + *
5339 + *     pushm   r0-r7,lr
5340 + *     mov     r7, sp
5341 + *     // rest of prologue goes here
5342 + *     lddpc   r0, .LC1
5343 + * .L1: rsub   r0, pc
5344 + *     mcall   r0[mcount@GOT]
5345 + *     // rest of function goes here
5346 + * .LC1:
5347 + *     .long   .L1 - _GLOBAL_OFFSET_TABLE_
5348 + *
5349 + * This way, when mcount() is called, r7 points to the calling
5350 + * function's return address. It is guaranteed that calling mcount
5351 + * will clobber no registers except LR, which is unavoidable.
5352 + */
5353 +#define MCOUNT asm(                            \
5354 +       "       .align  4\n"                    \
5355 +       "       .global _mcount\n"              \
5356 +       "       .type   _mcount,@function\n"    \
5357 +       "_mcount:\n"                            \
5358 +       "       pushm   r8-r12,lr\n"            \
5359 +       "       mov     r11, lr\n"              \
5360 +       "       ld.w    r12, r7[0]\n"           \
5361 +       "       rcall   __mcount_internal\n"    \
5362 +       "       popm    r8-r12,pc\n"            \
5363 +       "       .size   _mcount, . - _mcount\n" \
5364 +       "       .weak   mcount\n"               \
5365 +       "       mcount = _mcount");
5366 diff -Nrup a/libc/sysdeps/linux/avr32/bits/mman.h b/libc/sysdeps/linux/avr32/bits/mman.h
5367 --- a/libc/sysdeps/linux/avr32/bits/mman.h      1969-12-31 19:00:00.000000000 -0500
5368 +++ b/libc/sysdeps/linux/avr32/bits/mman.h      2008-02-28 19:02:10.000000000 -0500
5369 @@ -0,0 +1,95 @@
5370 +/* Definitions for POSIX memory map interface.  Linux/AVR32 version.
5371 +   Copyright (C) 1997, 2000 Free Software Foundation, Inc.
5372 +   This file is part of the GNU C Library.
5374 +   The GNU C Library is free software; you can redistribute it and/or
5375 +   modify it under the terms of the GNU Lesser General Public
5376 +   License as published by the Free Software Foundation; either
5377 +   version 2.1 of the License, or (at your option) any later version.
5379 +   The GNU C Library is distributed in the hope that it will be useful,
5380 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
5381 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5382 +   Lesser General Public License for more details.
5384 +   You should have received a copy of the GNU Lesser General Public
5385 +   License along with the GNU C Library; if not, write to the Free
5386 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5387 +   02111-1307 USA.  */
5389 +#ifndef _SYS_MMAN_H
5390 +# error "Never include this file directly.  Use <sys/mman.h> instead"
5391 +#endif
5393 +/* The following definitions basically come from the kernel headers.
5394 +   But the kernel header is not namespace clean.  */
5397 +/* Protections are chosen from these bits, OR'd together.  The
5398 +   implementation does not necessarily support PROT_EXEC or PROT_WRITE
5399 +   without PROT_READ.  The only guarantees are that no writing will be
5400 +   allowed without PROT_WRITE and no access will be allowed for PROT_NONE. */
5402 +#define PROT_READ      0x1             /* Page can be read.  */
5403 +#define PROT_WRITE     0x2             /* Page can be written.  */
5404 +#define PROT_EXEC      0x4             /* Page can be executed.  */
5405 +#define PROT_NONE      0x0             /* Page can not be accessed.  */
5407 +/* Sharing types (must choose one and only one of these).  */
5408 +#define MAP_SHARED     0x01            /* Share changes.  */
5409 +#define MAP_PRIVATE    0x02            /* Changes are private.  */
5410 +#ifdef __USE_MISC
5411 +# define MAP_TYPE      0x0f            /* Mask for type of mapping.  */
5412 +#endif
5414 +/* Other flags.  */
5415 +#define MAP_FIXED      0x10            /* Interpret addr exactly.  */
5416 +#ifdef __USE_MISC
5417 +# define MAP_FILE      0
5418 +# define MAP_ANONYMOUS 0x20            /* Don't use a file.  */
5419 +# define MAP_ANON      MAP_ANONYMOUS
5420 +#endif
5422 +/* These are Linux-specific.  */
5423 +#ifdef __USE_MISC
5424 +# define MAP_GROWSDOWN 0x0100          /* Stack-like segment.  */
5425 +# define MAP_DENYWRITE 0x0800          /* ETXTBSY */
5426 +# define MAP_EXECUTABLE        0x1000          /* Mark it as an executable.  */
5427 +# define MAP_LOCKED    0x2000          /* Lock the mapping.  */
5428 +# define MAP_NORESERVE 0x4000          /* Don't check for reservations.  */
5429 +# define MAP_POPULATE  0x8000          /* populate (prefault) pagetables */
5430 +# define MAP_NONBLOCK  0x10000         /* do not block on IO */
5431 +#endif
5433 +/* Flags to `msync'.  */
5434 +#define MS_ASYNC       1               /* Sync memory asynchronously.  */
5435 +#define MS_SYNC                4               /* Synchronous memory sync.  */
5436 +#define MS_INVALIDATE  2               /* Invalidate the caches.  */
5438 +/* Flags for `mlockall'.  */
5439 +#define MCL_CURRENT    1               /* Lock all currently mapped pages.  */
5440 +#define MCL_FUTURE     2               /* Lock all additions to address
5441 +                                          space.  */
5443 +/* Flags for `mremap'.  */
5444 +#ifdef __USE_GNU
5445 +# define MREMAP_MAYMOVE        1
5446 +#endif
5448 +/* Advise to `madvise'.  */
5449 +#ifdef __USE_BSD
5450 +# define MADV_NORMAL    0      /* No further special treatment.  */
5451 +# define MADV_RANDOM    1      /* Expect random page references.  */
5452 +# define MADV_SEQUENTIAL 2     /* Expect sequential page references.  */
5453 +# define MADV_WILLNEED  3      /* Will need these pages.  */
5454 +# define MADV_DONTNEED  4      /* Don't need these pages.  */
5455 +#endif
5457 +/* The POSIX people had to invent similar names for the same things.  */
5458 +#ifdef __USE_XOPEN2K
5459 +# define POSIX_MADV_NORMAL     0 /* No further special treatment.  */
5460 +# define POSIX_MADV_RANDOM     1 /* Expect random page references.  */
5461 +# define POSIX_MADV_SEQUENTIAL 2 /* Expect sequential page references.  */
5462 +# define POSIX_MADV_WILLNEED   3 /* Will need these pages.  */
5463 +# define POSIX_MADV_DONTNEED   4 /* Don't need these pages.  */
5464 +#endif
5465 diff -Nrup a/libc/sysdeps/linux/avr32/bits/profil-counter.h b/libc/sysdeps/linux/avr32/bits/profil-counter.h
5466 --- a/libc/sysdeps/linux/avr32/bits/profil-counter.h    1969-12-31 19:00:00.000000000 -0500
5467 +++ b/libc/sysdeps/linux/avr32/bits/profil-counter.h    2008-02-28 19:02:10.000000000 -0500
5468 @@ -0,0 +1,26 @@
5469 +/* Low-level statistical profiling support function.  Linux/AVR32 version.
5470 +   Copyright (C) 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
5471 +   This file is part of the GNU C Library.
5473 +   The GNU C Library is free software; you can redistribute it and/or
5474 +   modify it under the terms of the GNU Lesser General Public
5475 +   License as published by the Free Software Foundation; either
5476 +   version 2.1 of the License, or (at your option) any later version.
5478 +   The GNU C Library is distributed in the hope that it will be useful,
5479 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
5480 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5481 +   Lesser General Public License for more details.
5483 +   You should have received a copy of the GNU Lesser General Public
5484 +   License along with the GNU C Library; if not, write to the Free
5485 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
5486 +   02111-1307 USA.  */
5488 +#include <signal.h>
5490 +void
5491 +profil_counter(int signo, siginfo_t *si, struct sigcontext *sc)
5493 +       profil_count((void *)sc->pc);
5495 diff -Nrup a/libc/sysdeps/linux/avr32/bits/setjmp.h b/libc/sysdeps/linux/avr32/bits/setjmp.h
5496 --- a/libc/sysdeps/linux/avr32/bits/setjmp.h    1969-12-31 19:00:00.000000000 -0500
5497 +++ b/libc/sysdeps/linux/avr32/bits/setjmp.h    2008-02-28 19:02:10.000000000 -0500
5498 @@ -0,0 +1,21 @@
5500 + * Copyright (C) 2004-2005 Atmel Norway
5501 + */
5502 +#ifndef _SETJMP_H
5503 +# error "Never include <bits/setjmp.h> directly; use <setjmp.h> instead."
5504 +#endif
5506 +#ifndef _ASM
5508 + * The jump buffer contains r0-r7, sr, sp and lr. Other registers are
5509 + * not saved.
5510 + */
5511 +typedef int __jmp_buf[11];
5512 +#endif
5514 +#define __JMP_BUF_SP   4
5516 +/* Test if longjmp to JMPBUF would unwind the frame containing a local
5517 +   variable at ADDRESS.  */
5518 +#define _JMPBUF_UNWINDS(jmpbuf, address) \
5519 +  ((void *)(address) < (void *)(jmpbuf[__JMP_BUF_SP]))
5520 diff -Nrup a/libc/sysdeps/linux/avr32/bits/syscalls.h b/libc/sysdeps/linux/avr32/bits/syscalls.h
5521 --- a/libc/sysdeps/linux/avr32/bits/syscalls.h  1969-12-31 19:00:00.000000000 -0500
5522 +++ b/libc/sysdeps/linux/avr32/bits/syscalls.h  2008-02-28 19:02:10.000000000 -0500
5523 @@ -0,0 +1,143 @@
5524 +#ifndef _SYSCALL_H
5525 +# error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
5526 +#endif
5529 + * This includes the `__NR_<name>' syscall numbers taken from the
5530 + * Linux kernel header files. It also defines the traditional
5531 + * `SYS_<name>' macros for older programs.
5532 + */
5533 +#include <bits/sysnum.h>
5535 +#ifndef __set_errno
5536 +# define __set_errno(val) (*__errno_location()) = (val)
5537 +#endif
5538 +#ifndef SYS_ify
5539 +# define SYS_ify(syscall_name) (__NR_##syscall_name)
5540 +#endif
5542 +#ifndef __ASSEMBLER__
5544 +#undef _syscall0
5545 +#define _syscall0(type,name)                           \
5546 +       type name(void)                                 \
5547 +       {                                               \
5548 +               return (type)(INLINE_SYSCALL(name, 0)); \
5549 +       }
5551 +#undef _syscall1
5552 +#define _syscall1(type,name,type1,arg1)                                \
5553 +       type name(type1 arg1)                                   \
5554 +       {                                                       \
5555 +               return (type)(INLINE_SYSCALL(name, 1, arg1));   \
5556 +       }
5558 +#undef _syscall2
5559 +#define _syscall2(type,name,type1,arg1,type2,arg2)                     \
5560 +       type name(type1 arg1, type2 arg2)                               \
5561 +       {                                                               \
5562 +               return (type)(INLINE_SYSCALL(name, 2, arg1, arg2));     \
5563 +       }
5565 +#undef _syscall3
5566 +#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3)          \
5567 +       type name(type1 arg1, type2 arg2, type3 arg3)                   \
5568 +       {                                                               \
5569 +               return (type)(INLINE_SYSCALL(name, 3, arg1,             \
5570 +                                            arg2, arg3));              \
5571 +       }
5573 +#undef _syscall4
5574 +#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,          \
5575 +                 type4,arg4)                                           \
5576 +       type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4)       \
5577 +       {                                                               \
5578 +               return (type)(INLINE_SYSCALL(name, 4, arg1, arg2,       \
5579 +                                            arg3, arg4));              \
5580 +       }
5582 +#undef _syscall5
5583 +#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,          \
5584 +                 type4,arg4,type5,arg5)                                \
5585 +       type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,       \
5586 +                 type5 arg5)                                           \
5587 +       {                                                               \
5588 +               return (type)(INLINE_SYSCALL(name, 5, arg1, arg2,       \
5589 +                                            arg3, arg4, arg5));        \
5590 +       }
5592 +#undef _syscall6
5593 +#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,          \
5594 +                 type4,arg4,type5,arg5,type6,arg6)                     \
5595 +       type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4,       \
5596 +                 type5 arg5, type6 arg6)                               \
5597 +       {                                                               \
5598 +               return (type)(INLINE_SYSCALL(name, 6, arg1, arg2, arg3, \
5599 +                                            arg4, arg5, arg6));        \
5600 +       }
5602 +#undef unlikely
5603 +#define unlikely(x) __builtin_expect((x), 0)
5605 +#undef INLINE_SYSCALL
5606 +#define INLINE_SYSCALL(name, nr, args...)                              \
5607 +       ({                                                              \
5608 +               unsigned _sys_result = INTERNAL_SYSCALL(name, , nr, args); \
5609 +               if (unlikely(INTERNAL_SYSCALL_ERROR_P(_sys_result, ))) { \
5610 +                       __set_errno(INTERNAL_SYSCALL_ERRNO(_sys_result, )); \
5611 +                       _sys_result = (unsigned int) -1;                \
5612 +               }                                                       \
5613 +               (int) _sys_result;                                      \
5614 +       })
5616 +#undef INTERNAL_SYSCALL_DECL
5617 +#define INTERNAL_SYSCALL_DECL(err) do { } while(0)
5619 +#undef INTERNAL_SYSCALL
5620 +#define INTERNAL_SYSCALL(name, err, nr, args...)                       \
5621 +       ({                                                              \
5622 +               register int _a1 asm ("r12");                           \
5623 +               register int _scno asm("r8") = SYS_ify(name);           \
5624 +               LOAD_ARGS_##nr (args);                                  \
5625 +               asm volatile ("scall    /* syscall " #name " */"        \
5626 +                             : "=r" (_a1)                              \
5627 +                             : "r"(_scno) ASM_ARGS_##nr                \
5628 +                             : "lr", "cc", "memory");                  \
5629 +               _a1;                                                    \
5630 +       })
5632 +#undef INTERNAL_SYSCALL_ERROR_P
5633 +#define INTERNAL_SYSCALL_ERROR_P(val, err)             \
5634 +       ((unsigned int)(val) >= 0xfffff001U)
5636 +#undef INTERNAL_SYSCALL_ERRNO
5637 +#define INTERNAL_SYSCALL_ERRNO(val, errr) (-(val))
5639 +#define LOAD_ARGS_0() do { } while(0)
5640 +#define ASM_ARGS_0
5641 +#define LOAD_ARGS_1(a1)                                        \
5642 +       _a1 = (int) (a1);                               \
5643 +       LOAD_ARGS_0()
5644 +#define ASM_ARGS_1     ASM_ARGS_0, "r"(_a1)
5645 +#define LOAD_ARGS_2(a1, a2)                            \
5646 +       register int _a2 asm("r11") = (int)(a2);        \
5647 +       LOAD_ARGS_1(a1)
5648 +#define ASM_ARGS_2     ASM_ARGS_1, "r"(_a2)
5649 +#define LOAD_ARGS_3(a1, a2, a3)                                \
5650 +       register int _a3 asm("r10") = (int)(a3);        \
5651 +       LOAD_ARGS_2(a1, a2)
5652 +#define ASM_ARGS_3     ASM_ARGS_2, "r"(_a3)
5653 +#define LOAD_ARGS_4(a1, a2, a3, a4)                    \
5654 +       register int _a4 asm("r9") = (int)(a4);         \
5655 +       LOAD_ARGS_3(a1, a2, a3)
5656 +#define ASM_ARGS_4     ASM_ARGS_3, "r"(_a4)
5657 +#define LOAD_ARGS_5(a1, a2, a3, a4, a5)                        \
5658 +       register int _a5 asm("r5") = (int)(a5);         \
5659 +       LOAD_ARGS_4(a1, a2, a3, a4)
5660 +#define ASM_ARGS_5     ASM_ARGS_4, "r"(_a5)
5661 +#define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6)            \
5662 +       register int _a6 asm("r3") = (int)(a6);         \
5663 +       LOAD_ARGS_5(a1, a2, a3, a4, a5)
5664 +#define ASM_ARGS_6     ASM_ARGS_5, "r"(_a6)
5666 +#endif /* __ASSEMBLER__ */
5667 diff -Nrup a/libc/sysdeps/linux/avr32/bits/wordsize.h b/libc/sysdeps/linux/avr32/bits/wordsize.h
5668 --- a/libc/sysdeps/linux/avr32/bits/wordsize.h  1969-12-31 19:00:00.000000000 -0500
5669 +++ b/libc/sysdeps/linux/avr32/bits/wordsize.h  2008-02-28 19:02:10.000000000 -0500
5670 @@ -0,0 +1 @@
5671 +#define __WORDSIZE     32
5672 diff -Nrup a/libc/sysdeps/linux/avr32/brk.c b/libc/sysdeps/linux/avr32/brk.c
5673 --- a/libc/sysdeps/linux/avr32/brk.c    1969-12-31 19:00:00.000000000 -0500
5674 +++ b/libc/sysdeps/linux/avr32/brk.c    2008-02-28 19:02:10.000000000 -0500
5675 @@ -0,0 +1,23 @@
5677 + * Copyright (C) 2004 Atmel Norway AS
5678 + */
5679 +#include <errno.h>
5680 +#include <sys/syscall.h>
5682 +void *__curbrk = 0;
5684 +int brk (void *addr)
5686 +       void *newbrk;
5688 +       newbrk = INLINE_SYSCALL(brk, 1, addr);
5690 +       __curbrk = newbrk;
5692 +       if (newbrk < addr) {
5693 +               __set_errno (ENOMEM);
5694 +               return -1;
5695 +       }
5697 +       return 0;
5699 diff -Nrup a/libc/sysdeps/linux/avr32/bsd-_setjmp.S b/libc/sysdeps/linux/avr32/bsd-_setjmp.S
5700 --- a/libc/sysdeps/linux/avr32/bsd-_setjmp.S    1969-12-31 19:00:00.000000000 -0500
5701 +++ b/libc/sysdeps/linux/avr32/bsd-_setjmp.S    2008-02-28 19:02:10.000000000 -0500
5702 @@ -0,0 +1,12 @@
5704 + * Copyright (C) 2004 Atmel Norway AS
5705 + */
5707 +       /* This just does a tail-call to __sigsetjmp(env, 0) */
5708 +       .global _setjmp
5709 +       .type   _setjmp,"function"
5710 +       .align  1
5711 +_setjmp:
5712 +       mov     r11, 0
5713 +       bral    __sigsetjmp_internal
5714 +       .size   _setjmp, . - _setjmp
5715 diff -Nrup a/libc/sysdeps/linux/avr32/bsd-setjmp.S b/libc/sysdeps/linux/avr32/bsd-setjmp.S
5716 --- a/libc/sysdeps/linux/avr32/bsd-setjmp.S     1969-12-31 19:00:00.000000000 -0500
5717 +++ b/libc/sysdeps/linux/avr32/bsd-setjmp.S     2008-02-28 19:02:10.000000000 -0500
5718 @@ -0,0 +1,12 @@
5720 + * Copyright (C) 2004 Atmel Norway AS
5721 + */
5723 +       /* This just does a tail-call to __sigsetjmp(env, 1) */
5724 +       .global setjmp
5725 +       .type   setjmp,"function"
5726 +       .align  1
5727 +setjmp:
5728 +       mov     r11, 1
5729 +       bral    __sigsetjmp_internal
5730 +       .size   setjmp, . - setjmp
5731 diff -Nrup a/libc/sysdeps/linux/avr32/clone.c b/libc/sysdeps/linux/avr32/clone.c
5732 --- a/libc/sysdeps/linux/avr32/clone.c  1969-12-31 19:00:00.000000000 -0500
5733 +++ b/libc/sysdeps/linux/avr32/clone.c  2008-02-28 19:02:10.000000000 -0500
5734 @@ -0,0 +1,37 @@
5736 + * Copyright (C) 2004 Atmel Norway AS
5737 + */
5738 +#include <errno.h>
5739 +#include <sys/syscall.h>
5740 +#include <unistd.h>
5743 + * I don't know if we can be absolutely certain that the fn and arg
5744 + * parameters are preserved when returning as the child. If the
5745 + * compiler stores them in registers (r0-r7), they should be.
5746 + */
5747 +int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg)
5749 +       register int (*_fn)(void *arg) = fn;
5750 +       register void *_arg = arg;
5751 +       int err;
5753 +       /* Sanity check the arguments */
5754 +       err = -EINVAL;
5755 +       if (!fn)
5756 +               goto syscall_error;
5757 +       if (!child_stack)
5758 +               goto syscall_error;
5760 +       err = INLINE_SYSCALL(clone, 2, flags, child_stack);
5761 +       if (err < 0)
5762 +               goto syscall_error;
5763 +       else if (err != 0)
5764 +               return err;
5766 +       _exit(_fn(_arg));
5768 +syscall_error:
5769 +       __set_errno (-err);
5770 +       return -1;
5772 diff -Nrup a/libc/sysdeps/linux/avr32/crt1.S b/libc/sysdeps/linux/avr32/crt1.S
5773 --- a/libc/sysdeps/linux/avr32/crt1.S   1969-12-31 19:00:00.000000000 -0500
5774 +++ b/libc/sysdeps/linux/avr32/crt1.S   2008-02-28 19:02:10.000000000 -0500
5775 @@ -0,0 +1,93 @@
5777 + * Copyright (C) 2004 Atmel Norway AS
5778 + *
5779 + * When we enter _start, the stack looks like this:
5780 + *     argc            argument counter
5781 + *     argv[0]         pointer to program name
5782 + *     argv[1..argc-1] pointers to program args
5783 + *     NULL
5784 + *     env[0..N]       pointers to environment variables
5785 + *     NULL
5786 + *
5787 + * r12 contains a function pointer to be registered with `atexit'.
5788 + * This is how the dynamic linker arranges to have DT_FINI functions
5789 + * called for shared libraries that have been loaded before this
5790 + * code runs.
5791 + *
5792 + * We're going to call the following function:
5793 + * __uClibc_main(int (*main)(int, char **, char **), int argc,
5794 + *              char **argv, void (*app_init)(void), void (*app_fini)(void),
5795 + *              void (*rtld_fini)(void), void *stack_end)
5796 + *
5797 + * So we need to set up things as follows:
5798 + *     r12 = address of main
5799 + *     r11 = argc
5800 + *     r10 = &argv[0]
5801 + *     r9  = address of _init
5802 + *     r8  = address of _fini
5803 + *     sp[0] = whatever we got passed in r12
5804 + */
5806 +#include <features.h>
5808 +       .text
5809 +       .global _start
5810 +       .type   _start, @function
5811 +_start:
5812 +       /* Clear the frame pointer and link register since this is the outermost frame.  */
5813 +       mov     r7, 0
5814 +       mov     lr, 0
5816 +       ld.w    r11, sp++               /* argc         */
5817 +       mov     r10, sp                 /* &argv[0]     */
5819 +       st.w    --sp, r10               /* stack_end */
5820 +       st.w    --sp, r12               /* rtld_fini */
5822 +#ifdef __PIC__
5823 +       lddpc   r6, .L_GOT
5824 +.L_RGOT:
5825 +       rsub    r6, pc
5826 +       lda.w   r9, _init
5827 +       lda.w   r8, _fini
5828 +       lda.w   r12, main
5830 +       /* Ok, now run uClibc's main() -- should not return */
5831 +       call    __uClibc_main
5833 +       .align  2
5834 +.L_GOT:
5835 +       .long   .L_RGOT - _GLOBAL_OFFSET_TABLE_
5836 +#else
5837 +       lddpc   r9, __init_addr         /* app_init */
5838 +       lddpc   r8, __fini_addr         /* app_fini */
5839 +       lddpc   r12, __main_addr        /* main */
5841 +       /* Ok, now run uClibc's main() -- should not return */
5842 +       lddpc   pc, ___uClibc_main_addr
5844 +       .align  2
5845 +__init_addr:
5846 +       .long   _init
5847 +__fini_addr:
5848 +       .long   _fini
5849 +__main_addr:
5850 +       .long   main
5851 +___uClibc_main_addr:
5852 +       .long   __uClibc_main
5853 +#endif
5854 +       .size   _start, . - _start
5856 +       /*
5857 +        * The LSB says we need this.
5858 +        */
5859 +       .section ".note.ABI-tag", "a"
5860 +       .align  4
5861 +       .long   2f - 1f         /* namesz */
5862 +       .long   4f - 3f         /* descsz */
5863 +       .long   1               /* type   */
5864 +1:     .asciz  "GNU"           /* name */
5865 +2:     .align  4
5866 +3:     .long   0               /* Linux executable */
5867 +       .long   2,6,0           /* Earliest compatible kernel */
5868 +4:     .align  4
5869 diff -Nrup a/libc/sysdeps/linux/avr32/crti.S b/libc/sysdeps/linux/avr32/crti.S
5870 --- a/libc/sysdeps/linux/avr32/crti.S   1969-12-31 19:00:00.000000000 -0500
5871 +++ b/libc/sysdeps/linux/avr32/crti.S   2008-02-28 19:02:10.000000000 -0500
5872 @@ -0,0 +1,17 @@
5874 +       .section .init
5875 +       .align  2
5876 +       .global _init
5877 +       .type   _init, @function
5878 +_init:
5879 +       /* Use a four-byte instruction to avoid NOPs */
5880 +       stm     --sp, r0-r7,lr
5881 +       .align  2
5883 +       .section .fini
5884 +       .align  2
5885 +       .global _fini
5886 +       .type   _fini, @function
5887 +_fini:
5888 +       stm     --sp, r0-r7,lr
5889 +       .align  2
5890 diff -Nrup a/libc/sysdeps/linux/avr32/crtn.S b/libc/sysdeps/linux/avr32/crtn.S
5891 --- a/libc/sysdeps/linux/avr32/crtn.S   1969-12-31 19:00:00.000000000 -0500
5892 +++ b/libc/sysdeps/linux/avr32/crtn.S   2008-02-28 19:02:10.000000000 -0500
5893 @@ -0,0 +1,14 @@
5895 +       .section .init
5896 +       .align  2
5897 +       .global _init
5898 +       .type   _init, @function
5899 +       ldm     sp++, r0-r7,pc
5900 +       .size   _init, . - _init
5902 +       .section .fini
5903 +       .align  2
5904 +       .global _fini
5905 +       .type   _fini, @function
5906 +       ldm     sp++, r0-r7,pc
5907 +       .size   _fini, . - _fini
5908 diff -Nrup a/libc/sysdeps/linux/avr32/__longjmp.S b/libc/sysdeps/linux/avr32/__longjmp.S
5909 --- a/libc/sysdeps/linux/avr32/__longjmp.S      1969-12-31 19:00:00.000000000 -0500
5910 +++ b/libc/sysdeps/linux/avr32/__longjmp.S      2008-02-28 19:02:10.000000000 -0500
5911 @@ -0,0 +1,17 @@
5912 +/* longjmp for AVR32
5913 + *
5914 + * Copyright (C) 2004 Atmel Norway AS
5915 + */
5917 +       .global __longjmp
5918 +       .type   __longjmp,"function"
5919 +       .align  1
5920 +__longjmp:
5921 +       ldm     r12++, r0,r1,r2,r3,r4,r5,r6,r7,r8,sp,lr
5922 +       mov     r12, r11        /* get the return value right */
5923 +       mustr   r8              /* restore status register (lower half) */
5924 +       cp      r12, 0          /* can't return zero */
5925 +       frs
5926 +       moveq   r12, 1
5927 +       mov     pc,lr
5928 +       .size   __longjmp, . - __longjmp
5929 diff -Nrup a/libc/sysdeps/linux/avr32/Makefile b/libc/sysdeps/linux/avr32/Makefile
5930 --- a/libc/sysdeps/linux/avr32/Makefile 1969-12-31 19:00:00.000000000 -0500
5931 +++ b/libc/sysdeps/linux/avr32/Makefile 2008-02-28 19:02:10.000000000 -0500
5932 @@ -0,0 +1,93 @@
5933 +# Makefile for uClibc
5935 +# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
5937 +# This program is free software; you can redistribute it and/or modify it under
5938 +# the terms of the GNU Library General Public License as published by the Free
5939 +# Software Foundation; either version 2 of the License, or (at your option) any
5940 +# later version.
5942 +# This program is distributed in the hope that it will be useful, but WITHOUT
5943 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
5944 +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
5945 +# details.
5947 +# You should have received a copy of the GNU Library General Public License
5948 +# along with this program; if not, write to the Free Software Foundation, Inc.,
5949 +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5951 +TOPDIR=../../../../
5952 +include $(TOPDIR)Rules.mak
5953 +ASFLAGS=$(CFLAGS)
5955 +CRT_SRC        = crt1.S
5956 +CRT_OBJ = crt1.o
5957 +SCRT_OBJ = $(patsubst %,S%, $(CRT_OBJ))
5958 +CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
5960 +SSRC=__longjmp.S setjmp.S bsd-setjmp.S vfork.S \
5961 +       bsd-_setjmp.S sigrestorer.S syscall.S
5962 +SOBJS=$(patsubst %.S,%.o, $(SSRC))
5964 +CSRC=clone.c brk.c sigaction.c mmap.c
5965 +COBJS=$(patsubst %.c,%.o, $(CSRC))
5967 +OBJS=$(SOBJS) $(COBJS)
5969 +OBJ_LIST=../../../obj.sysdeps.$(TARGET_ARCH)
5971 +all: $(OBJ_LIST)
5973 +$(OBJ_LIST): $(OBJS) $(CRT_OBJ) $(SCRT_OBJ) $(CTOR_TARGETS)
5974 +       echo $(patsubst %, sysdeps/linux/$(TARGET_ARCH)/%, $(OBJS)) > $(OBJ_LIST)
5975 +       $(INSTALL) -d $(TOPDIR)lib/
5976 +       cp $(CRT_OBJ) $(SCRT_OBJ) $(TOPDIR)lib/
5978 +$(CRT_OBJ): $(CRT_SRC)
5979 +       $(CC) $(ASFLAGS) -DL_$* $< -c -o $*.o
5980 +       $(STRIPTOOL) -x -R .note -R .comment $*.o
5982 +$(SCRT_OBJ): $(CRT_SRC)
5983 +       $(CC) $(ASFLAGS) $(PIEFLAG) -DL_$* $< -c -o $*.o
5984 +       $(STRIPTOOL) -x -R .note -R .comment $*.o
5986 +$(SOBJS): %.o : %.S
5987 +       $(CC) $(ASFLAGS) -c $< -o $@
5988 +       $(STRIPTOOL) -x -R .note -R .comment $*.o
5990 +$(COBJS): %.o : %.c
5991 +       $(CC) $(CFLAGS) -c $< -o $@
5992 +       $(STRIPTOOL) -x -R .note -R .comment $*.o
5994 +ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
5995 +crti.o: crti.S
5996 +       $(CC) $(ASFLAGS) -c crti.S -o crti.o
5998 +$(TOPDIR)lib/crti.o: crti.o
5999 +       $(INSTALL) -d $(TOPDIR)lib/
6000 +       cp crti.o $(TOPDIR)lib/
6002 +crtn.o: crtn.S
6003 +       $(CC) $(ASFLAGS) -c crtn.S -o crtn.o
6005 +$(TOPDIR)lib/crtn.o: crtn.o
6006 +       $(INSTALL) -d $(TOPDIR)lib/
6007 +       cp crtn.o $(TOPDIR)lib/
6008 +else
6009 +$(TOPDIR)lib/crti.o:
6010 +       $(INSTALL) -d $(TOPDIR)lib/
6011 +       $(AR) $(ARFLAGS) $(TOPDIR)lib/crti.o
6012 +$(TOPDIR)lib/crtn.o:
6013 +       $(INSTALL) -d $(TOPDIR)lib/
6014 +       $(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o
6015 +endif
6018 +headers:
6019 +#      $(LN) -fs ../libc/sysdeps/linux/avr32/fpu_control.h $(TOPDIR)/include/
6021 +clean:
6022 +       $(RM) *.[oa] *~ core
6023 +       $(RM) bits/sysnum.h
6024 +       $(RM) gmon-start.S
6026 diff -Nrup a/libc/sysdeps/linux/avr32/_mmap.c b/libc/sysdeps/linux/avr32/_mmap.c
6027 --- a/libc/sysdeps/linux/avr32/_mmap.c  1969-12-31 19:00:00.000000000 -0500
6028 +++ b/libc/sysdeps/linux/avr32/_mmap.c  2008-02-28 19:02:10.000000000 -0500
6029 @@ -0,0 +1,33 @@
6030 +/* Copyright (C) 2005 Atmel Norway
6032 +   This program is free software; you can redistribute it and/or modify it under
6033 +   the terms of the GNU Library General Public License as published by the Free
6034 +   Software Foundation; either version 2 of the License, or (at your option) any
6035 +   later version.
6037 +   This program is distributed in the hope that it will be useful, but WITHOUT
6038 +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
6039 +   FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
6040 +   details.
6042 +   You should have received a copy of the GNU Library General Public License
6043 +   along with this program; if not, write to the Free Software Foundation, Inc.,
6044 +   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6046 +   Derived in part from the Linux-8086 C library, the GNU C Library, and several
6047 +   other sundry sources.  Files within this library are copyright by their
6048 +   respective copyright holders.
6049 + */
6051 +#include <errno.h>
6052 +#include <sys/mman.h>
6053 +#include <sys/syscall.h>
6055 +#define __NR_mmap2 __NR_mmap
6057 +static _syscall6(__ptr_t, mmap2, __ptr_t, addr, size_t, len, int, prot, int, flags, int, fd, __off_t, pgoff);
6059 +__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
6061 +       return mmap2(addr, len, prot, flags, fd, offset >> 12);
6063 diff -Nrup a/libc/sysdeps/linux/avr32/mmap.c b/libc/sysdeps/linux/avr32/mmap.c
6064 --- a/libc/sysdeps/linux/avr32/mmap.c   1969-12-31 19:00:00.000000000 -0500
6065 +++ b/libc/sysdeps/linux/avr32/mmap.c   2008-02-28 19:02:10.000000000 -0500
6066 @@ -0,0 +1,31 @@
6067 +/* Copyright (C) 2005 Atmel Norway
6069 +   This program is free software; you can redistribute it and/or modify it under
6070 +   the terms of the GNU Library General Public License as published by the Free
6071 +   Software Foundation; either version 2 of the License, or (at your option) any
6072 +   later version.
6074 +   This program is distributed in the hope that it will be useful, but WITHOUT
6075 +   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
6076 +   FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
6077 +   details.
6079 +   You should have received a copy of the GNU Library General Public License
6080 +   along with this program; if not, write to the Free Software Foundation, Inc.,
6081 +   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6083 +   Derived in part from the Linux-8086 C library, the GNU C Library, and several
6084 +   other sundry sources.  Files within this library are copyright by their
6085 +   respective copyright holders.
6086 + */
6088 +#include <errno.h>
6089 +#include <sys/mman.h>
6090 +#include <sys/syscall.h>
6092 +static _syscall6(__ptr_t, mmap2, __ptr_t, addr, size_t, len, int, prot, int, flags, int, fd, __off_t, pgoff);
6094 +__ptr_t mmap(__ptr_t addr, size_t len, int prot, int flags, int fd, __off_t offset)
6096 +       return mmap2(addr, len, prot, flags, fd, offset >> 12);
6098 diff -Nrup a/libc/sysdeps/linux/avr32/setjmp.S b/libc/sysdeps/linux/avr32/setjmp.S
6099 --- a/libc/sysdeps/linux/avr32/setjmp.S 1969-12-31 19:00:00.000000000 -0500
6100 +++ b/libc/sysdeps/linux/avr32/setjmp.S 2008-02-28 19:02:10.000000000 -0500
6101 @@ -0,0 +1,43 @@
6103 + * Copyright (C) 2004 Atmel Norway AS
6104 + */
6105 +#define _SETJMP_H
6106 +#define _ASM
6107 +#include <bits/setjmp.h>
6109 +       .text
6111 +       .global __sigsetjmp
6112 +       .type   __sigsetjmp,"function"
6114 +       /* Create a global, hidden symbol for use by setjmp() and _setjmp().
6115 +          If it's not hidden, the linker will complain about a relative
6116 +          jump to a dynamic symbol when building a shared library.
6118 +          Also, if a user overrides the __sigsetjmp function, he might not
6119 +          expect the setjmp() and _setjmp() function to effectively be
6120 +          overridden as well.  */
6121 +       .global __sigsetjmp_internal
6122 +       .hidden __sigsetjmp_internal
6123 +       .type   __sigsetjmp_internal,"function"
6124 +       .align  1
6125 +__sigsetjmp:
6126 +__sigsetjmp_internal:
6127 +       mustr   r8
6128 +       stm     r12, r0,r1,r2,r3,r4,r5,r6,r7,r8,sp,lr
6130 +       /* Make a tail call to __sigjmp_save; it takes the same args.  */
6131 +#ifdef __PIC__
6132 +       mov     r9, r6
6133 +       lddpc   r6, .LG
6134 +.L1:   rsub    r6, pc
6135 +       ld.w    r8, r6[__sigjmp_save@got]
6136 +       mov     r6, r9
6137 +       mov     pc, r8
6139 +       .align  2
6140 +.LG:   .long   .L1 - _GLOBAL_OFFSET_TABLE_
6141 +#else
6142 +       rjmp    __sigjmp_save
6143 +#endif
6144 +       .size   __sigsetjmp, . - __sigsetjmp
6145 diff -Nrup a/libc/sysdeps/linux/avr32/sigaction.c b/libc/sysdeps/linux/avr32/sigaction.c
6146 --- a/libc/sysdeps/linux/avr32/sigaction.c      1969-12-31 19:00:00.000000000 -0500
6147 +++ b/libc/sysdeps/linux/avr32/sigaction.c      2008-02-28 19:02:10.000000000 -0500
6148 @@ -0,0 +1,49 @@
6150 + * Copyright (C) 2004 Atmel Norway AS
6151 + */
6152 +#include <errno.h>
6153 +#include <signal.h>
6154 +#include <string.h>
6155 +#include <sys/syscall.h>
6156 +#include <bits/kernel_sigaction.h>
6158 +#define SA_RESTORER    0x04000000
6159 +extern void __default_rt_sa_restorer(void);
6162 + * If act is not NULL, change the action for sig to *act.
6163 + * If oact is not NULL, put the old action for sig in *oact.
6164 + */
6165 +int __libc_sigaction(int signum, const struct sigaction *act,
6166 +                    struct sigaction *oldact)
6168 +       struct kernel_sigaction kact, koact;
6169 +       int result;
6171 +       if (act) {
6172 +               kact.k_sa_handler = act->sa_handler;
6173 +               memcpy(&kact.sa_mask, &act->sa_mask, sizeof (kact.sa_mask));
6174 +               kact.sa_flags = act->sa_flags;
6175 +               if (kact.sa_flags & (SA_RESTORER | SA_ONSTACK))
6176 +                       kact.sa_restorer = act->sa_restorer;
6177 +               else
6178 +                       kact.sa_restorer = __default_rt_sa_restorer;
6179 +               kact.sa_flags |= SA_RESTORER;
6180 +       }
6182 +       result = __syscall_rt_sigaction(signum, act ? __ptrvalue(&kact) : NULL,
6183 +                                       oldact ? __ptrvalue(&koact) : NULL,
6184 +                                       _NSIG / 8);
6186 +       if (oldact && result >= 0) {
6187 +               oldact->sa_handler = koact.k_sa_handler;
6188 +               memcpy(&oldact->sa_mask, &koact.sa_mask,
6189 +                      sizeof(oldact->sa_mask));
6190 +               oldact->sa_flags = koact.sa_flags;
6191 +               oldact->sa_restorer = koact.sa_restorer;
6192 +       }
6194 +       return result;
6197 +weak_alias(__libc_sigaction, sigaction)
6198 diff -Nrup a/libc/sysdeps/linux/avr32/sigrestorer.S b/libc/sysdeps/linux/avr32/sigrestorer.S
6199 --- a/libc/sysdeps/linux/avr32/sigrestorer.S    1969-12-31 19:00:00.000000000 -0500
6200 +++ b/libc/sysdeps/linux/avr32/sigrestorer.S    2008-02-28 19:02:10.000000000 -0500
6201 @@ -0,0 +1,11 @@
6203 + * Copyright (C) 2004 Atmel Norway AS
6204 + */
6205 +#include <sys/syscall.h>
6207 +       .global __default_rt_sa_restorer
6208 +       .type   __default_rt_sa_restorer,"function"
6209 +       .align  1
6210 +__default_rt_sa_restorer:
6211 +       mov     r8, __NR_rt_sigreturn
6212 +       scall
6213 diff -Nrup a/libc/sysdeps/linux/avr32/sys/elf.h b/libc/sysdeps/linux/avr32/sys/elf.h
6214 --- a/libc/sysdeps/linux/avr32/sys/elf.h        1969-12-31 19:00:00.000000000 -0500
6215 +++ b/libc/sysdeps/linux/avr32/sys/elf.h        2008-02-28 19:02:10.000000000 -0500
6216 @@ -0,0 +1,26 @@
6217 +/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
6218 +   This file is part of the GNU C Library.
6220 +   The GNU C Library is free software; you can redistribute it and/or
6221 +   modify it under the terms of the GNU Lesser General Public
6222 +   License as published by the Free Software Foundation; either
6223 +   version 2.1 of the License, or (at your option) any later version.
6225 +   The GNU C Library is distributed in the hope that it will be useful,
6226 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
6227 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6228 +   Lesser General Public License for more details.
6230 +   You should have received a copy of the GNU Lesser General Public
6231 +   License along with the GNU C Library; if not, write to the Free
6232 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
6233 +   02111-1307 USA.  */
6235 +#ifndef _SYS_ELF_H
6236 +#define _SYS_ELF_H     1
6238 +#warning "This header is obsolete; use <sys/procfs.h> instead."
6240 +#include <sys/procfs.h>
6242 +#endif /* sys/elf.h */
6243 diff -Nrup a/libc/sysdeps/linux/avr32/sys/io.h b/libc/sysdeps/linux/avr32/sys/io.h
6244 --- a/libc/sysdeps/linux/avr32/sys/io.h 1969-12-31 19:00:00.000000000 -0500
6245 +++ b/libc/sysdeps/linux/avr32/sys/io.h 2008-02-28 19:02:10.000000000 -0500
6246 @@ -0,0 +1,48 @@
6247 +/* Copyright (C) 1996, 1998, 1999 Free Software Foundation, Inc.
6248 +   This file is part of the GNU C Library.
6250 +   The GNU C Library is free software; you can redistribute it and/or
6251 +   modify it under the terms of the GNU Lesser General Public
6252 +   License as published by the Free Software Foundation; either
6253 +   version 2.1 of the License, or (at your option) any later version.
6255 +   The GNU C Library is distributed in the hope that it will be useful,
6256 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
6257 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6258 +   Lesser General Public License for more details.
6260 +   You should have received a copy of the GNU Lesser General Public
6261 +   License along with the GNU C Library; if not, write to the Free
6262 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
6263 +   02111-1307 USA.  */
6265 +#ifndef        _SYS_IO_H
6267 +#define        _SYS_IO_H       1
6268 +#include <features.h>
6270 +__BEGIN_DECLS
6272 +/* If TURN_ON is TRUE, request for permission to do direct i/o on the
6273 +   port numbers in the range [FROM,FROM+NUM-1].  Otherwise, turn I/O
6274 +   permission off for that range.  This call requires root privileges.  */
6275 +extern int ioperm (unsigned long int __from, unsigned long int __num,
6276 +                  int __turn_on) __THROW;
6278 +/* Set the I/O privilege level to LEVEL.  If LEVEL is nonzero,
6279 +   permission to access any I/O port is granted.  This call requires
6280 +   root privileges. */
6281 +extern int iopl (int __level) __THROW;
6283 +/* The functions that actually perform reads and writes.  */
6284 +extern unsigned char inb (unsigned long int port) __THROW;
6285 +extern unsigned short int inw (unsigned long int port) __THROW;
6286 +extern unsigned long int inl (unsigned long int port) __THROW;
6288 +extern void outb (unsigned char value, unsigned long int port) __THROW;
6289 +extern void outw (unsigned short value, unsigned long int port) __THROW;
6290 +extern void outl (unsigned long value, unsigned long int port) __THROW;
6292 +__END_DECLS
6294 +#endif /* _SYS_IO_H */
6295 diff -Nrup a/libc/sysdeps/linux/avr32/sys/procfs.h b/libc/sysdeps/linux/avr32/sys/procfs.h
6296 --- a/libc/sysdeps/linux/avr32/sys/procfs.h     1969-12-31 19:00:00.000000000 -0500
6297 +++ b/libc/sysdeps/linux/avr32/sys/procfs.h     2008-02-28 19:02:10.000000000 -0500
6298 @@ -0,0 +1,123 @@
6299 +/* Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
6300 +   This file is part of the GNU C Library.
6302 +   The GNU C Library is free software; you can redistribute it and/or
6303 +   modify it under the terms of the GNU Lesser General Public
6304 +   License as published by the Free Software Foundation; either
6305 +   version 2.1 of the License, or (at your option) any later version.
6307 +   The GNU C Library is distributed in the hope that it will be useful,
6308 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
6309 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6310 +   Lesser General Public License for more details.
6312 +   You should have received a copy of the GNU Lesser General Public
6313 +   License along with the GNU C Library; if not, write to the Free
6314 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
6315 +   02111-1307 USA.  */
6317 +#ifndef _SYS_PROCFS_H
6318 +#define _SYS_PROCFS_H  1
6320 +/* This is somewhat modelled after the file of the same name on SVR4
6321 +   systems.  It provides a definition of the core file format for ELF
6322 +   used on Linux.  It doesn't have anything to do with the /proc file
6323 +   system, even though Linux has one.
6325 +   Anyway, the whole purpose of this file is for GDB and GDB only.
6326 +   Don't read too much into it.  Don't use it for anything other than
6327 +   GDB unless you know what you are doing.  */
6329 +#include <features.h>
6330 +#include <sys/time.h>
6331 +#include <sys/types.h>
6332 +#include <sys/user.h>
6334 +__BEGIN_DECLS
6336 +/* Type for a general-purpose register.  */
6337 +typedef unsigned long elf_greg_t;
6339 +/* And the whole bunch of them.  We could have used `struct
6340 +   user_regs' directly in the typedef, but tradition says that
6341 +   the register set is an array, which does have some peculiar
6342 +   semantics, so leave it that way.  */
6343 +#define ELF_NGREG (sizeof (struct user_regs) / sizeof(elf_greg_t))
6344 +typedef elf_greg_t elf_gregset_t[ELF_NGREG];
6346 +/* Register set for the floating-point registers.  */
6347 +typedef struct user_fpregs elf_fpregset_t;
6349 +/* Signal info.  */
6350 +struct elf_siginfo
6351 +  {
6352 +    int si_signo;                      /* Signal number.  */
6353 +    int si_code;                       /* Extra code.  */
6354 +    int si_errno;                      /* Errno.  */
6355 +  };
6357 +/* Definitions to generate Intel SVR4-like core files.  These mostly
6358 +   have the same names as the SVR4 types with "elf_" tacked on the
6359 +   front to prevent clashes with Linux definitions, and the typedef
6360 +   forms have been avoided.  This is mostly like the SVR4 structure,
6361 +   but more Linuxy, with things that Linux does not support and which
6362 +   GDB doesn't really use excluded.  */
6364 +struct elf_prstatus
6365 +  {
6366 +    struct elf_siginfo pr_info;                /* Info associated with signal.  */
6367 +    short int pr_cursig;               /* Current signal.  */
6368 +    unsigned long int pr_sigpend;      /* Set of pending signals.  */
6369 +    unsigned long int pr_sighold;      /* Set of held signals.  */
6370 +    __pid_t pr_pid;
6371 +    __pid_t pr_ppid;
6372 +    __pid_t pr_pgrp;
6373 +    __pid_t pr_sid;
6374 +    struct timeval pr_utime;           /* User time.  */
6375 +    struct timeval pr_stime;           /* System time.  */
6376 +    struct timeval pr_cutime;          /* Cumulative user time.  */
6377 +    struct timeval pr_cstime;          /* Cumulative system time.  */
6378 +    elf_gregset_t pr_reg;              /* GP registers.  */
6379 +    int pr_fpvalid;                    /* True if math copro being used.  */
6380 +  };
6383 +#define ELF_PRARGSZ     (80)    /* Number of chars for args.  */
6385 +struct elf_prpsinfo
6386 +  {
6387 +    char pr_state;                     /* Numeric process state.  */
6388 +    char pr_sname;                     /* Char for pr_state.  */
6389 +    char pr_zomb;                      /* Zombie.  */
6390 +    char pr_nice;                      /* Nice val.  */
6391 +    unsigned long int pr_flag;         /* Flags.  */
6392 +    unsigned short int pr_uid;
6393 +    unsigned short int pr_gid;
6394 +    int pr_pid, pr_ppid, pr_pgrp, pr_sid;
6395 +    /* Lots missing */
6396 +    char pr_fname[16];                 /* Filename of executable.  */
6397 +    char pr_psargs[ELF_PRARGSZ];       /* Initial part of arg list.  */
6398 +  };
6400 +/* The rest of this file provides the types for emulation of the
6401 +   Solaris <proc_service.h> interfaces that should be implemented by
6402 +   users of libthread_db.  */
6404 +/* Addresses.  */
6405 +typedef void *psaddr_t;
6407 +/* Register sets.  Linux has different names.  */
6408 +typedef elf_gregset_t prgregset_t;
6409 +typedef elf_fpregset_t prfpregset_t;
6411 +/* We don't have any differences between processes and threads,
6412 +   therefore have only one PID type.  */
6413 +typedef __pid_t lwpid_t;
6415 +/* Process status and info.  In the end we do provide typedefs for them.  */
6416 +typedef struct elf_prstatus prstatus_t;
6417 +typedef struct elf_prpsinfo prpsinfo_t;
6419 +__END_DECLS
6421 +#endif /* sys/procfs.h */
6422 diff -Nrup a/libc/sysdeps/linux/avr32/sys/ucontext.h b/libc/sysdeps/linux/avr32/sys/ucontext.h
6423 --- a/libc/sysdeps/linux/avr32/sys/ucontext.h   1969-12-31 19:00:00.000000000 -0500
6424 +++ b/libc/sysdeps/linux/avr32/sys/ucontext.h   2008-02-28 19:02:10.000000000 -0500
6425 @@ -0,0 +1,94 @@
6426 +/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
6427 +   This file is part of the GNU C Library.
6429 +   The GNU C Library is free software; you can redistribute it and/or
6430 +   modify it under the terms of the GNU Lesser General Public
6431 +   License as published by the Free Software Foundation; either
6432 +   version 2.1 of the License, or (at your option) any later version.
6434 +   The GNU C Library is distributed in the hope that it will be useful,
6435 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
6436 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6437 +   Lesser General Public License for more details.
6439 +   You should have received a copy of the GNU Lesser General Public
6440 +   License along with the GNU C Library; if not, write to the Free
6441 +   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
6442 +   02111-1307 USA.  */
6444 +/* Linux/AVR32 ABI compliant context switching support.  */
6446 +#ifndef _SYS_UCONTEXT_H
6447 +#define _SYS_UCONTEXT_H        1
6449 +#include <features.h>
6450 +#include <signal.h>
6451 +#include <sys/procfs.h>
6452 +#include <bits/sigcontext.h>
6454 +typedef int greg_t;
6456 +/* Number of general registers.  */
6457 +#define NGREG  16
6459 +/* Container for all general registers.  */
6460 +typedef elf_gregset_t gregset_t;
6462 +/* Number of each register is the `gregset_t' array.  */
6463 +enum
6465 +  R0 = 0,
6466 +#define R0     R0
6467 +  R1 = 1,
6468 +#define R1     R1
6469 +  R2 = 2,
6470 +#define R2     R2
6471 +  R3 = 3,
6472 +#define R3     R3
6473 +  R4 = 4,
6474 +#define R4     R4
6475 +  R5 = 5,
6476 +#define R5     R5
6477 +  R6 = 6,
6478 +#define R6     R6
6479 +  R7 = 7,
6480 +#define R7     R7
6481 +  R8 = 8,
6482 +#define R8     R8
6483 +  R9 = 9,
6484 +#define R9     R9
6485 +  R10 = 10,
6486 +#define R10    R10
6487 +  R11 = 11,
6488 +#define R11    R11
6489 +  R12 = 12,
6490 +#define R12    R12
6491 +  R13 = 13,
6492 +#define R13    R13
6493 +  R14 = 14,
6494 +#define R14    R14
6495 +  R15 = 15
6496 +#define R15    R15
6499 +/* Structure to describe FPU registers.  */
6500 +typedef elf_fpregset_t fpregset_t;
6502 +/* Context to describe whole processor state.  */
6503 +typedef struct
6504 +  {
6505 +    gregset_t gregs;
6506 +    fpregset_t fpregs;
6507 +  } mcontext_t;
6509 +/* Userlevel context.  */
6510 +typedef struct ucontext
6512 +    unsigned long     uc_flags;
6513 +    struct ucontext  *uc_link;
6514 +    stack_t           uc_stack;
6515 +    struct sigcontext uc_mcontext;
6516 +    sigset_t          uc_sigmask;   /* mask last for extensibility */
6517 +} ucontext_t;
6519 +#endif /* sys/ucontext.h */
6520 diff -Nrup a/libc/sysdeps/linux/avr32/sys/user.h b/libc/sysdeps/linux/avr32/sys/user.h
6521 --- a/libc/sysdeps/linux/avr32/sys/user.h       1969-12-31 19:00:00.000000000 -0500
6522 +++ b/libc/sysdeps/linux/avr32/sys/user.h       2008-02-28 19:02:10.000000000 -0500
6523 @@ -0,0 +1,46 @@
6524 +#ifndef _SYS_USER_H
6525 +#define _SYS_USER_H
6527 +struct user_fpregs
6532 +struct user_regs
6534 +       unsigned long sr;
6535 +       unsigned long pc;
6536 +       unsigned long lr;
6537 +       unsigned long sp;
6538 +       unsigned long r12;
6539 +       unsigned long r11;
6540 +       unsigned long r10;
6541 +       unsigned long r9;
6542 +       unsigned long r8;
6543 +       unsigned long r7;
6544 +       unsigned long r6;
6545 +       unsigned long r5;
6546 +       unsigned long r4;
6547 +       unsigned long r3;
6548 +       unsigned long r2;
6549 +       unsigned long r1;
6550 +       unsigned long r0;
6551 +       unsigned long r12_orig;
6554 +struct user
6556 +       struct user_regs        regs;           /* general registers */
6557 +       size_t                  u_tsize;        /* text size (pages) */
6558 +       size_t                  u_dsize;        /* data size (pages) */
6559 +       size_t                  u_ssize;        /* stack size (pages) */
6560 +       unsigned long           start_code;     /* text starting address */
6561 +       unsigned long           start_data;     /* data starting address */
6562 +       unsigned long           start_stack;    /* stack starting address */
6563 +       long int                signal;         /* signal causing core dump */
6564 +       struct user_regs *      u_ar0;          /* help gdb find registers */
6565 +       unsigned long           magic;          /* identifies a core file */
6566 +       char                    u_comm[32];     /* user command name */
6569 +#endif /* _SYS_USER_H */
6570 diff -Nrup a/libc/sysdeps/linux/avr32/syscall.S b/libc/sysdeps/linux/avr32/syscall.S
6571 --- a/libc/sysdeps/linux/avr32/syscall.S        1969-12-31 19:00:00.000000000 -0500
6572 +++ b/libc/sysdeps/linux/avr32/syscall.S        2008-02-28 19:02:10.000000000 -0500
6573 @@ -0,0 +1,81 @@
6575 + * syscall for AVR32/uClibc
6576 + *
6577 + * Copyright (C) 2004 Atmel Norway
6578 + *
6579 + * This program is free software; you can redistribute it and/or modify it
6580 + * under the terms of the GNU Library General Public License as published by
6581 + * the Free Software Foundation; either version 2 of the License, or (at your
6582 + * option) any later version.
6583 + *
6584 + * This program is distributed in the hope that it will be useful, but WITHOUT
6585 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6586 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
6587 + * for more details.
6588 + *
6589 + * You should have received a copy of the GNU Library General Public License
6590 + * along with this program; if not, write to the Free Software Foundation,
6591 + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6592 + */
6593 +#include <features.h>
6595 +       .text
6597 +       /*
6598 +        * long int syscall(long int sysno, ...)
6599 +        */
6600 +       .global syscall
6601 +       .type   syscall, @function
6602 +       .align  2
6603 +syscall:
6604 +       stm     --sp, r3,r5,lr
6605 +       sub     lr, sp, -12
6606 +       mov     r8, r12
6607 +       ldm     lr, r3,r5,r9-r12
6608 +       scall
6609 +       cp.w    r12, -4095
6610 +       brlo    .Ldone
6612 +#ifdef __PIC__
6613 +       lddpc   r5, .Lgot
6614 +.Lgotcalc:
6615 +       rsub    r5, pc
6616 +# ifdef __UCLIBC_HAS_THREADS__
6617 +       mov     r3, r12
6618 +       mcall   r5[__errno_location@got]
6619 +       st.w    r12[0], r3
6620 +# else
6621 +       ld.w    r3, r5[errno@got]
6622 +       st.w    r3[0], r12
6623 +# endif
6624 +#else
6625 +# ifdef __UCLIBC_HAS_THREADS__
6626 +       mov     r3, r12
6627 +       mcall   .Lerrno_location
6628 +       st.w    r12[0], r3
6629 +# else
6630 +       lddpc   r3, .Lerrno
6631 +       st.w    r3[0], r12
6632 +# endif
6633 +#endif
6634 +       mov     r12, -1
6636 +.Ldone:
6637 +       ldm     sp++, r3,r5,pc
6639 +       .align  2
6640 +#ifdef __PIC__
6641 +.Lgot:
6642 +       .long   .Lgotcalc - _GLOBAL_OFFSET_TABLE_
6643 +#else
6644 +# ifdef __UCLIBC_HAS_THREADS__
6645 +.Lerrno_location:
6646 +       .long   __errno_location
6647 +# else
6648 +.Lerrno:
6649 +       .long   errno
6650 +# endif
6651 +#endif
6654 +       .size   syscall, . - syscall
6655 diff -Nrup a/libc/sysdeps/linux/avr32/vfork.S b/libc/sysdeps/linux/avr32/vfork.S
6656 --- a/libc/sysdeps/linux/avr32/vfork.S  1969-12-31 19:00:00.000000000 -0500
6657 +++ b/libc/sysdeps/linux/avr32/vfork.S  2008-02-28 19:02:10.000000000 -0500
6658 @@ -0,0 +1,55 @@
6659 +       /*
6660 +        * vfork for uClibc
6661 +        *
6662 +        * Copyright (C) 2005 Atmel Norway
6663 +        */
6665 +       /*
6666 +        * Clone the process without copying the address space.  The
6667 +        * calling process is suspended until the child either exits
6668 +        * or calls execve.
6669 +        *
6670 +        * This all means that we cannot rely on the stack to store
6671 +        * away registers, since they will be overwritten by the child
6672 +        * as soon as it makes another function call (e.g. execve()).
6673 +        * Fortunately, the Linux kernel preserves LR across system calls.
6674 +        */
6675 +#include <features.h>
6676 +#include <sys/syscall.h>
6678 +       .global __vfork
6679 +       .type   __vfork,@function
6680 +       .align  1
6681 +__vfork:
6682 +       mov     r8, __NR_vfork
6683 +       scall
6684 +       cp.w    r12, -4096
6685 +       retls   r12
6687 +       /* vfork failed, so we may use the stack freely */
6688 +       pushm   r4-r7,lr
6689 +#ifdef __PIC__
6690 +       lddpc   r6, .L_GOT
6691 +       rsub    r4, r12, 0
6692 +.L_RGOT:
6693 +       rsub    r6, pc
6694 +       mcall   r6[__errno_location@got]
6695 +#else
6696 +       rsub    r4, r12, 0
6697 +       mcall   .L__errno_location
6698 +#endif
6699 +       st.w    r12[0], r4
6700 +       popm    r4-r7,pc,r12=-1
6702 +       .align  2
6703 +#ifdef __PIC__
6704 +.L_GOT:
6705 +       .long   .L_RGOT - _GLOBAL_OFFSET_TABLE_
6706 +#else
6707 +.L__errno_location:
6708 +       .long   __errno_location
6709 +#endif
6710 +       .size   __vfork, . - __vfork
6712 +       .weak   vfork
6713 +       vfork   = __vfork
6714 diff -Nrup a/libc/sysdeps/linux/common/create_module.c b/libc/sysdeps/linux/common/create_module.c
6715 --- a/libc/sysdeps/linux/common/create_module.c 2004-03-11 19:21:20.000000000 -0500
6716 +++ b/libc/sysdeps/linux/common/create_module.c 2008-02-28 19:02:10.000000000 -0500
6717 @@ -61,7 +61,8 @@ unsigned long create_module(const char *
6719    return __create_module(name, size, 0, 0);
6721 -#else
6722 +/* create_module is obsolete in Linux 2.6, so AVR32 doesn't have it */
6723 +#elif !defined(__avr32__)
6724  /* Sparc, MIPS, etc don't mistake return values for errors. */ 
6725  _syscall2(unsigned long, create_module, const char *, name, size_t, size);
6726  #endif
6727 diff -Nrup a/libc/sysdeps/linux/common/getrusage.c b/libc/sysdeps/linux/common/getrusage.c
6728 --- a/libc/sysdeps/linux/common/getrusage.c     2005-01-05 18:11:28.000000000 -0500
6729 +++ b/libc/sysdeps/linux/common/getrusage.c     2008-02-28 19:02:10.000000000 -0500
6730 @@ -10,4 +10,4 @@
6731  #include "syscalls.h"
6732  #include <unistd.h>
6733  #include <wait.h>
6734 -_syscall2(int, getrusage, int, who, struct rusage *, usage);
6735 +_syscall2(int, getrusage, __rusage_who_t, who, struct rusage *, usage);
6736 diff -Nrup a/libc/sysdeps/linux/common/open64.c b/libc/sysdeps/linux/common/open64.c
6737 --- a/libc/sysdeps/linux/common/open64.c        2002-10-31 13:20:21.000000000 -0500
6738 +++ b/libc/sysdeps/linux/common/open64.c        2008-02-28 19:02:10.000000000 -0500
6739 @@ -26,7 +26,7 @@
6740  #endif
6742  #ifdef __UCLIBC_HAS_LFS__
6743 -extern int __libc_open (__const char *file, int oflag, mode_t mode);
6744 +extern int __libc_open (__const char *file, int oflag, ...);
6746  /* Open FILE with access OFLAG.  If OFLAG includes O_CREAT,
6747     a third argument is the file protection.  */
6748 diff -Nrup a/libc/sysdeps/linux/common/__syscall_fcntl.c b/libc/sysdeps/linux/common/__syscall_fcntl.c
6749 --- a/libc/sysdeps/linux/common/__syscall_fcntl.c       2005-07-30 10:02:24.000000000 -0400
6750 +++ b/libc/sysdeps/linux/common/__syscall_fcntl.c       2008-02-28 19:02:10.000000000 -0500
6751 @@ -12,7 +12,7 @@
6752  #include <fcntl.h>
6754  #if defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64
6755 -extern int __libc_fcntl64(int fd, int cmd, long arg);
6756 +extern int __libc_fcntl64(int fd, int cmd, ...);
6757  #endif
6759  #define __NR___syscall_fcntl __NR_fcntl
6760 diff -Nrup a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h
6761 --- a/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h        1969-12-31 19:00:00.000000000 -0500
6762 +++ b/libpthread/linuxthreads/sysdeps/avr32/pt-machine.h        2008-02-28 19:02:10.000000000 -0500
6763 @@ -0,0 +1,92 @@
6764 +/* Machine-dependent pthreads configuration and inline functions.
6766 +   Copyright (C) 2005 Atmel Norway
6767 +   This file is part of the GNU C Library.
6769 +   The GNU C Library is free software; you can redistribute it and/or
6770 +   modify it under the terms of the GNU Lesser General Public License as
6771 +   published by the Free Software Foundation; either version 2.1 of the
6772 +   License, or (at your option) any later version.
6774 +   The GNU C Library is distributed in the hope that it will be useful,
6775 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
6776 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
6777 +   Lesser General Public License for more details.
6779 +   You should have received a copy of the GNU Lesser General Public
6780 +   License along with the GNU C Library; see the file COPYING.LIB.  If not,
6781 +   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
6782 +   Boston, MA 02111-1307, USA.  */
6784 +#ifndef _PT_MACHINE_H
6785 +#define _PT_MACHINE_H   1
6787 +#include <features.h>
6789 +static inline int
6790 +_test_and_set (int *p, int v) __THROW
6792 +       int result;
6794 +       __asm__ __volatile__(
6795 +               "/* Inline test and set */\n"
6796 +               "1:     ssrf    5\n"
6797 +               "       ld.w    %0, %2\n"
6798 +               "       tst     %0, %3\n"
6799 +               "       breq    2f\n"
6800 +               "       stcond  %1, %3\n"
6801 +               "       brne    1b\n"
6802 +               "2:"
6803 +               : "=&r"(result), "=m"(*p)
6804 +               : "m"(*p), "r"(v)
6805 +               : "memory", "cc");
6807 +       return result;
6810 +#ifndef PT_EI
6811 +# define PT_EI extern inline
6812 +#endif
6814 +extern long int testandset (int *spinlock);
6815 +extern int __compare_and_swap (long int *p, long int oldval, long int newval);
6817 +/* Spinlock implementation; required.  */
6818 +PT_EI long int
6819 +testandset (int *spinlock)
6821 +       return _test_and_set(spinlock, 1);
6825 +/* Get some notion of the current stack.  Need not be exactly the top
6826 +   of the stack, just something somewhere in the current frame.  */
6827 +#define CURRENT_STACK_FRAME  stack_pointer
6828 +register char * stack_pointer __asm__ ("sp");
6830 +/* Compare-and-swap for semaphores. */
6832 +#define HAS_COMPARE_AND_SWAP
6833 +PT_EI int
6834 +__compare_and_swap(long int *p, long int oldval, long int newval)
6836 +       long int result, tmp;
6838 +       __asm__ __volatile__(
6839 +               "/* Inline compare and swap */\n"
6840 +               "1:     ssrf    5\n"
6841 +               "       ld.w    %1, %3\n"
6842 +               "       cp.w    %1, %5\n"
6843 +               "       sreq    %0\n"
6844 +               "       brne    2f\n"
6845 +               "       stcond  %2, %4\n"
6846 +               "       brne    1b\n"
6847 +               "2:"
6848 +               : "=&r"(result), "=&r"(tmp), "=m"(*p)
6849 +               : "m"(*p), "r"(newval), "r"(oldval)
6850 +               : "cc", "memory");
6852 +       return result;
6855 +#endif /* pt-machine.h */
6856 diff -Nrup a/Makefile b/Makefile
6857 --- a/Makefile  2007-02-01 21:24:29.000000000 -0500
6858 +++ b/Makefile  2008-02-28 19:02:10.000000000 -0500
6859 @@ -163,7 +163,7 @@ install_dev:
6860         else \
6861                 extra_exclude="" ; \
6862         fi ; \
6863 -       tar -chf - include --exclude .svn --exclude CVS $$extra_exclude \
6864 +       tar -chf - --exclude .svn --exclude CVS $$extra_exclude include \
6865                 | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
6866         echo '/* Dont use _syscall#() macros; use the syscall() function */' > \
6867                 $(PREFIX)$(DEVEL_PREFIX)include/bits/syscalls.h
6868 diff -Nrup a/Makefile.orig b/Makefile.orig
6869 --- a/Makefile.orig     1969-12-31 19:00:00.000000000 -0500
6870 +++ b/Makefile.orig     2007-02-01 21:24:29.000000000 -0500
6871 @@ -0,0 +1,383 @@
6872 +# Makefile for uClibc
6874 +# Copyright (C) 2000-2003 Erik Andersen <andersen@uclibc.org>
6876 +# This program is free software; you can redistribute it and/or
6877 +# modify it under the terms of the GNU Library General Public
6878 +# License as published by the Free Software Foundation; either
6879 +# version 2 of the License, or (at your option) any later
6880 +# version.
6882 +# This program is distributed in the hope that it will be useful,
6883 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
6884 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6885 +# GNU Library General Public License for more details.
6887 +# You should have received a copy of the GNU Library General
6888 +# Public License along with this program; if not, write to the
6889 +# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
6890 +# Boston, MA 02111-1307 USA
6893 +#--------------------------------------------------------------
6894 +# You shouldn't need to mess with anything beyond this point...
6895 +#--------------------------------------------------------------
6896 +noconfig_targets := menuconfig config oldconfig randconfig \
6897 +       defconfig allyesconfig allnoconfig clean distclean \
6898 +       release tags TAGS
6899 +TOPDIR=./
6900 +include Rules.mak
6902 +DIRS = ldso libc libcrypt libresolv libnsl libutil libm libpthread librt
6903 +ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
6904 +       DIRS += libintl
6905 +endif
6907 +ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
6909 +all: headers pregen subdirs shared finished
6911 +# In this section, we need .config
6912 +-include .config.cmd
6914 +shared: subdirs
6915 +ifeq ($(strip $(HAVE_SHARED)),y)
6916 +       $(SECHO)
6917 +       $(SECHO) Building shared libraries ...
6918 +       $(SECHO)
6919 +       @$(MAKE) -C libc shared
6920 +       @$(MAKE) -C ldso shared
6921 +       @$(MAKE) -C libcrypt shared
6922 +       @$(MAKE) -C libresolv shared
6923 +       @$(MAKE) -C libnsl shared
6924 +       @$(MAKE) -C libutil shared
6925 +       @$(MAKE) -C libm shared
6926 +       @$(MAKE) -C libpthread shared
6927 +       @$(MAKE) -C librt shared
6928 +ifeq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
6929 +       @$(MAKE) -C libintl shared
6930 +endif
6931 +else
6932 +       $(SECHO)
6933 +       $(SECHO) Not building shared libraries ...
6934 +       $(SECHO)
6935 +endif
6937 +finished: shared
6938 +       $(SECHO)
6939 +       $(SECHO) Finally finished compiling ...
6940 +       $(SECHO)
6942 +include/bits/uClibc_config.h: .config
6943 +       @if [ ! -x ./extra/config/conf ] ; then \
6944 +           $(MAKE) -C extra/config conf; \
6945 +       fi;
6946 +       $(RM) -r include/bits
6947 +       $(INSTALL) -d include/bits
6948 +       @./extra/config/conf -o extra/Configs/Config.in
6950 +# For the moment, we have to keep re-running this target 
6951 +# because the fix includes scripts rely on pre-processers 
6952 +# in order to generate the headers correctly :(.  That 
6953 +# means we can't use the $(HOSTCC) in order to get the 
6954 +# correct output.
6955 +ifeq ($(strip $(ARCH_HAS_MMU)),y)
6956 +export header_extra_args = 
6957 +else
6958 +export header_extra_args = -n
6959 +endif
6960 +headers: include/bits/uClibc_config.h
6961 +       @$(SHELL_SET_X); \
6962 +       ./extra/scripts/fix_includes.sh \
6963 +               -k $(KERNEL_SOURCE) -t $(TARGET_ARCH) \
6964 +               $(header_extra_args)
6965 +       @cd include/bits; \
6966 +       set -e; \
6967 +       for i in `ls ../../libc/sysdeps/linux/common/bits/*.h` ; do \
6968 +               $(LN) -fs $$i .; \
6969 +       done; \
6970 +       if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits ] ; then \
6971 +               for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/bits/*.h` ; do \
6972 +                       $(LN) -fs $$i .; \
6973 +               done; \
6974 +       fi
6975 +       @cd include/sys; \
6976 +       set -e; \
6977 +       for i in `ls ../../libc/sysdeps/linux/common/sys/*.h` ; do \
6978 +               $(LN) -fs $$i .; \
6979 +       done; \
6980 +       if [ -d ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
6981 +               for i in `ls ../../libc/sysdeps/linux/$(TARGET_ARCH)/sys/*.h` ; do \
6982 +                       $(LN) -fs $$i .; \
6983 +               done; \
6984 +       fi
6985 +       @cd $(TOPDIR); \
6986 +       set -e; \
6987 +       $(SHELL_SET_X); \
6988 +       TOPDIR=. CC="$(CC)" /bin/sh extra/scripts/gen_bits_syscall_h.sh > include/bits/sysnum.h.new; \
6989 +       if cmp include/bits/sysnum.h include/bits/sysnum.h.new >/dev/null 2>&1; then \
6990 +               $(RM) include/bits/sysnum.h.new; \
6991 +       else \
6992 +               mv -f include/bits/sysnum.h.new include/bits/sysnum.h; \
6993 +       fi
6994 +       $(MAKE) -C libc/sysdeps/linux/common headers
6995 +       $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) headers
6997 +# Command used to download source code
6998 +WGET:=wget --passive-ftp
7000 +LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
7002 +pregen: headers
7003 +ifeq ($(strip $(UCLIBC_DOWNLOAD_PREGENERATED_LOCALE_DATA)),y)
7004 +       (cd extra/locale; \
7005 +       if [ ! -f $(LOCALE_DATA_FILENAME) ] ; then \
7006 +       $(WGET) http://www.uclibc.org/downloads/$(LOCALE_DATA_FILENAME) ; \
7007 +       fi );
7008 +endif
7009 +ifeq ($(strip $(UCLIBC_PREGENERATED_LOCALE_DATA)),y)
7010 +       (cd extra/locale; zcat $(LOCALE_DATA_FILENAME) | tar -xvf -)
7011 +       $(MAKE) -C extra/locale pregen
7012 +endif
7015 +subdirs: $(patsubst %, _dir_%, $(DIRS))
7016 +$(patsubst %, _dir_%, $(DIRS)): headers
7017 +       $(MAKE) -C $(patsubst _dir_%, %, $@)
7019 +tags:
7020 +       ctags -R
7022 +install: install_runtime install_dev finished2
7025 +RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell extra/scripts/relative_path.sh $(DEVEL_PREFIX)lib $(RUNTIME_PREFIX)lib)
7027 +# Installs header files and development library links.
7028 +install_dev:
7029 +       $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)lib
7030 +       $(INSTALL) -d $(PREFIX)$(DEVEL_PREFIX)include
7031 +       -$(INSTALL) -m 644 lib/*.[ao] $(PREFIX)$(DEVEL_PREFIX)lib/
7032 +       if [ "$(KERNEL_SOURCE)" = "$(DEVEL_PREFIX)" ] ; then \
7033 +               extra_exclude="--exclude include/linux --exclude include/asm'*'" ; \
7034 +       else \
7035 +               extra_exclude="" ; \
7036 +       fi ; \
7037 +       tar -chf - include --exclude .svn --exclude CVS $$extra_exclude \
7038 +               | tar -xf - -C $(PREFIX)$(DEVEL_PREFIX)
7039 +       echo '/* Dont use _syscall#() macros; use the syscall() function */' > \
7040 +               $(PREFIX)$(DEVEL_PREFIX)include/bits/syscalls.h
7041 +ifneq ($(strip $(UCLIBC_HAS_FLOATS)),y)
7042 +       # Remove floating point related headers since float support is disabled.
7043 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/complex.h
7044 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/fpu_control.h
7045 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ieee754.h
7046 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/math.h
7047 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/tgmath.h
7048 +endif
7049 +ifneq ($(strip $(UCLIBC_HAS_WCHAR)),y)
7050 +       # Remove wide char headers since wide char support is disabled.
7051 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wctype.h
7052 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wchar.h
7053 +endif
7054 +ifneq ($(strip $(UCLIBC_HAS_LOCALE)),y)
7055 +       # Remove iconv header since locale support is disabled.
7056 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/iconv.h
7057 +endif
7058 +ifneq ($(strip $(UCLIBC_HAS_GLIBC_CUSTOM_PRINTF)),y)
7059 +       # Remove printf header since custom print specifier support is disabled.
7060 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/printf.h
7061 +endif
7062 +ifneq ($(strip $(UCLIBC_HAS_XLOCALE)),y)
7063 +       # Remove xlocale header since extended locale support is disabled.
7064 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/xlocale.h
7065 +endif
7066 +ifneq ($(strip $(UCLIBC_HAS_GETTEXT_AWARENESS)),y)
7067 +       # Remove libintl header since gettext support is disabled.
7068 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/libintl.h
7069 +endif
7070 +ifneq ($(strip $(UCLIBC_HAS_REGEX)),y)
7071 +       # Remove regex headers since regex support is disabled.
7072 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regex.h
7073 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/regexp.h
7074 +endif
7075 +ifneq ($(strip $(UCLIBC_HAS_WORDEXP)),y)
7076 +       # Remove wordexp header since wordexp support is disabled.
7077 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/wordexp.h
7078 +endif
7079 +ifneq ($(strip $(UCLIBC_HAS_FTW)),y)
7080 +       # Remove ftw header since ftw support is disabled.
7081 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/ftw.h
7082 +endif
7083 +ifneq ($(strip $(UCLIBC_HAS_GLOB)),y)
7084 +       # Remove glob header since glob support is disabled.
7085 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/glob.h
7086 +endif
7087 +ifneq ($(strip $(UCLIBC_HAS_GNU_GETOPT)),y)
7088 +       # Remove getopt header since gnu getopt support is disabled.
7089 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/getopt.h
7090 +endif
7091 +ifneq ($(strip $(HAS_SHADOW)),y)
7092 +       # Remove getopt header since shadow password support is disabled.
7093 +       $(RM) $(PREFIX)$(DEVEL_PREFIX)include/shadow.h
7094 +endif
7095 +       -@for i in `find  $(PREFIX)$(DEVEL_PREFIX) -type d` ; do \
7096 +           chmod 755 $$i; chmod 644 $$i/*.h > /dev/null 2>&1; \
7097 +       done;
7098 +       -find $(PREFIX)$(DEVEL_PREFIX) -name .svn | xargs $(RM) -r;
7099 +       -chown -R `id | sed 's/^uid=\([0-9]*\).*gid=\([0-9]*\).*$$/\1:\2/'` $(PREFIX)$(DEVEL_PREFIX)
7100 +ifeq ($(strip $(HAVE_SHARED)),y)
7101 +       for i in `find lib/ -type l -name 'lib[a-zA-Z]*.so' | \
7102 +       sed -e 's/lib\///'` ; do \
7103 +               $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)$$i.$(MAJOR_VERSION) \
7104 +               $(PREFIX)$(DEVEL_PREFIX)lib/$$i; \
7105 +       done;
7106 +ifeq ($(strip $(PTHREADS_DEBUG_SUPPORT)),y)
7107 +       $(LN) -sf $(RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB)libthread_db.so.1 \
7108 +               $(PREFIX)$(DEVEL_PREFIX)lib/libthread_db.so
7109 +endif
7110 +#      # If we build shared libraries then the static libs are PIC...
7111 +#      # Make _pic.a symlinks to make mklibs.py and similar tools happy.
7112 +       for i in `find lib/  -type f -name '*.a' | sed -e 's/lib\///'` ; do \
7113 +               $(LN) -sf $$i $(PREFIX)$(DEVEL_PREFIX)lib/`echo $$i \
7114 +                       | sed -e 's/\.a$$/_pic.a/'`; \
7115 +       done;
7116 +       # Ugh!!! Remember that libdl.a and libdl_pic.a are different.  Since
7117 +       # libdl is pretty small, and not likely to benefit from mklibs.py and
7118 +       # similar, lets just remove libdl_pic.a and avoid the issue
7119 +       rm -f $(PREFIX)$(DEVEL_PREFIX)lib/libdl_pic.a
7120 +endif
7123 +# Installs run-time libraries
7124 +install_runtime:
7125 +ifeq ($(strip $(HAVE_SHARED)),y)
7126 +       $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)lib
7127 +       $(INSTALL) -m 644 lib/lib*-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
7128 +               $(PREFIX)$(RUNTIME_PREFIX)lib
7129 +       cp -dRf lib/*.so.* $(PREFIX)$(RUNTIME_PREFIX)lib
7130 +       @if [ -x lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so ] ; then \
7131 +           set -e; \
7132 +               $(SHELL_SET_X); \
7133 +           $(INSTALL) -m 755 lib/ld-uClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so \
7134 +                       $(PREFIX)$(RUNTIME_PREFIX)lib; \
7135 +       fi;
7136 +endif
7138 +.PHONY: utils
7139 +ifeq ($(strip $(HAVE_SHARED)),y)
7140 +utils:
7141 +       $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils
7142 +else
7143 +utils: dummy
7144 +endif
7146 +# Installs helper applications, such as 'ldd' and 'ldconfig'
7147 +install_utils: utils
7148 +       $(MAKE) CROSS="$(CROSS)" CC="$(CC)" -C utils install
7149 +#ifeq ($(strip $(UCLIBC_HAS_LOCALE)),y)
7150 +#      @$(MAKE) -C libc/misc/wchar iconv.target
7151 +#      $(INSTALL) -d $(PREFIX)$(RUNTIME_PREFIX)/usr/bin;
7152 +#      $(INSTALL) -m 755 libc/misc/wchar/iconv.target $(PREFIX)$(RUNTIME_PREFIX)/usr/bin/iconv
7153 +#endif
7155 +finished2:
7156 +       $(SECHO)
7157 +       $(SECHO) Finished installing ...
7158 +       $(SECHO)
7160 +else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
7162 +all: menuconfig
7164 +# configuration
7165 +# ---------------------------------------------------------------------------
7166 +extra/config/conf:
7167 +       $(MAKE) -C extra/config conf
7169 +extra/config/mconf:
7170 +       $(MAKE) -C extra/config ncurses mconf
7172 +menuconfig: extra/config/mconf
7173 +       $(RM) -r include/bits
7174 +       $(INSTALL) -d include/bits
7175 +       @./extra/config/mconf extra/Configs/Config.in
7177 +config: extra/config/conf
7178 +       $(RM) -r include/bits
7179 +       $(INSTALL) -d include/bits
7180 +       @./extra/config/conf extra/Configs/Config.in
7182 +oldconfig: extra/config/conf
7183 +       $(RM) -r include/bits
7184 +       $(INSTALL) -d include/bits
7185 +       @./extra/config/conf -o extra/Configs/Config.in
7187 +randconfig: extra/config/conf
7188 +       $(RM) -r include/bits
7189 +       $(INSTALL) -d include/bits
7190 +       @./extra/config/conf -r extra/Configs/Config.in
7192 +allyesconfig: extra/config/conf
7193 +       $(RM) -r include/bits
7194 +       $(INSTALL) -d include/bits
7195 +       @./extra/config/conf -y extra/Configs/Config.in
7196 +       sed -i -e "s/^DODEBUG=.*/# DODEBUG is not set/" .config
7197 +       sed -i -e "s/^DOASSERTS=.*/# DOASSERTS is not set/" .config
7198 +       sed -i -e "s/^SUPPORT_LD_DEBUG_EARLY=.*/# SUPPORT_LD_DEBUG_EARLY is not set/" .config
7199 +       sed -i -e "s/^SUPPORT_LD_DEBUG=.*/# SUPPORT_LD_DEBUG is not set/" .config
7200 +       sed -i -e "s/^UCLIBC_MJN3_ONLY=.*/# UCLIBC_MJN3_ONLY is not set/" .config
7201 +       @./extra/config/conf -o extra/Configs/Config.in
7203 +allnoconfig: extra/config/conf
7204 +       $(RM) -r include/bits
7205 +       $(INSTALL) -d include/bits
7206 +       @./extra/config/conf -n extra/Configs/Config.in
7208 +defconfig: extra/config/conf
7209 +       $(RM) -r include/bits
7210 +       $(INSTALL) -d include/bits
7211 +       @./extra/config/conf -d extra/Configs/Config.in
7213 +clean:
7214 +       - find . \( -name \*.o -o -name \*.a -o -name \*.so -o -name core -o -name .\#\* \) -exec $(RM) {} \;
7215 +       @$(RM) -r tmp lib include/bits libc/tmp _install
7216 +       $(RM) libc/obj.* headers
7217 +       $(MAKE) -C test clean
7218 +       $(MAKE) -C ldso clean
7219 +       $(MAKE) -C libc/misc/internals clean
7220 +       $(MAKE) -C libc/misc/wchar clean
7221 +       $(MAKE) -C libc/unistd clean
7222 +       $(MAKE) -C libc/sysdeps/linux/common clean
7223 +       $(MAKE) -C extra/locale clean
7224 +       $(MAKE) -C utils clean
7225 +       @set -e; \
7226 +       for i in `(cd $(TOPDIR)/libc/sysdeps/linux/common/sys; ls *.h)` ; do \
7227 +               $(RM) include/sys/$$i; \
7228 +       done; \
7229 +       if [ -d libc/sysdeps/linux/$(TARGET_ARCH)/sys ] ; then \
7230 +               for i in `(cd libc/sysdeps/linux/$(TARGET_ARCH)/sys; ls *.h)` ; do \
7231 +                       $(RM) include/sys/$$i; \
7232 +               done; \
7233 +       fi;
7234 +       @$(RM) include/linux include/asm*
7235 +       @if [ -d libc/sysdeps/linux/$(TARGET_ARCH) ]; then              \
7236 +           $(MAKE) -C libc/sysdeps/linux/$(TARGET_ARCH) clean;         \
7237 +       fi;
7239 +distclean: clean
7240 +       $(RM) .config .config.old .config.cmd
7241 +       $(MAKE) -C extra clean
7243 +dist release:
7244 +       $(RM) -r ../uClibc-$(VERSION) ../uClibc-$(VERSION).tar.bz2
7245 +       svn -q export . ../uClibc-$(VERSION)
7246 +       tar cjf ../uClibc-$(VERSION).tar.bz2 -C .. uClibc-$(VERSION)
7247 +       du -b ../uClibc-$(VERSION).tar.bz2
7249 +endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
7251 +check:
7252 +       $(MAKE) -C test
7254 +.PHONY: dummy subdirs release distclean clean config oldconfig menuconfig
7255 diff -Nrup a/Rules.mak b/Rules.mak
7256 --- a/Rules.mak 2007-02-28 16:12:06.000000000 -0500
7257 +++ b/Rules.mak 2008-02-28 19:02:10.000000000 -0500
7258 @@ -234,6 +234,12 @@ ifeq ($(strip $(TARGET_ARCH)),frv)
7259         UCLIBC_LDSO=ld.so.1
7260  endif
7262 +ifeq ($(strip $(TARGET_ARCH)),avr32)
7263 +       CPU_CFLAGS-$(CONFIG_AP7000)     += -mcpu=ap7000
7264 +       CPU_CFLAGS-$(LINKRELAX)         += -masm-addr-pseudos -Wa,--pic,--linkrelax
7265 +       CPU_LDFLAGS-$(LINKRELAX)        += --relax
7266 +endif
7268  # Keep the check_gcc from being needlessly executed
7269  ifndef PIEFLAG
7270  ifneq ($(UCLIBC_BUILD_PIE),y)
7271 diff -Nrup a/Rules.mak.orig b/Rules.mak.orig
7272 --- a/Rules.mak.orig    1969-12-31 19:00:00.000000000 -0500
7273 +++ b/Rules.mak.orig    2008-02-28 19:02:10.000000000 -0500
7274 @@ -0,0 +1,361 @@
7275 +# Rules.make for uClibc
7277 +# Copyright (C) 2000 by Lineo, inc.
7278 +# Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
7280 +# This program is free software; you can redistribute it and/or modify it under
7281 +# the terms of the GNU Library General Public License as published by the Free
7282 +# Software Foundation; either version 2 of the License, or (at your option) any
7283 +# later version.
7285 +# This program is distributed in the hope that it will be useful, but WITHOUT
7286 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
7287 +# FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
7288 +# details.
7290 +# You should have received a copy of the GNU Library General Public License
7291 +# along with this program; if not, write to the Free Software Foundation, Inc.,
7292 +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
7295 +#-----------------------------------------------------------
7296 +# This file contains rules which are shared between multiple
7297 +# Makefiles.  All normal configuration options live in the 
7298 +# file named ".config".  Don't mess with this file unless 
7299 +# you know what you are doing.
7302 +#-----------------------------------------------------------
7303 +# If you are running a cross compiler, you will want to set 
7304 +# 'CROSS' to something more interesting ...  Target 
7305 +# architecture is determined by asking the CC compiler what 
7306 +# arch it compiles things for, so unless your compiler is 
7307 +# broken, you should not need to specify TARGET_ARCH.
7309 +# Most people will set this stuff on the command line, i.e.
7310 +#        make CROSS=arm-linux-
7311 +# will build uClibc for 'arm'.
7313 +ifndef CROSS
7314 +CROSS=
7315 +endif
7316 +CC         = $(CROSS)gcc
7317 +AR         = $(CROSS)ar
7318 +LD         = $(CROSS)ld
7319 +NM         = $(CROSS)nm
7320 +RANLIB     = $(CROSS)ranlib
7321 +STRIPTOOL  = $(CROSS)strip
7323 +INSTALL    = install
7324 +LN         = ln
7325 +RM         = rm -f
7327 +# Select the compiler needed to build binaries for your development system
7328 +HOSTCC     = gcc
7329 +HOSTCFLAGS = -O2 -Wall
7332 +#---------------------------------------------------------
7333 +# Nothing beyond this point should ever be touched by mere
7334 +# mortals.  Unless you hang out with the gods, you should
7335 +# probably leave all this stuff alone.
7336 +MAJOR_VERSION := 0
7337 +MINOR_VERSION := 9
7338 +SUBLEVEL      := 28
7339 +EXTRAVERSION  := 3
7340 +VERSION       := $(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).$(EXTRAVERSION)
7341 +# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
7342 +LC_ALL := C
7343 +export MAJOR_VERSION MINOR_VERSION SUBLEVEL VERSION LC_ALL
7345 +SHARED_FULLNAME:=libuClibc-$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL).so
7346 +SHARED_MAJORNAME:=libc.so.$(MAJOR_VERSION)
7347 +UCLIBC_LDSO:=ld-uClibc.so.$(MAJOR_VERSION)
7348 +LIBNAME:=libc.a
7349 +LIBC:=$(TOPDIR)libc/$(LIBNAME)
7351 +# Make sure DESTDIR and PREFIX can be used to install
7352 +# PREFIX is a uClibcism while DESTDIR is a common GNUism
7353 +ifndef PREFIX
7354 +PREFIX = $(DESTDIR)
7355 +endif
7357 +# Pull in the user's uClibc configuration
7358 +ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
7359 +-include $(TOPDIR).config
7360 +endif
7362 +ifndef CROSS
7363 +CROSS=$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
7364 +endif
7366 +# A nifty macro to make testing gcc features easier
7367 +check_gcc=$(shell \
7368 +       if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
7369 +       then echo "$(1)"; else echo "$(2)"; fi)
7370 +check_as=$(shell \
7371 +       if $(CC) -Wa,$(1) -Wa,-Z -c -o /dev/null -xassembler /dev/null > /dev/null 2>&1; \
7372 +       then echo "-Wa,$(1)"; fi)
7374 +# Setup some shortcuts so that silent mode is silent like it should be
7375 +ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
7376 +export MAKE_IS_SILENT=n
7377 +SECHO=@echo
7378 +SHELL_SET_X=set -x
7379 +else
7380 +export MAKE_IS_SILENT=y
7381 +SECHO=-@false
7382 +SHELL_SET_X=set +x
7383 +endif
7385 +# Make certain these contain a final "/", but no "//"s.
7386 +TARGET_ARCH:=$(shell grep -s ^TARGET_ARCH $(TOPDIR)/.config | sed -e 's/^TARGET_ARCH=//' -e 's/"//g')
7387 +RUNTIME_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(RUNTIME_PREFIX))))))
7388 +DEVEL_PREFIX:=$(strip $(subst //,/, $(subst ,/, $(subst ",, $(strip $(DEVEL_PREFIX))))))
7389 +export RUNTIME_PREFIX DEVEL_PREFIX
7391 +ARFLAGS:=cr
7393 +OPTIMIZATION:=
7394 +PICFLAG:=-fPIC
7395 +PIEFLAG_NAME:=-fPIE
7397 +# Some nice CPU specific optimizations
7398 +ifeq ($(strip $(TARGET_ARCH)),i386)
7399 +       OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
7400 +       OPTIMIZATION+=$(call check_gcc,-falign-jumps=0 -falign-loops=0,-malign-jumps=0 -malign-loops=0)
7401 +       CPU_CFLAGS-$(CONFIG_386)+=-march=i386
7402 +       CPU_CFLAGS-$(CONFIG_486)+=-march=i486
7403 +       CPU_CFLAGS-$(CONFIG_ELAN)+=-march=i486
7404 +       CPU_CFLAGS-$(CONFIG_586)+=-march=i586
7405 +       CPU_CFLAGS-$(CONFIG_586MMX)+=$(call check_gcc,-march=pentium-mmx,-march=i586)
7406 +       CPU_CFLAGS-$(CONFIG_686)+=-march=i686
7407 +       CPU_CFLAGS-$(CONFIG_PENTIUMII)+=$(call check_gcc,-march=pentium2,-march=i686)
7408 +       CPU_CFLAGS-$(CONFIG_PENTIUMIII)+=$(call check_gcc,-march=pentium3,-march=i686)
7409 +       CPU_CFLAGS-$(CONFIG_PENTIUM4)+=$(call check_gcc,-march=pentium4,-march=i686)
7410 +       CPU_CFLAGS-$(CONFIG_K6)+=$(call check_gcc,-march=k6,-march=i586)
7411 +       CPU_CFLAGS-$(CONFIG_K7)+=$(call check_gcc,-march=athlon,-malign-functions=4 -march=i686)
7412 +       CPU_CFLAGS-$(CONFIG_CRUSOE)+=-march=i686 -malign-functions=0 -malign-jumps=0 -malign-loops=0
7413 +       CPU_CFLAGS-$(CONFIG_WINCHIPC6)+=$(call check_gcc,-march=winchip-c6,-march=i586)
7414 +       CPU_CFLAGS-$(CONFIG_WINCHIP2)+=$(call check_gcc,-march=winchip2,-march=i586)
7415 +       CPU_CFLAGS-$(CONFIG_CYRIXIII)+=$(call check_gcc,-march=c3,-march=i486) -malign-functions=0 -malign-jumps=0 -malign-loops=0
7416 +       CPU_CFLAGS-$(CONFIG_NEHEMIAH)+=$(call check_gcc,-march=c3-2,-march=i686)
7417 +endif
7419 +ifeq ($(strip $(TARGET_ARCH)),arm)
7420 +       OPTIMIZATION+=-fstrict-aliasing
7421 +       CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-EL
7422 +       CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-EB
7423 +       CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-mlittle-endian
7424 +       CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mbig-endian
7425 +       CPU_CFLAGS-$(CONFIG_GENERIC_ARM)+=
7426 +       CPU_CFLAGS-$(CONFIG_ARM610)+=-mtune=arm610 -march=armv3
7427 +       CPU_CFLAGS-$(CONFIG_ARM710)+=-mtune=arm710 -march=armv3
7428 +       CPU_CFLAGS-$(CONFIG_ARM720T)+=-mtune=arm7tdmi -march=armv4
7429 +       CPU_CFLAGS-$(CONFIG_ARM920T)+=-mtune=arm9tdmi -march=armv4
7430 +       CPU_CFLAGS-$(CONFIG_ARM922T)+=-mtune=arm9tdmi -march=armv4
7431 +       CPU_CFLAGS-$(CONFIG_ARM926T)+=-mtune=arm9tdmi -march=armv5
7432 +       CPU_CFLAGS-$(CONFIG_ARM1136JF_S)+=-mtune=arm1136jf-s -march=armv6
7433 +       CPU_CFLAGS-$(CONFIG_ARM_SA110)+=-mtune=strongarm110 -march=armv4
7434 +       CPU_CFLAGS-$(CONFIG_ARM_SA1100)+=-mtune=strongarm1100 -march=armv4
7435 +       CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=$(call check_gcc,-mtune=xscale,-mtune=strongarm110)
7436 +       CPU_CFLAGS-$(CONFIG_ARM_XSCALE)+=-march=armv4 -Wa,-mcpu=xscale
7437 +endif
7439 +ifeq ($(strip $(TARGET_ARCH)),mips)
7440 +       CPU_CFLAGS-$(CONFIG_MIPS_ISA_1)+=-mips1
7441 +       CPU_CFLAGS-$(CONFIG_MIPS_ISA_2)+=-mips2 -mtune=mips2
7442 +       CPU_CFLAGS-$(CONFIG_MIPS_ISA_3)+=-mips3 -mtune=mips3
7443 +       CPU_CFLAGS-$(CONFIG_MIPS_ISA_4)+=-mips4 -mtune=mips4
7444 +       CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS32)+=-mips32 -mtune=mips32
7445 +       CPU_CFLAGS-$(CONFIG_MIPS_ISA_MIPS64)+=-mips64 -mtune=mips32
7446 +endif
7448 +ifeq ($(strip $(TARGET_ARCH)),sh)
7449 +       OPTIMIZATION+=-fstrict-aliasing
7450 +       OPTIMIZATION+= $(call check_gcc,-mprefergot,)
7451 +       CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN)+=-EL
7452 +       CPU_LDFLAGS-$(ARCH_BIG_ENDIAN)+=-EB
7453 +       CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN)+=-ml
7454 +       CPU_CFLAGS-$(ARCH_BIG_ENDIAN)+=-mb
7455 +       CPU_CFLAGS-$(CONFIG_SH2)+=-m2
7456 +       CPU_CFLAGS-$(CONFIG_SH3)+=-m3
7457 +ifeq ($(strip $(UCLIBC_HAS_FLOATS)),y)
7458 +       CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a
7459 +       CPU_CFLAGS-$(CONFIG_SH4)+=-m4
7460 +else
7461 +       CPU_CFLAGS-$(CONFIG_SH2A)+=-m2a-nofpu
7462 +       CPU_CFLAGS-$(CONFIG_SH4)+=-m4-nofpu
7463 +endif
7464 +endif
7466 +ifeq ($(strip $(TARGET_ARCH)),sh64)
7467 +       OPTIMIZATION+=-fstrict-aliasing
7468 +       CPU_LDFLAGS-$(ARCH_LITTLE_ENDIAN):=-EL
7469 +       CPU_LDFLAGS-$(ARCH_BIG_ENDIAN):=-EB
7470 +       CPU_CFLAGS-$(ARCH_LITTLE_ENDIAN):=-ml
7471 +       CPU_CFLAGS-$(ARCH_BIG_ENDIAN):=-mb
7472 +       CPU_CFLAGS-$(CONFIG_SH5)+=-m5-32media
7473 +endif
7475 +ifeq ($(strip $(TARGET_ARCH)),h8300)
7476 +       CPU_LDFLAGS-$(CONFIG_H8300H)+= -ms8300h
7477 +       CPU_LDFLAGS-$(CONFIG_H8S)   += -ms8300s
7478 +       CPU_CFLAGS-$(CONFIG_H8300H) += -mh -mint32 -fsigned-char
7479 +       CPU_CFLAGS-$(CONFIG_H8S)    += -ms -mint32 -fsigned-char
7480 +endif
7482 +ifeq ($(strip $(TARGET_ARCH)),cris)
7483 +       CPU_LDFLAGS-$(CONFIG_CRIS)+=-mcrislinux
7484 +       CPU_CFLAGS-$(CONFIG_CRIS)+=-mlinux
7485 +       PICFLAG:=-fpic
7486 +       PIEFLAG_NAME:=-fpie
7487 +endif
7489 +ifeq ($(strip $(TARGET_ARCH)),powerpc)
7490 +# PowerPC can hold 8192 entries in its GOT with -fpic which is more than
7491 +# enough. Therefore use -fpic which will reduce code size and generates
7492 +# faster code.
7493 +       PICFLAG:=-fpic
7494 +       PIEFLAG_NAME:=-fpie
7495 +       PPC_HAS_REL16:=$(shell echo -e "\t.text\n\taddis 11,30,_GLOBAL_OFFSET_TABLE_-.@ha" | $(CC) -c -x assembler -o /dev/null -  2> /dev/null && echo -n y || echo -n n)
7496 +       CPU_CFLAGS-$(PPC_HAS_REL16)+= -DHAVE_ASM_PPC_REL16
7497 +endif
7499 +ifeq ($(strip $(TARGET_ARCH)),frv)
7500 +       CPU_LDFLAGS-$(CONFIG_FRV)+=-melf32frvfd
7501 +       CPU_CFLAGS-$(CONFIG_FRV)+=-mfdpic
7502 +       # Using -pie causes the program to have an interpreter, which is
7503 +       # forbidden, so we must make do with -shared.  Unfortunately,
7504 +       # -shared by itself would get us global function descriptors
7505 +       # and calls through PLTs, dynamic resolution of symbols, etc,
7506 +       # which would break as well, but -Bsymbolic comes to the rescue.
7507 +       export LDPIEFLAG:=-shared -Bsymbolic
7508 +       UCLIBC_LDSO=ld.so.1
7509 +endif
7511 +ifeq ($(strip $(TARGET_ARCH)),avr32)
7512 +       CPU_CFLAGS-$(CONFIG_AP7000)     += -mcpu=ap7000
7513 +endif
7515 +# Keep the check_gcc from being needlessly executed
7516 +ifndef PIEFLAG
7517 +ifneq ($(UCLIBC_BUILD_PIE),y)
7518 +export PIEFLAG:=
7519 +else
7520 +export PIEFLAG:=$(call check_gcc,$(PIEFLAG_NAME),$(PICFLAG))
7521 +endif
7522 +endif
7523 +# We need to keep track of both the CC PIE flag (above) as 
7524 +# well as the LD PIE flag (below) because we can't rely on 
7525 +# gcc passing -pie if we used -fPIE
7526 +ifndef LDPIEFLAG
7527 +ifneq ($(UCLIBC_BUILD_PIE),y)
7528 +export LDPIEFLAG:=
7529 +else
7530 +export LDPIEFLAG:=$(shell $(LD) --help | grep -q pie && echo "-Wl,-pie")
7531 +endif
7532 +endif
7534 +# Use '-Os' optimization if available, else use -O2, allow Config to override
7535 +OPTIMIZATION+=$(call check_gcc,-Os,-O2)
7536 +# Use the gcc 3.4 -funit-at-a-time optimization when available
7537 +OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
7539 +# Add a bunch of extra pedantic annoyingly strict checks
7540 +XWARNINGS=$(subst ",, $(strip $(WARNINGS))) -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
7541 +XARCH_CFLAGS=$(subst ",, $(strip $(ARCH_CFLAGS)))
7542 +CPU_CFLAGS=$(subst ",, $(strip $(CPU_CFLAGS-y)))
7544 +LDADD_LIBFLOAT=
7545 +ifeq ($(strip $(UCLIBC_HAS_SOFT_FLOAT)),y)
7546 +# Add -msoft-float to the CPU_FLAGS since ldso and libdl ignore CFLAGS.
7547 +# If -msoft-float isn't supported, we want an error anyway.
7548 +# Hmm... might need to revisit this for arm since it has 2 different
7549 +# soft float encodings.
7550 +    CPU_CFLAGS += -msoft-float
7551 +ifeq ($(strip $(TARGET_ARCH)),arm)
7552 +# No longer needed with current toolchains, but leave it here for now.
7553 +# If anyone is actually still using gcc 2.95 (say), they can uncomment it.
7554 +#    LDADD_LIBFLOAT=-lfloat
7555 +endif
7556 +endif
7558 +SSP_DISABLE_FLAGS:=$(call check_gcc,-fno-stack-protector,)
7559 +ifeq ($(UCLIBC_BUILD_SSP),y)
7560 +SSP_CFLAGS:=$(call check_gcc,-fno-stack-protector-all,)
7561 +SSP_CFLAGS+=$(call check_gcc,-fstack-protector,)
7562 +SSP_ALL_CFLAGS:=$(call check_gcc,-fstack-protector-all,)
7563 +else
7564 +SSP_CFLAGS:=$(SSP_DISABLE_FLAGS)
7565 +endif
7567 +# Some nice CFLAGS to work with
7568 +CFLAGS:=$(XWARNINGS) $(CPU_CFLAGS) $(SSP_CFLAGS) \
7569 +       -fno-builtin -nostdinc -D_LIBC -I$(TOPDIR)include -I.
7570 +LDFLAGS_NOSTRIP:=$(CPU_LDFLAGS-y) -shared --warn-common --warn-once -z combreloc -z defs
7572 +ifeq ($(DODEBUG),y)
7573 +    #CFLAGS += -g3
7574 +    CFLAGS += -O0 -g3
7575 +    LDFLAGS := $(LDFLAGS_NOSTRIP)
7576 +    STRIPTOOL:= true -Since_we_are_debugging
7577 +else
7578 +    CFLAGS += $(OPTIMIZATION) $(XARCH_CFLAGS)
7579 +    LDFLAGS := $(LDFLAGS_NOSTRIP) -s
7580 +endif
7582 +ifeq ($(UCLIBC_BUILD_RELRO),y)
7583 +LDFLAGS+=-z relro
7584 +endif
7586 +ifeq ($(UCLIBC_BUILD_NOW),y)
7587 +LDFLAGS+=-z now
7588 +endif
7590 +# Sigh, some stupid versions of gcc can't seem to cope with '-iwithprefix include'
7591 +#CFLAGS+=-iwithprefix include
7592 +CFLAGS+=-isystem $(shell $(CC) -print-file-name=include)
7594 +ifneq ($(DOASSERTS),y)
7595 +    CFLAGS += -DNDEBUG
7596 +endif
7598 +CFLAGS_NOPIC:=$(CFLAGS)
7599 +ifeq ($(DOPIC),y)
7600 +    CFLAGS += $(PICFLAG)
7601 +endif
7603 +ifeq ($(DL_FINI_CRT_COMPAT),y)
7604 +CFLAGS += -D_DL_FINI_CRT_COMPAT
7605 +endif
7607 +# Keep the check_as from being needlessly executed
7608 +ASFLAGS = $(CFLAGS)
7609 +ifndef ASFLAGS_NOEXEC
7610 +ifeq ($(UCLIBC_BUILD_NOEXECSTACK),y)
7611 +export ASFLAGS_NOEXEC := $(call check_as,--noexecstack)
7612 +else
7613 +export ASFLAGS_NOEXEC :=
7614 +endif
7615 +endif
7616 +ASFLAGS += $(ASFLAGS_NOEXEC)
7618 +LIBGCC_CFLAGS ?= $(CFLAGS) $(CPU_CFLAGS-y)
7619 +LIBGCC:=$(shell $(CC) $(LIBGCC_CFLAGS) -print-libgcc-file-name)
7620 +LIBGCC_DIR:=$(dir $(LIBGCC))
7622 +########################################
7624 +# uClinux shared lib support
7627 +ifeq ($(CONFIG_BINFMT_SHARED_FLAT),y)
7628 +  # For the shared version of this, we specify no stack and its library ID
7629 +  FLTFLAGS += -s 0
7630 +  LIBID=1
7631 +  export LIBID FLTFLAGS
7632 +  SHARED_TARGET = lib/libc
7633 +endif
7635 +TARGET_ARCH:=$(strip $(subst ",, $(strip $(TARGET_ARCH))))
7636 diff -Nrup a/utils/ldd.c b/utils/ldd.c
7637 --- a/utils/ldd.c       2004-10-06 03:34:17.000000000 -0400
7638 +++ b/utils/ldd.c       2008-02-28 19:02:10.000000000 -0500
7639 @@ -56,6 +56,11 @@
7640  #define ELFCLASSM      ELFCLASS32
7641  #endif
7643 +#if defined(__avr32__)
7644 +#define MATCH_MACHINE(x) (x == EM_AVR32)
7645 +#define ELFCLASSM      ELFCLASS32
7646 +#endif
7648  #if defined(__s390__)
7649  #define MATCH_MACHINE(x) (x == EM_S390)
7650  #define ELFCLASSM      ELFCLASS32