History

Use _WIN32 for a windows hosted tcc and define it for the PE target.

grischka committed 18 years ago

Commit 34140dd1 parent b0d40c14 files · +1534 −1530Browse files

Unified · Split

4 files
  1. alloca86-bt.S +2 −2
  2. elf.h +957 −957
  3. tcc.c +52 −48
  4. tccpe.c +523 −523
alloca86-bt.S+2−2
@@ -1,9 +1,9 @@
1/* ---------------------------------------------- */1/* ---------------------------------------------- */
2/* alloca86b.S */2/* alloca86b.S */
3 3
4.globl __bound___alloca4.globl __bound__alloca
5 5
6__bound___alloca:6__bound__alloca:
7 pop %edx7 pop %edx
8 pop %eax8 pop %eax
9 mov %eax, %ecx9 mov %eax, %ecx
elf.h+957−957
@@ -19,23 +19,23 @@ · 18 unmodified lines
19 Boston, MA 02111-1307, USA. */19 Boston, MA 02111-1307, USA. */
20 20
21#ifndef _ELF_H21#ifndef _ELF_H
22#define _ELF_H 122#define _ELF_H 1
23 23
24#ifndef WIN3224#ifndef _WIN32
25#include <inttypes.h>25#include <inttypes.h>
26#else26#else
27#ifndef __int8_t_defined27#ifndef __int8_t_defined
28#define __int8_t_defined28#define __int8_t_defined
29typedef signed char int8_t;29typedef signed char int8_t;
30typedef short int int16_t;30typedef short int int16_t;
31typedef int int32_t;31typedef int int32_t;
32typedef long long int int64_t;32typedef long long int int64_t;
33#endif33#endif
34 34
35typedef unsigned char uint8_t;35typedef unsigned char uint8_t;
36typedef unsigned short int uint16_t;36typedef unsigned short int uint16_t;
37typedef unsigned int uint32_t;37typedef unsigned int uint32_t;
38typedef unsigned long long int uint64_t;38typedef unsigned long long int uint64_t;
39#endif39#endif
40 40
41/* Standard ELF types. */41/* Standard ELF types. */
@@ -46,15 +46,15 @@ typedef uint16_t Elf64_Half; · 4 unmodified lines
46 46
47/* Types for signed and unsigned 32-bit quantities. */47/* Types for signed and unsigned 32-bit quantities. */
48typedef uint32_t Elf32_Word;48typedef uint32_t Elf32_Word;
49typedef int32_t Elf32_Sword;49typedef int32_t Elf32_Sword;
50typedef uint32_t Elf64_Word;50typedef uint32_t Elf64_Word;
51typedef int32_t Elf64_Sword;51typedef int32_t Elf64_Sword;
52 52
53/* Types for signed and unsigned 64-bit quantities. */53/* Types for signed and unsigned 64-bit quantities. */
54typedef uint64_t Elf32_Xword;54typedef uint64_t Elf32_Xword;
55typedef int64_t Elf32_Sxword;55typedef int64_t Elf32_Sxword;
56typedef uint64_t Elf64_Xword;56typedef uint64_t Elf64_Xword;
57typedef int64_t Elf64_Sxword;57typedef int64_t Elf64_Sxword;
58 58
59/* Type of addresses. */59/* Type of addresses. */
60typedef uint32_t Elf32_Addr;60typedef uint32_t Elf32_Addr;
@@ -79,251 +79,251 @@ typedef uint64_t Elf64_Symndx; · 18 unmodified lines
79 79
80typedef struct80typedef struct
81{81{
82 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */82 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
83 Elf32_Half e_type; /* Object file type */83 Elf32_Half e_type; /* Object file type */
84 Elf32_Half e_machine; /* Architecture */84 Elf32_Half e_machine; /* Architecture */
85 Elf32_Word e_version; /* Object file version */85 Elf32_Word e_version; /* Object file version */
86 Elf32_Addr e_entry; /* Entry point virtual address */86 Elf32_Addr e_entry; /* Entry point virtual address */
87 Elf32_Off e_phoff; /* Program header table file offset */87 Elf32_Off e_phoff; /* Program header table file offset */
88 Elf32_Off e_shoff; /* Section header table file offset */88 Elf32_Off e_shoff; /* Section header table file offset */
89 Elf32_Word e_flags; /* Processor-specific flags */89 Elf32_Word e_flags; /* Processor-specific flags */
90 Elf32_Half e_ehsize; /* ELF header size in bytes */90 Elf32_Half e_ehsize; /* ELF header size in bytes */
91 Elf32_Half e_phentsize; /* Program header table entry size */91 Elf32_Half e_phentsize; /* Program header table entry size */
92 Elf32_Half e_phnum; /* Program header table entry count */92 Elf32_Half e_phnum; /* Program header table entry count */
93 Elf32_Half e_shentsize; /* Section header table entry size */93 Elf32_Half e_shentsize; /* Section header table entry size */
94 Elf32_Half e_shnum; /* Section header table entry count */94 Elf32_Half e_shnum; /* Section header table entry count */
95 Elf32_Half e_shstrndx; /* Section header string table index */95 Elf32_Half e_shstrndx; /* Section header string table index */
96} Elf32_Ehdr;96} Elf32_Ehdr;
97 97
98typedef struct98typedef struct
99{99{
100 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */100 unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
101 Elf64_Half e_type; /* Object file type */101 Elf64_Half e_type; /* Object file type */
102 Elf64_Half e_machine; /* Architecture */102 Elf64_Half e_machine; /* Architecture */
103 Elf64_Word e_version; /* Object file version */103 Elf64_Word e_version; /* Object file version */
104 Elf64_Addr e_entry; /* Entry point virtual address */104 Elf64_Addr e_entry; /* Entry point virtual address */
105 Elf64_Off e_phoff; /* Program header table file offset */105 Elf64_Off e_phoff; /* Program header table file offset */
106 Elf64_Off e_shoff; /* Section header table file offset */106 Elf64_Off e_shoff; /* Section header table file offset */
107 Elf64_Word e_flags; /* Processor-specific flags */107 Elf64_Word e_flags; /* Processor-specific flags */
108 Elf64_Half e_ehsize; /* ELF header size in bytes */108 Elf64_Half e_ehsize; /* ELF header size in bytes */
109 Elf64_Half e_phentsize; /* Program header table entry size */109 Elf64_Half e_phentsize; /* Program header table entry size */
110 Elf64_Half e_phnum; /* Program header table entry count */110 Elf64_Half e_phnum; /* Program header table entry count */
111 Elf64_Half e_shentsize; /* Section header table entry size */111 Elf64_Half e_shentsize; /* Section header table entry size */
112 Elf64_Half e_shnum; /* Section header table entry count */112 Elf64_Half e_shnum; /* Section header table entry count */
113 Elf64_Half e_shstrndx; /* Section header string table index */113 Elf64_Half e_shstrndx; /* Section header string table index */
114} Elf64_Ehdr;114} Elf64_Ehdr;
115 115
116/* Fields in the e_ident array. The EI_* macros are indices into the116/* Fields in the e_ident array. The EI_* macros are indices into the
117 array. The macros under each EI_* macro are the values the byte117 array. The macros under each EI_* macro are the values the byte
118 may have. */118 may have. */
119 119
120#define EI_MAG0 0 /* File identification byte 0 index */120#define EI_MAG0 0 /* File identification byte 0 index */
121#define ELFMAG0 0x7f /* Magic number byte 0 */121#define ELFMAG0 0x7f /* Magic number byte 0 */
122 122
123#define EI_MAG1 1 /* File identification byte 1 index */123#define EI_MAG1 1 /* File identification byte 1 index */
124#define ELFMAG1 'E' /* Magic number byte 1 */124#define ELFMAG1 'E' /* Magic number byte 1 */
125 125
126#define EI_MAG2 2 /* File identification byte 2 index */126#define EI_MAG2 2 /* File identification byte 2 index */
127#define ELFMAG2 'L' /* Magic number byte 2 */127#define ELFMAG2 'L' /* Magic number byte 2 */
128 128
129#define EI_MAG3 3 /* File identification byte 3 index */129#define EI_MAG3 3 /* File identification byte 3 index */
130#define ELFMAG3 'F' /* Magic number byte 3 */130#define ELFMAG3 'F' /* Magic number byte 3 */
131 131
132/* Conglomeration of the identification bytes, for easy testing as a word. */132/* Conglomeration of the identification bytes, for easy testing as a word. */
133#define ELFMAG "\177ELF"133#define ELFMAG "\177ELF"
134#define SELFMAG 4134#define SELFMAG 4
135 135
136#define EI_CLASS 4 /* File class byte index */136#define EI_CLASS 4 /* File class byte index */
137#define ELFCLASSNONE 0 /* Invalid class */137#define ELFCLASSNONE 0 /* Invalid class */
138#define ELFCLASS32 1 /* 32-bit objects */138#define ELFCLASS32 1 /* 32-bit objects */
139#define ELFCLASS64 2 /* 64-bit objects */139#define ELFCLASS64 2 /* 64-bit objects */
140#define ELFCLASSNUM 3140#define ELFCLASSNUM 3
141 141
142#define EI_DATA 5 /* Data encoding byte index */142#define EI_DATA 5 /* Data encoding byte index */
143#define ELFDATANONE 0 /* Invalid data encoding */143#define ELFDATANONE 0 /* Invalid data encoding */
144#define ELFDATA2LSB 1 /* 2's complement, little endian */144#define ELFDATA2LSB 1 /* 2's complement, little endian */
145#define ELFDATA2MSB 2 /* 2's complement, big endian */145#define ELFDATA2MSB 2 /* 2's complement, big endian */
146#define ELFDATANUM 3146#define ELFDATANUM 3
147 147
148#define EI_VERSION 6 /* File version byte index */148#define EI_VERSION 6 /* File version byte index */
149 /* Value must be EV_CURRENT */149 /* Value must be EV_CURRENT */
150 150
151#define EI_OSABI 7 /* OS ABI identification */151#define EI_OSABI 7 /* OS ABI identification */
152#define ELFOSABI_SYSV 0 /* UNIX System V ABI */152#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
153#define ELFOSABI_HPUX 1 /* HP-UX */153#define ELFOSABI_HPUX 1 /* HP-UX */
154#define ELFOSABI_FREEBSD 9 /* Free BSD */154#define ELFOSABI_FREEBSD 9 /* Free BSD */
155#define ELFOSABI_ARM 97 /* ARM */155#define ELFOSABI_ARM 97 /* ARM */
156#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */156#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
157 157
158#define EI_ABIVERSION 8 /* ABI version */158#define EI_ABIVERSION 8 /* ABI version */
159 159
160#define EI_PAD 9 /* Byte index of padding bytes */160#define EI_PAD 9 /* Byte index of padding bytes */
161 161
162/* Legal values for e_type (object file type). */162/* Legal values for e_type (object file type). */
163 163
164#define ET_NONE 0 /* No file type */164#define ET_NONE 0 /* No file type */
165#define ET_REL 1 /* Relocatable file */165#define ET_REL 1 /* Relocatable file */
166#define ET_EXEC 2 /* Executable file */166#define ET_EXEC 2 /* Executable file */
167#define ET_DYN 3 /* Shared object file */167#define ET_DYN 3 /* Shared object file */
168#define ET_CORE 4 /* Core file */168#define ET_CORE 4 /* Core file */
169#define ET_NUM 5 /* Number of defined types */169#define ET_NUM 5 /* Number of defined types */
170#define ET_LOPROC 0xff00 /* Processor-specific */170#define ET_LOPROC 0xff00 /* Processor-specific */
171#define ET_HIPROC 0xffff /* Processor-specific */171#define ET_HIPROC 0xffff /* Processor-specific */
172 172
173/* Legal values for e_machine (architecture). */173/* Legal values for e_machine (architecture). */
174 174
175#define EM_NONE 0 /* No machine */175#define EM_NONE 0 /* No machine */
176#define EM_M32 1 /* AT&T WE 32100 */176#define EM_M32 1 /* AT&T WE 32100 */
177#define EM_SPARC 2 /* SUN SPARC */177#define EM_SPARC 2 /* SUN SPARC */
178#define EM_386 3 /* Intel 80386 */178#define EM_386 3 /* Intel 80386 */
179#define EM_68K 4 /* Motorola m68k family */179#define EM_68K 4 /* Motorola m68k family */
180#define EM_88K 5 /* Motorola m88k family */180#define EM_88K 5 /* Motorola m88k family */
181#define EM_486 6 /* Intel 80486 */181#define EM_486 6 /* Intel 80486 */
182#define EM_860 7 /* Intel 80860 */182#define EM_860 7 /* Intel 80860 */
183#define EM_MIPS 8 /* MIPS R3000 big-endian */183#define EM_MIPS 8 /* MIPS R3000 big-endian */
184#define EM_S370 9 /* Amdahl */184#define EM_S370 9 /* Amdahl */
185#define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */185#define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */
186#define EM_RS6000 11 /* RS6000 */186#define EM_RS6000 11 /* RS6000 */
187 187
188#define EM_PARISC 15 /* HPPA */188#define EM_PARISC 15 /* HPPA */
189#define EM_nCUBE 16 /* nCUBE */189#define EM_nCUBE 16 /* nCUBE */
190#define EM_VPP500 17 /* Fujitsu VPP500 */190#define EM_VPP500 17 /* Fujitsu VPP500 */
191#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */191#define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
192#define EM_960 19 /* Intel 80960 */192#define EM_960 19 /* Intel 80960 */
193#define EM_PPC 20 /* PowerPC */193#define EM_PPC 20 /* PowerPC */
194 194
195#define EM_V800 36 /* NEC V800 series */195#define EM_V800 36 /* NEC V800 series */
196#define EM_FR20 37 /* Fujitsu FR20 */196#define EM_FR20 37 /* Fujitsu FR20 */
197#define EM_RH32 38 /* TRW RH32 */197#define EM_RH32 38 /* TRW RH32 */
198#define EM_MMA 39 /* Fujitsu MMA */198#define EM_MMA 39 /* Fujitsu MMA */
199#define EM_ARM 40 /* ARM */199#define EM_ARM 40 /* ARM */
200#define EM_FAKE_ALPHA 41 /* Digital Alpha */200#define EM_FAKE_ALPHA 41 /* Digital Alpha */
201#define EM_SH 42 /* Hitachi SH */201#define EM_SH 42 /* Hitachi SH */
202#define EM_SPARCV9 43 /* SPARC v9 64-bit */202#define EM_SPARCV9 43 /* SPARC v9 64-bit */
203#define EM_TRICORE 44 /* Siemens Tricore */203#define EM_TRICORE 44 /* Siemens Tricore */
204#define EM_ARC 45 /* Argonaut RISC Core */204#define EM_ARC 45 /* Argonaut RISC Core */
205#define EM_H8_300 46 /* Hitachi H8/300 */205#define EM_H8_300 46 /* Hitachi H8/300 */
206#define EM_H8_300H 47 /* Hitachi H8/300H */206#define EM_H8_300H 47 /* Hitachi H8/300H */
207#define EM_H8S 48 /* Hitachi H8S */207#define EM_H8S 48 /* Hitachi H8S */
208#define EM_H8_500 49 /* Hitachi H8/500 */208#define EM_H8_500 49 /* Hitachi H8/500 */
209#define EM_IA_64 50 /* Intel Merced */209#define EM_IA_64 50 /* Intel Merced */
210#define EM_MIPS_X 51 /* Stanford MIPS-X */210#define EM_MIPS_X 51 /* Stanford MIPS-X */
211#define EM_COLDFIRE 52 /* Motorola Coldfire */211#define EM_COLDFIRE 52 /* Motorola Coldfire */
212#define EM_68HC12 53 /* Motorola M68HC12 */212#define EM_68HC12 53 /* Motorola M68HC12 */
213#define EM_NUM 54213#define EM_NUM 54
214 214
215/* If it is necessary to assign new unofficial EM_* values, please215/* If it is necessary to assign new unofficial EM_* values, please
216 pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the216 pick large random numbers (0x8523, 0xa7f2, etc.) to minimize the
217 chances of collision with official or non-GNU unofficial values. */217 chances of collision with official or non-GNU unofficial values. */
218 218
219#define EM_ALPHA 0x9026219#define EM_ALPHA 0x9026
220#define EM_C60 0x9c60220#define EM_C60 0x9c60
221 221
222/* Legal values for e_version (version). */222/* Legal values for e_version (version). */
223 223
224#define EV_NONE 0 /* Invalid ELF version */224#define EV_NONE 0 /* Invalid ELF version */
225#define EV_CURRENT 1 /* Current version */225#define EV_CURRENT 1 /* Current version */
226#define EV_NUM 2226#define EV_NUM 2
227 227
228/* Section header. */228/* Section header. */
229 229
230typedef struct230typedef struct
231{231{
232 Elf32_Word sh_name; /* Section name (string tbl index) */232 Elf32_Word sh_name; /* Section name (string tbl index) */
233 Elf32_Word sh_type; /* Section type */233 Elf32_Word sh_type; /* Section type */
234 Elf32_Word sh_flags; /* Section flags */234 Elf32_Word sh_flags; /* Section flags */
235 Elf32_Addr sh_addr; /* Section virtual addr at execution */235 Elf32_Addr sh_addr; /* Section virtual addr at execution */
236 Elf32_Off sh_offset; /* Section file offset */236 Elf32_Off sh_offset; /* Section file offset */
237 Elf32_Word sh_size; /* Section size in bytes */237 Elf32_Word sh_size; /* Section size in bytes */
238 Elf32_Word sh_link; /* Link to another section */238 Elf32_Word sh_link; /* Link to another section */
239 Elf32_Word sh_info; /* Additional section information */239 Elf32_Word sh_info; /* Additional section information */
240 Elf32_Word sh_addralign; /* Section alignment */240 Elf32_Word sh_addralign; /* Section alignment */
241 Elf32_Word sh_entsize; /* Entry size if section holds table */241 Elf32_Word sh_entsize; /* Entry size if section holds table */
242} Elf32_Shdr;242} Elf32_Shdr;
243 243
244typedef struct244typedef struct
245{245{
246 Elf64_Word sh_name; /* Section name (string tbl index) */246 Elf64_Word sh_name; /* Section name (string tbl index) */
247 Elf64_Word sh_type; /* Section type */247 Elf64_Word sh_type; /* Section type */
248 Elf64_Xword sh_flags; /* Section flags */248 Elf64_Xword sh_flags; /* Section flags */
249 Elf64_Addr sh_addr; /* Section virtual addr at execution */249 Elf64_Addr sh_addr; /* Section virtual addr at execution */
250 Elf64_Off sh_offset; /* Section file offset */250 Elf64_Off sh_offset; /* Section file offset */
251 Elf64_Xword sh_size; /* Section size in bytes */251 Elf64_Xword sh_size; /* Section size in bytes */
252 Elf64_Word sh_link; /* Link to another section */252 Elf64_Word sh_link; /* Link to another section */
253 Elf64_Word sh_info; /* Additional section information */253 Elf64_Word sh_info; /* Additional section information */
254 Elf64_Xword sh_addralign; /* Section alignment */254 Elf64_Xword sh_addralign; /* Section alignment */
255 Elf64_Xword sh_entsize; /* Entry size if section holds table */255 Elf64_Xword sh_entsize; /* Entry size if section holds table */
256} Elf64_Shdr;256} Elf64_Shdr;
257 257
258/* Special section indices. */258/* Special section indices. */
259 259
260#define SHN_UNDEF 0 /* Undefined section */260#define SHN_UNDEF 0 /* Undefined section */
261#define SHN_LORESERVE 0xff00 /* Start of reserved indices */261#define SHN_LORESERVE 0xff00 /* Start of reserved indices */
262#define SHN_LOPROC 0xff00 /* Start of processor-specific */262#define SHN_LOPROC 0xff00 /* Start of processor-specific */
263#define SHN_HIPROC 0xff1f /* End of processor-specific */263#define SHN_HIPROC 0xff1f /* End of processor-specific */
264#define SHN_ABS 0xfff1 /* Associated symbol is absolute */264#define SHN_ABS 0xfff1 /* Associated symbol is absolute */
265#define SHN_COMMON 0xfff2 /* Associated symbol is common */265#define SHN_COMMON 0xfff2 /* Associated symbol is common */
266#define SHN_HIRESERVE 0xffff /* End of reserved indices */266#define SHN_HIRESERVE 0xffff /* End of reserved indices */
267 267
268/* Legal values for sh_type (section type). */268/* Legal values for sh_type (section type). */
269 269
270#define SHT_NULL 0 /* Section header table entry unused */270#define SHT_NULL 0 /* Section header table entry unused */
271#define SHT_PROGBITS 1 /* Program data */271#define SHT_PROGBITS 1 /* Program data */
272#define SHT_SYMTAB 2 /* Symbol table */272#define SHT_SYMTAB 2 /* Symbol table */
273#define SHT_STRTAB 3 /* String table */273#define SHT_STRTAB 3 /* String table */
274#define SHT_RELA 4 /* Relocation entries with addends */274#define SHT_RELA 4 /* Relocation entries with addends */
275#define SHT_HASH 5 /* Symbol hash table */275#define SHT_HASH 5 /* Symbol hash table */
276#define SHT_DYNAMIC 6 /* Dynamic linking information */276#define SHT_DYNAMIC 6 /* Dynamic linking information */
277#define SHT_NOTE 7 /* Notes */277#define SHT_NOTE 7 /* Notes */
278#define SHT_NOBITS 8 /* Program space with no data (bss) */278#define SHT_NOBITS 8 /* Program space with no data (bss) */
279#define SHT_REL 9 /* Relocation entries, no addends */279#define SHT_REL 9 /* Relocation entries, no addends */
280#define SHT_SHLIB 10 /* Reserved */280#define SHT_SHLIB 10 /* Reserved */
281#define SHT_DYNSYM 11 /* Dynamic linker symbol table */281#define SHT_DYNSYM 11 /* Dynamic linker symbol table */
282#define SHT_NUM 12 /* Number of defined types. */282#define SHT_NUM 12 /* Number of defined types. */
283#define SHT_LOOS 0x60000000 /* Start OS-specific */283#define SHT_LOOS 0x60000000 /* Start OS-specific */
284#define SHT_LOSUNW 0x6ffffffb /* Sun-specific low bound. */284#define SHT_LOSUNW 0x6ffffffb /* Sun-specific low bound. */
285#define SHT_SUNW_COMDAT 0x6ffffffb285#define SHT_SUNW_COMDAT 0x6ffffffb
286#define SHT_SUNW_syminfo 0x6ffffffc286#define SHT_SUNW_syminfo 0x6ffffffc
287#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */287#define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */
288#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */288#define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */
289#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */289#define SHT_GNU_versym 0x6fffffff /* Version symbol table. */
290#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */290#define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */
291#define SHT_HIOS 0x6fffffff /* End OS-specific type */291#define SHT_HIOS 0x6fffffff /* End OS-specific type */
292#define SHT_LOPROC 0x70000000 /* Start of processor-specific */292#define SHT_LOPROC 0x70000000 /* Start of processor-specific */
293#define SHT_ARM_EXIDX 0x70000001 /* Exception Index table */293#define SHT_ARM_EXIDX 0x70000001 /* Exception Index table */
294#define SHT_ARM_PREEMPTMAP 0x70000002 /* dynamic linking pre-emption map */294#define SHT_ARM_PREEMPTMAP 0x70000002 /* dynamic linking pre-emption map */
295#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility attrs */295#define SHT_ARM_ATTRIBUTES 0x70000003 /* Object file compatibility attrs */
296#define SHT_HIPROC 0x7fffffff /* End of processor-specific */296#define SHT_HIPROC 0x7fffffff /* End of processor-specific */
297#define SHT_LOUSER 0x80000000 /* Start of application-specific */297#define SHT_LOUSER 0x80000000 /* Start of application-specific */
298#define SHT_HIUSER 0x8fffffff /* End of application-specific */298#define SHT_HIUSER 0x8fffffff /* End of application-specific */
299 299
300/* Legal values for sh_flags (section flags). */300/* Legal values for sh_flags (section flags). */
301 301
302#define SHF_WRITE (1 << 0) /* Writable */302#define SHF_WRITE (1 << 0) /* Writable */
303#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */303#define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
304#define SHF_EXECINSTR (1 << 2) /* Executable */304#define SHF_EXECINSTR (1 << 2) /* Executable */
305#define SHF_MASKPROC 0xf0000000 /* Processor-specific */305#define SHF_MASKPROC 0xf0000000 /* Processor-specific */
306 306
307/* Symbol table entry. */307/* Symbol table entry. */
308 308
309typedef struct309typedef struct
310{310{
311 Elf32_Word st_name; /* Symbol name (string tbl index) */311 Elf32_Word st_name; /* Symbol name (string tbl index) */
312 Elf32_Addr st_value; /* Symbol value */312 Elf32_Addr st_value; /* Symbol value */
313 Elf32_Word st_size; /* Symbol size */313 Elf32_Word st_size; /* Symbol size */
314 unsigned char st_info; /* Symbol type and binding */314 unsigned char st_info; /* Symbol type and binding */
315 unsigned char st_other; /* No defined meaning, 0 */315 unsigned char st_other; /* No defined meaning, 0 */
316 Elf32_Section st_shndx; /* Section index */316 Elf32_Section st_shndx; /* Section index */
317} Elf32_Sym;317} Elf32_Sym;
318 318
319typedef struct319typedef struct
320{320{
321 Elf64_Word st_name; /* Symbol name (string tbl index) */321 Elf64_Word st_name; /* Symbol name (string tbl index) */
322 unsigned char st_info; /* Symbol type and binding */322 unsigned char st_info; /* Symbol type and binding */
323 unsigned char st_other; /* No defined meaning, 0 */323 unsigned char st_other; /* No defined meaning, 0 */
324 Elf64_Section st_shndx; /* Section index */324 Elf64_Section st_shndx; /* Section index */
325 Elf64_Addr st_value; /* Symbol value */325 Elf64_Addr st_value; /* Symbol value */
326 Elf64_Xword st_size; /* Symbol size */326 Elf64_Xword st_size; /* Symbol size */
327} Elf64_Sym;327} Elf64_Sym;
328 328
329/* The syminfo section if available contains additional information about329/* The syminfo section if available contains additional information about
@@ -331,100 +331,100 @@ typedef struct · 1 unmodified line
331 331
332typedef struct332typedef struct
333{333{
334 Elf32_Half si_boundto; /* Direct bindings, symbol bound to */334 Elf32_Half si_boundto; /* Direct bindings, symbol bound to */
335 Elf32_Half si_flags; /* Per symbol flags */335 Elf32_Half si_flags; /* Per symbol flags */
336} Elf32_Syminfo;336} Elf32_Syminfo;
337 337
338typedef struct338typedef struct
339{339{
340 Elf64_Half si_boundto; /* Direct bindings, symbol bound to */340 Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
341 Elf64_Half si_flags; /* Per symbol flags */341 Elf64_Half si_flags; /* Per symbol flags */
342} Elf64_Syminfo;342} Elf64_Syminfo;
343 343
344/* Possible values for si_boundto. */344/* Possible values for si_boundto. */
345#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */345#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
346#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */346#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */
347#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */347#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries */
348 348
349/* Possible bitmasks for si_flags. */349/* Possible bitmasks for si_flags. */
350#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */350#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */
351#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */351#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */
352#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */352#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */
353#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy353#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy
354 loaded */354 loaded */
355/* Syminfo version values. */355/* Syminfo version values. */
356#define SYMINFO_NONE 0356#define SYMINFO_NONE 0
357#define SYMINFO_CURRENT 1357#define SYMINFO_CURRENT 1
358#define SYMINFO_NUM 2358#define SYMINFO_NUM 2
359 359
360 360
361/* Special section index. */361/* Special section index. */
362 362
363#define SHN_UNDEF 0 /* No section, undefined symbol. */363#define SHN_UNDEF 0 /* No section, undefined symbol. */
364 364
365/* How to extract and insert information held in the st_info field. */365/* How to extract and insert information held in the st_info field. */
366 366
367#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)367#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
368#define ELF32_ST_TYPE(val) ((val) & 0xf)368#define ELF32_ST_TYPE(val) ((val) & 0xf)
369#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))369#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
370 370
371/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */371/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
372#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)372#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
373#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)373#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
374#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))374#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
375 375
376/* Legal values for ST_BIND subfield of st_info (symbol binding). */376/* Legal values for ST_BIND subfield of st_info (symbol binding). */
377 377
378#define STB_LOCAL 0 /* Local symbol */378#define STB_LOCAL 0 /* Local symbol */
379#define STB_GLOBAL 1 /* Global symbol */379#define STB_GLOBAL 1 /* Global symbol */
380#define STB_WEAK 2 /* Weak symbol */380#define STB_WEAK 2 /* Weak symbol */
381#define STB_NUM 3 /* Number of defined types. */381#define STB_NUM 3 /* Number of defined types. */
382#define STB_LOOS 10 /* Start of OS-specific */382#define STB_LOOS 10 /* Start of OS-specific */
383#define STB_HIOS 12 /* End of OS-specific */383#define STB_HIOS 12 /* End of OS-specific */
384#define STB_LOPROC 13 /* Start of processor-specific */384#define STB_LOPROC 13 /* Start of processor-specific */
385#define STB_HIPROC 15 /* End of processor-specific */385#define STB_HIPROC 15 /* End of processor-specific */
386 386
387/* Legal values for ST_TYPE subfield of st_info (symbol type). */387/* Legal values for ST_TYPE subfield of st_info (symbol type). */
388 388
389#define STT_NOTYPE 0 /* Symbol type is unspecified */389#define STT_NOTYPE 0 /* Symbol type is unspecified */
390#define STT_OBJECT 1 /* Symbol is a data object */390#define STT_OBJECT 1 /* Symbol is a data object */
391#define STT_FUNC 2 /* Symbol is a code object */391#define STT_FUNC 2 /* Symbol is a code object */
392#define STT_SECTION 3 /* Symbol associated with a section */392#define STT_SECTION 3 /* Symbol associated with a section */
393#define STT_FILE 4 /* Symbol's name is file name */393#define STT_FILE 4 /* Symbol's name is file name */
394#define STT_NUM 5 /* Number of defined types. */394#define STT_NUM 5 /* Number of defined types. */
395#define STT_LOOS 11 /* Start of OS-specific */395#define STT_LOOS 11 /* Start of OS-specific */
396#define STT_HIOS 12 /* End of OS-specific */396#define STT_HIOS 12 /* End of OS-specific */
397#define STT_LOPROC 13 /* Start of processor-specific */397#define STT_LOPROC 13 /* Start of processor-specific */
398#define STT_HIPROC 15 /* End of processor-specific */398#define STT_HIPROC 15 /* End of processor-specific */
399 399
400 400
401/* Symbol table indices are found in the hash buckets and chain table401/* Symbol table indices are found in the hash buckets and chain table
402 of a symbol hash table section. This special index value indicates402 of a symbol hash table section. This special index value indicates
403 the end of a chain, meaning no further symbols are found in that bucket. */403 the end of a chain, meaning no further symbols are found in that bucket. */
404 404
405#define STN_UNDEF 0 /* End of a chain. */405#define STN_UNDEF 0 /* End of a chain. */
406 406
407 407
408/* How to extract and insert information held in the st_other field. */408/* How to extract and insert information held in the st_other field. */
409 409
410#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)410#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)
411 411
412/* For ELF64 the definitions are the same. */412/* For ELF64 the definitions are the same. */
413#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)413#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)
414 414
415/* Symbol visibility specification encoded in the st_other field. */415/* Symbol visibility specification encoded in the st_other field. */
416#define STV_DEFAULT 0 /* Default symbol visibility rules */416#define STV_DEFAULT 0 /* Default symbol visibility rules */
417#define STV_INTERNAL 1 /* Processor specific hidden class */417#define STV_INTERNAL 1 /* Processor specific hidden class */
418#define STV_HIDDEN 2 /* Sym unavailable in other modules */418#define STV_HIDDEN 2 /* Sym unavailable in other modules */
419#define STV_PROTECTED 3 /* Not preemptible, not exported */419#define STV_PROTECTED 3 /* Not preemptible, not exported */
420 420
421 421
422/* Relocation table entry without addend (in section of type SHT_REL). */422/* Relocation table entry without addend (in section of type SHT_REL). */
423 423
424typedef struct424typedef struct
425{425{
426 Elf32_Addr r_offset; /* Address */426 Elf32_Addr r_offset; /* Address */
427 Elf32_Word r_info; /* Relocation type and symbol index */427 Elf32_Word r_info; /* Relocation type and symbol index */
428} Elf32_Rel;428} Elf32_Rel;
429 429
430/* I have seen two different definitions of the Elf64_Rel and430/* I have seen two different definitions of the Elf64_Rel and
@@ -434,266 +434,266 @@ typedef struct · 3 unmodified lines
434 434
435typedef struct435typedef struct
436{436{
437 Elf64_Addr r_offset; /* Address */437 Elf64_Addr r_offset; /* Address */
438 Elf64_Xword r_info; /* Relocation type and symbol index */438 Elf64_Xword r_info; /* Relocation type and symbol index */
439} Elf64_Rel;439} Elf64_Rel;
440 440
441/* Relocation table entry with addend (in section of type SHT_RELA). */441/* Relocation table entry with addend (in section of type SHT_RELA). */
442 442
443typedef struct443typedef struct
444{444{
445 Elf32_Addr r_offset; /* Address */445 Elf32_Addr r_offset; /* Address */
446 Elf32_Word r_info; /* Relocation type and symbol index */446 Elf32_Word r_info; /* Relocation type and symbol index */
447 Elf32_Sword r_addend; /* Addend */447 Elf32_Sword r_addend; /* Addend */
448} Elf32_Rela;448} Elf32_Rela;
449 449
450typedef struct450typedef struct
451{451{
452 Elf64_Addr r_offset; /* Address */452 Elf64_Addr r_offset; /* Address */
453 Elf64_Xword r_info; /* Relocation type and symbol index */453 Elf64_Xword r_info; /* Relocation type and symbol index */
454 Elf64_Sxword r_addend; /* Addend */454 Elf64_Sxword r_addend; /* Addend */
455} Elf64_Rela;455} Elf64_Rela;
456 456
457/* How to extract and insert information held in the r_info field. */457/* How to extract and insert information held in the r_info field. */
458 458
459#define ELF32_R_SYM(val) ((val) >> 8)459#define ELF32_R_SYM(val) ((val) >> 8)
460#define ELF32_R_TYPE(val) ((val) & 0xff)460#define ELF32_R_TYPE(val) ((val) & 0xff)
461#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))461#define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
462 462
463#define ELF64_R_SYM(i) ((i) >> 32)463#define ELF64_R_SYM(i) ((i) >> 32)
464#define ELF64_R_TYPE(i) ((i) & 0xffffffff)464#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
465#define ELF64_R_INFO(sym,type) (((sym) << 32) + (type))465#define ELF64_R_INFO(sym,type) (((sym) << 32) + (type))
466 466
467/* Program segment header. */467/* Program segment header. */
468 468
469typedef struct469typedef struct
470{470{
471 Elf32_Word p_type; /* Segment type */471 Elf32_Word p_type; /* Segment type */
472 Elf32_Off p_offset; /* Segment file offset */472 Elf32_Off p_offset; /* Segment file offset */
473 Elf32_Addr p_vaddr; /* Segment virtual address */473 Elf32_Addr p_vaddr; /* Segment virtual address */
474 Elf32_Addr p_paddr; /* Segment physical address */474 Elf32_Addr p_paddr; /* Segment physical address */
475 Elf32_Word p_filesz; /* Segment size in file */475 Elf32_Word p_filesz; /* Segment size in file */
476 Elf32_Word p_memsz; /* Segment size in memory */476 Elf32_Word p_memsz; /* Segment size in memory */
477 Elf32_Word p_flags; /* Segment flags */477 Elf32_Word p_flags; /* Segment flags */
478 Elf32_Word p_align; /* Segment alignment */478 Elf32_Word p_align; /* Segment alignment */
479} Elf32_Phdr;479} Elf32_Phdr;
480 480
481typedef struct481typedef struct
482{482{
483 Elf64_Word p_type; /* Segment type */483 Elf64_Word p_type; /* Segment type */
484 Elf64_Word p_flags; /* Segment flags */484 Elf64_Word p_flags; /* Segment flags */
485 Elf64_Off p_offset; /* Segment file offset */485 Elf64_Off p_offset; /* Segment file offset */
486 Elf64_Addr p_vaddr; /* Segment virtual address */486 Elf64_Addr p_vaddr; /* Segment virtual address */
487 Elf64_Addr p_paddr; /* Segment physical address */487 Elf64_Addr p_paddr; /* Segment physical address */
488 Elf64_Xword p_filesz; /* Segment size in file */488 Elf64_Xword p_filesz; /* Segment size in file */
489 Elf64_Xword p_memsz; /* Segment size in memory */489 Elf64_Xword p_memsz; /* Segment size in memory */
490 Elf64_Xword p_align; /* Segment alignment */490 Elf64_Xword p_align; /* Segment alignment */
491} Elf64_Phdr;491} Elf64_Phdr;
492 492
493/* Legal values for p_type (segment type). */493/* Legal values for p_type (segment type). */
494 494
495#define PT_NULL 0 /* Program header table entry unused */495#define PT_NULL 0 /* Program header table entry unused */
496#define PT_LOAD 1 /* Loadable program segment */496#define PT_LOAD 1 /* Loadable program segment */
497#define PT_DYNAMIC 2 /* Dynamic linking information */497#define PT_DYNAMIC 2 /* Dynamic linking information */
498#define PT_INTERP 3 /* Program interpreter */498#define PT_INTERP 3 /* Program interpreter */
499#define PT_NOTE 4 /* Auxiliary information */499#define PT_NOTE 4 /* Auxiliary information */
500#define PT_SHLIB 5 /* Reserved */500#define PT_SHLIB 5 /* Reserved */
501#define PT_PHDR 6 /* Entry for header table itself */501#define PT_PHDR 6 /* Entry for header table itself */
502#define PT_NUM 7 /* Number of defined types. */502#define PT_NUM 7 /* Number of defined types. */
503#define PT_LOOS 0x60000000 /* Start of OS-specific */503#define PT_LOOS 0x60000000 /* Start of OS-specific */
504#define PT_HIOS 0x6fffffff /* End of OS-specific */504#define PT_HIOS 0x6fffffff /* End of OS-specific */
505#define PT_LOPROC 0x70000000 /* Start of processor-specific */505#define PT_LOPROC 0x70000000 /* Start of processor-specific */
506#define PT_HIPROC 0x7fffffff /* End of processor-specific */506#define PT_HIPROC 0x7fffffff /* End of processor-specific */
507 507
508/* Legal values for p_flags (segment flags). */508/* Legal values for p_flags (segment flags). */
509 509
510#define PF_X (1 << 0) /* Segment is executable */510#define PF_X (1 << 0) /* Segment is executable */
511#define PF_W (1 << 1) /* Segment is writable */511#define PF_W (1 << 1) /* Segment is writable */
512#define PF_R (1 << 2) /* Segment is readable */512#define PF_R (1 << 2) /* Segment is readable */
513#define PF_MASKPROC 0xf0000000 /* Processor-specific */513#define PF_MASKPROC 0xf0000000 /* Processor-specific */
514 514
515/* Legal values for note segment descriptor types for core files. */515/* Legal values for note segment descriptor types for core files. */
516 516
517#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */517#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */
518#define NT_FPREGSET 2 /* Contains copy of fpregset struct */518#define NT_FPREGSET 2 /* Contains copy of fpregset struct */
519#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */519#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */
520#define NT_PRXREG 4 /* Contains copy of prxregset struct */520#define NT_PRXREG 4 /* Contains copy of prxregset struct */
521#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */521#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */
522#define NT_AUXV 6 /* Contains copy of auxv array */522#define NT_AUXV 6 /* Contains copy of auxv array */
523#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */523#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */
524#define NT_PSTATUS 10 /* Contains copy of pstatus struct */524#define NT_PSTATUS 10 /* Contains copy of pstatus struct */
525#define NT_PSINFO 13 /* Contains copy of psinfo struct */525#define NT_PSINFO 13 /* Contains copy of psinfo struct */
526#define NT_PRCRED 14 /* Contains copy of prcred struct */526#define NT_PRCRED 14 /* Contains copy of prcred struct */
527#define NT_UTSNAME 15 /* Contains copy of utsname struct */527#define NT_UTSNAME 15 /* Contains copy of utsname struct */
528#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */528#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */
529#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */529#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */
530 530
531/* Legal values for the note segment descriptor types for object files. */531/* Legal values for the note segment descriptor types for object files. */
532 532
533#define NT_VERSION 1 /* Contains a version string. */533#define NT_VERSION 1 /* Contains a version string. */
534 534
535 535
536/* Dynamic section entry. */536/* Dynamic section entry. */
537 537
538typedef struct538typedef struct
539{539{
540 Elf32_Sword d_tag; /* Dynamic entry type */540 Elf32_Sword d_tag; /* Dynamic entry type */
541 union541 union
542 {542 {
543 Elf32_Word d_val; /* Integer value */543 Elf32_Word d_val; /* Integer value */
544 Elf32_Addr d_ptr; /* Address value */544 Elf32_Addr d_ptr; /* Address value */
545 } d_un;545 } d_un;
546} Elf32_Dyn;546} Elf32_Dyn;
547 547
548typedef struct548typedef struct
549{549{
550 Elf64_Sxword d_tag; /* Dynamic entry type */550 Elf64_Sxword d_tag; /* Dynamic entry type */
551 union551 union
552 {552 {
553 Elf64_Xword d_val; /* Integer value */553 Elf64_Xword d_val; /* Integer value */
554 Elf64_Addr d_ptr; /* Address value */554 Elf64_Addr d_ptr; /* Address value */
555 } d_un;555 } d_un;
556} Elf64_Dyn;556} Elf64_Dyn;
557 557
558/* Legal values for d_tag (dynamic entry type). */558/* Legal values for d_tag (dynamic entry type). */
559 559
560#define DT_NULL 0 /* Marks end of dynamic section */560#define DT_NULL 0 /* Marks end of dynamic section */
561#define DT_NEEDED 1 /* Name of needed library */561#define DT_NEEDED 1 /* Name of needed library */
562#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */562#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
563#define DT_PLTGOT 3 /* Processor defined value */563#define DT_PLTGOT 3 /* Processor defined value */
564#define DT_HASH 4 /* Address of symbol hash table */564#define DT_HASH 4 /* Address of symbol hash table */
565#define DT_STRTAB 5 /* Address of string table */565#define DT_STRTAB 5 /* Address of string table */
566#define DT_SYMTAB 6 /* Address of symbol table */566#define DT_SYMTAB 6 /* Address of symbol table */
567#define DT_RELA 7 /* Address of Rela relocs */567#define DT_RELA 7 /* Address of Rela relocs */
568#define DT_RELASZ 8 /* Total size of Rela relocs */568#define DT_RELASZ 8 /* Total size of Rela relocs */
569#define DT_RELAENT 9 /* Size of one Rela reloc */569#define DT_RELAENT 9 /* Size of one Rela reloc */
570#define DT_STRSZ 10 /* Size of string table */570#define DT_STRSZ 10 /* Size of string table */
571#define DT_SYMENT 11 /* Size of one symbol table entry */571#define DT_SYMENT 11 /* Size of one symbol table entry */
572#define DT_INIT 12 /* Address of init function */572#define DT_INIT 12 /* Address of init function */
573#define DT_FINI 13 /* Address of termination function */573#define DT_FINI 13 /* Address of termination function */
574#define DT_SONAME 14 /* Name of shared object */574#define DT_SONAME 14 /* Name of shared object */
575#define DT_RPATH 15 /* Library search path */575#define DT_RPATH 15 /* Library search path */
576#define DT_SYMBOLIC 16 /* Start symbol search here */576#define DT_SYMBOLIC 16 /* Start symbol search here */
577#define DT_REL 17 /* Address of Rel relocs */577#define DT_REL 17 /* Address of Rel relocs */
578#define DT_RELSZ 18 /* Total size of Rel relocs */578#define DT_RELSZ 18 /* Total size of Rel relocs */
579#define DT_RELENT 19 /* Size of one Rel reloc */579#define DT_RELENT 19 /* Size of one Rel reloc */
580#define DT_PLTREL 20 /* Type of reloc in PLT */580#define DT_PLTREL 20 /* Type of reloc in PLT */
581#define DT_DEBUG 21 /* For debugging; unspecified */581#define DT_DEBUG 21 /* For debugging; unspecified */
582#define DT_TEXTREL 22 /* Reloc might modify .text */582#define DT_TEXTREL 22 /* Reloc might modify .text */
583#define DT_JMPREL 23 /* Address of PLT relocs */583#define DT_JMPREL 23 /* Address of PLT relocs */
584#define DT_BIND_NOW 24 /* Process relocations of object */584#define DT_BIND_NOW 24 /* Process relocations of object */
585#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */585#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
586#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */586#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
587#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */587#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
588#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */588#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
589#define DT_NUM 29 /* Number used */589#define DT_NUM 29 /* Number used */
590#define DT_LOOS 0x60000000 /* Start of OS-specific */590#define DT_LOOS 0x60000000 /* Start of OS-specific */
591#define DT_HIOS 0x6fffffff /* End of OS-specific */591#define DT_HIOS 0x6fffffff /* End of OS-specific */
592#define DT_LOPROC 0x70000000 /* Start of processor-specific */592#define DT_LOPROC 0x70000000 /* Start of processor-specific */
593#define DT_HIPROC 0x7fffffff /* End of processor-specific */593#define DT_HIPROC 0x7fffffff /* End of processor-specific */
594#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */594#define DT_PROCNUM DT_MIPS_NUM /* Most used by any processor */
595 595
596/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the596/* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the
597 Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's597 Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's
598 approach. */598 approach. */
599#define DT_VALRNGLO 0x6ffffd00599#define DT_VALRNGLO 0x6ffffd00
600#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting600#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
601 the following DT_* entry. */601 the following DT_* entry. */
602#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */602#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
603#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */603#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
604#define DT_VALRNGHI 0x6ffffdff604#define DT_VALRNGHI 0x6ffffdff
605 605
606/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the606/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
607 Dyn.d_un.d_ptr field of the Elf*_Dyn structure.607 Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
608 608
609 If any adjustment is made to the ELF object after it has been609 If any adjustment is made to the ELF object after it has been
610 built these entries will need to be adjusted. */610 built these entries will need to be adjusted. */
611#define DT_ADDRRNGLO 0x6ffffe00611#define DT_ADDRRNGLO 0x6ffffe00
612#define DT_SYMINFO 0x6ffffeff /* syminfo table */612#define DT_SYMINFO 0x6ffffeff /* syminfo table */
613#define DT_ADDRRNGHI 0x6ffffeff613#define DT_ADDRRNGHI 0x6ffffeff
614 614
615/* The versioning entry types. The next are defined as part of the615/* The versioning entry types. The next are defined as part of the
616 GNU extension. */616 GNU extension. */
617#define DT_VERSYM 0x6ffffff0617#define DT_VERSYM 0x6ffffff0
618 618
619/* These were chosen by Sun. */619/* These were chosen by Sun. */
620#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */620#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
621#define DT_VERDEF 0x6ffffffc /* Address of version definition621#define DT_VERDEF 0x6ffffffc /* Address of version definition
622 table */622 table */
623#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */623#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
624#define DT_VERNEED 0x6ffffffe /* Address of table with needed624#define DT_VERNEED 0x6ffffffe /* Address of table with needed
625 versions */625 versions */
626#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */626#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
627#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */627#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
628#define DT_VERSIONTAGNUM 16628#define DT_VERSIONTAGNUM 16
629 629
630/* Sun added these machine-independent extensions in the "processor-specific"630/* Sun added these machine-independent extensions in the "processor-specific"
631 range. Be compatible. */631 range. Be compatible. */
632#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */632#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
633#define DT_FILTER 0x7fffffff /* Shared object to get values from */633#define DT_FILTER 0x7fffffff /* Shared object to get values from */
634#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)634#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
635#define DT_EXTRANUM 3635#define DT_EXTRANUM 3
636 636
637/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1637/* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1
638 entry in the dynamic section. */638 entry in the dynamic section. */
639#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */639#define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */
640#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */640#define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */
641#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */641#define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */
642#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/642#define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/
643#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/643#define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/
644#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/644#define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/
645#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */645#define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */
646 646
647/* Version definition sections. */647/* Version definition sections. */
648 648
649typedef struct649typedef struct
650{650{
651 Elf32_Half vd_version; /* Version revision */651 Elf32_Half vd_version; /* Version revision */
652 Elf32_Half vd_flags; /* Version information */652 Elf32_Half vd_flags; /* Version information */
653 Elf32_Half vd_ndx; /* Version Index */653 Elf32_Half vd_ndx; /* Version Index */
654 Elf32_Half vd_cnt; /* Number of associated aux entries */654 Elf32_Half vd_cnt; /* Number of associated aux entries */
655 Elf32_Word vd_hash; /* Version name hash value */655 Elf32_Word vd_hash; /* Version name hash value */
656 Elf32_Word vd_aux; /* Offset in bytes to verdaux array */656 Elf32_Word vd_aux; /* Offset in bytes to verdaux array */
657 Elf32_Word vd_next; /* Offset in bytes to next verdef657 Elf32_Word vd_next; /* Offset in bytes to next verdef
658 entry */658 entry */
659} Elf32_Verdef;659} Elf32_Verdef;
660 660
661typedef struct661typedef struct
662{662{
663 Elf64_Half vd_version; /* Version revision */663 Elf64_Half vd_version; /* Version revision */
664 Elf64_Half vd_flags; /* Version information */664 Elf64_Half vd_flags; /* Version information */
665 Elf64_Half vd_ndx; /* Version Index */665 Elf64_Half vd_ndx; /* Version Index */
666 Elf64_Half vd_cnt; /* Number of associated aux entries */666 Elf64_Half vd_cnt; /* Number of associated aux entries */
667 Elf64_Word vd_hash; /* Version name hash value */667 Elf64_Word vd_hash; /* Version name hash value */
668 Elf64_Word vd_aux; /* Offset in bytes to verdaux array */668 Elf64_Word vd_aux; /* Offset in bytes to verdaux array */
669 Elf64_Word vd_next; /* Offset in bytes to next verdef669 Elf64_Word vd_next; /* Offset in bytes to next verdef
670 entry */670 entry */
671} Elf64_Verdef;671} Elf64_Verdef;
672 672
673 673
674/* Legal values for vd_version (version revision). */674/* Legal values for vd_version (version revision). */
675#define VER_DEF_NONE 0 /* No version */675#define VER_DEF_NONE 0 /* No version */
676#define VER_DEF_CURRENT 1 /* Current version */676#define VER_DEF_CURRENT 1 /* Current version */
677#define VER_DEF_NUM 2 /* Given version number */677#define VER_DEF_NUM 2 /* Given version number */
678 678
679/* Legal values for vd_flags (version information flags). */679/* Legal values for vd_flags (version information flags). */
680#define VER_FLG_BASE 0x1 /* Version definition of file itself */680#define VER_FLG_BASE 0x1 /* Version definition of file itself */
681#define VER_FLG_WEAK 0x2 /* Weak version identifier */681#define VER_FLG_WEAK 0x2 /* Weak version identifier */
682 682
683/* Auxialiary version information. */683/* Auxialiary version information. */
684 684
685typedef struct685typedef struct
686{686{
687 Elf32_Word vda_name; /* Version or dependency names */687 Elf32_Word vda_name; /* Version or dependency names */
688 Elf32_Word vda_next; /* Offset in bytes to next verdaux688 Elf32_Word vda_next; /* Offset in bytes to next verdaux
689 entry */689 entry */
690} Elf32_Verdaux;690} Elf32_Verdaux;
691 691
692typedef struct692typedef struct
693{693{
694 Elf64_Word vda_name; /* Version or dependency names */694 Elf64_Word vda_name; /* Version or dependency names */
695 Elf64_Word vda_next; /* Offset in bytes to next verdaux695 Elf64_Word vda_next; /* Offset in bytes to next verdaux
696 entry */696 entry */
697} Elf64_Verdaux;697} Elf64_Verdaux;
698 698
699 699
@@ -701,57 +701,57 @@ typedef struct · 1 unmodified line
701 701
702typedef struct702typedef struct
703{703{
704 Elf32_Half vn_version; /* Version of structure */704 Elf32_Half vn_version; /* Version of structure */
705 Elf32_Half vn_cnt; /* Number of associated aux entries */705 Elf32_Half vn_cnt; /* Number of associated aux entries */
706 Elf32_Word vn_file; /* Offset of filename for this706 Elf32_Word vn_file; /* Offset of filename for this
707 dependency */707 dependency */
708 Elf32_Word vn_aux; /* Offset in bytes to vernaux array */708 Elf32_Word vn_aux; /* Offset in bytes to vernaux array */
709 Elf32_Word vn_next; /* Offset in bytes to next verneed709 Elf32_Word vn_next; /* Offset in bytes to next verneed
710 entry */710 entry */
711} Elf32_Verneed;711} Elf32_Verneed;
712 712
713typedef struct713typedef struct
714{714{
715 Elf64_Half vn_version; /* Version of structure */715 Elf64_Half vn_version; /* Version of structure */
716 Elf64_Half vn_cnt; /* Number of associated aux entries */716 Elf64_Half vn_cnt; /* Number of associated aux entries */
717 Elf64_Word vn_file; /* Offset of filename for this717 Elf64_Word vn_file; /* Offset of filename for this
718 dependency */718 dependency */
719 Elf64_Word vn_aux; /* Offset in bytes to vernaux array */719 Elf64_Word vn_aux; /* Offset in bytes to vernaux array */
720 Elf64_Word vn_next; /* Offset in bytes to next verneed720 Elf64_Word vn_next; /* Offset in bytes to next verneed
721 entry */721 entry */
722} Elf64_Verneed;722} Elf64_Verneed;
723 723
724 724
725/* Legal values for vn_version (version revision). */725/* Legal values for vn_version (version revision). */
726#define VER_NEED_NONE 0 /* No version */726#define VER_NEED_NONE 0 /* No version */
727#define VER_NEED_CURRENT 1 /* Current version */727#define VER_NEED_CURRENT 1 /* Current version */
728#define VER_NEED_NUM 2 /* Given version number */728#define VER_NEED_NUM 2 /* Given version number */
729 729
730/* Auxiliary needed version information. */730/* Auxiliary needed version information. */
731 731
732typedef struct732typedef struct
733{733{
734 Elf32_Word vna_hash; /* Hash value of dependency name */734 Elf32_Word vna_hash; /* Hash value of dependency name */
735 Elf32_Half vna_flags; /* Dependency specific information */735 Elf32_Half vna_flags; /* Dependency specific information */
736 Elf32_Half vna_other; /* Unused */736 Elf32_Half vna_other; /* Unused */
737 Elf32_Word vna_name; /* Dependency name string offset */737 Elf32_Word vna_name; /* Dependency name string offset */
738 Elf32_Word vna_next; /* Offset in bytes to next vernaux738 Elf32_Word vna_next; /* Offset in bytes to next vernaux
739 entry */739 entry */
740} Elf32_Vernaux;740} Elf32_Vernaux;
741 741
742typedef struct742typedef struct
743{743{
744 Elf64_Word vna_hash; /* Hash value of dependency name */744 Elf64_Word vna_hash; /* Hash value of dependency name */
745 Elf64_Half vna_flags; /* Dependency specific information */745 Elf64_Half vna_flags; /* Dependency specific information */
746 Elf64_Half vna_other; /* Unused */746 Elf64_Half vna_other; /* Unused */
747 Elf64_Word vna_name; /* Dependency name string offset */747 Elf64_Word vna_name; /* Dependency name string offset */
748 Elf64_Word vna_next; /* Offset in bytes to next vernaux748 Elf64_Word vna_next; /* Offset in bytes to next vernaux
749 entry */749 entry */
750} Elf64_Vernaux;750} Elf64_Vernaux;
751 751
752 752
753/* Legal values for vna_flags. */753/* Legal values for vna_flags. */
754#define VER_FLG_WEAK 0x2 /* Weak version identifier */754#define VER_FLG_WEAK 0x2 /* Weak version identifier */
755 755
756 756
757/* Auxiliary vector. */757/* Auxiliary vector. */
@@ -765,52 +765,52 @@ typedef struct · 7 unmodified lines
765 765
766typedef struct766typedef struct
767{767{
768 int a_type; /* Entry type */768 int a_type; /* Entry type */
769 union769 union
770 {770 {
771 long int a_val; /* Integer value */771 long int a_val; /* Integer value */
772 void *a_ptr; /* Pointer value */772 void *a_ptr; /* Pointer value */
773 void (*a_fcn) (void); /* Function pointer value */773 void (*a_fcn) (void); /* Function pointer value */
774 } a_un;774 } a_un;
775} Elf32_auxv_t;775} Elf32_auxv_t;
776 776
777typedef struct777typedef struct
778{778{
779 long int a_type; /* Entry type */779 long int a_type; /* Entry type */
780 union780 union
781 {781 {
782 long int a_val; /* Integer value */782 long int a_val; /* Integer value */
783 void *a_ptr; /* Pointer value */783 void *a_ptr; /* Pointer value */
784 void (*a_fcn) (void); /* Function pointer value */784 void (*a_fcn) (void); /* Function pointer value */
785 } a_un;785 } a_un;
786} Elf64_auxv_t;786} Elf64_auxv_t;
787 787
788/* Legal values for a_type (entry type). */788/* Legal values for a_type (entry type). */
789 789
790#define AT_NULL 0 /* End of vector */790#define AT_NULL 0 /* End of vector */
791#define AT_IGNORE 1 /* Entry should be ignored */791#define AT_IGNORE 1 /* Entry should be ignored */
792#define AT_EXECFD 2 /* File descriptor of program */792#define AT_EXECFD 2 /* File descriptor of program */
793#define AT_PHDR 3 /* Program headers for program */793#define AT_PHDR 3 /* Program headers for program */
794#define AT_PHENT 4 /* Size of program header entry */794#define AT_PHENT 4 /* Size of program header entry */
795#define AT_PHNUM 5 /* Number of program headers */795#define AT_PHNUM 5 /* Number of program headers */
796#define AT_PAGESZ 6 /* System page size */796#define AT_PAGESZ 6 /* System page size */
797#define AT_BASE 7 /* Base address of interpreter */797#define AT_BASE 7 /* Base address of interpreter */
798#define AT_FLAGS 8 /* Flags */798#define AT_FLAGS 8 /* Flags */
799#define AT_ENTRY 9 /* Entry point of program */799#define AT_ENTRY 9 /* Entry point of program */
800#define AT_NOTELF 10 /* Program is not ELF */800#define AT_NOTELF 10 /* Program is not ELF */
801#define AT_UID 11 /* Real uid */801#define AT_UID 11 /* Real uid */
802#define AT_EUID 12 /* Effective uid */802#define AT_EUID 12 /* Effective uid */
803#define AT_GID 13 /* Real gid */803#define AT_GID 13 /* Real gid */
804#define AT_EGID 14 /* Effective gid */804#define AT_EGID 14 /* Effective gid */
805 805
806/* Some more special a_type values describing the hardware. */806/* Some more special a_type values describing the hardware. */
807#define AT_PLATFORM 15 /* String identifying platform. */807#define AT_PLATFORM 15 /* String identifying platform. */
808#define AT_HWCAP 16 /* Machine dependent hints about808#define AT_HWCAP 16 /* Machine dependent hints about
809 processor capabilities. */809 processor capabilities. */
810 810
811/* This entry gives some information about the FPU initialization811/* This entry gives some information about the FPU initialization
812 performed by the kernel. */812 performed by the kernel. */
813#define AT_FPUCW 17 /* Used FPU control word. */813#define AT_FPUCW 17 /* Used FPU control word. */
814 814
815 815
816/* Note section contents. Each entry in the note section begins with816/* Note section contents. Each entry in the note section begins with
@@ -818,31 +818,31 @@ typedef struct · 1 unmodified line
818 818
819typedef struct819typedef struct
820{820{
821 Elf32_Word n_namesz; /* Length of the note's name. */821 Elf32_Word n_namesz; /* Length of the note's name. */
822 Elf32_Word n_descsz; /* Length of the note's descriptor. */822 Elf32_Word n_descsz; /* Length of the note's descriptor. */
823 Elf32_Word n_type; /* Type of the note. */823 Elf32_Word n_type; /* Type of the note. */
824} Elf32_Nhdr;824} Elf32_Nhdr;
825 825
826typedef struct826typedef struct
827{827{
828 Elf64_Word n_namesz; /* Length of the note's name. */828 Elf64_Word n_namesz; /* Length of the note's name. */
829 Elf64_Word n_descsz; /* Length of the note's descriptor. */829 Elf64_Word n_descsz; /* Length of the note's descriptor. */
830 Elf64_Word n_type; /* Type of the note. */830 Elf64_Word n_type; /* Type of the note. */
831} Elf64_Nhdr;831} Elf64_Nhdr;
832 832
833/* Known names of notes. */833/* Known names of notes. */
834 834
835/* Solaris entries in the note section have this name. */835/* Solaris entries in the note section have this name. */
836#define ELF_NOTE_SOLARIS "SUNW Solaris"836#define ELF_NOTE_SOLARIS "SUNW Solaris"
837 837
838/* Note entries for GNU systems have this name. */838/* Note entries for GNU systems have this name. */
839#define ELF_NOTE_GNU "GNU"839#define ELF_NOTE_GNU "GNU"
840 840
841 841
842/* Defined types of notes for Solaris. */842/* Defined types of notes for Solaris. */
843 843
844/* Value of descriptor (one word) is desired pagesize for the binary. */844/* Value of descriptor (one word) is desired pagesize for the binary. */
845#define ELF_NOTE_PAGESIZE_HINT 1845#define ELF_NOTE_PAGESIZE_HINT 1
846 846
847 847
848/* Defined note types for GNU systems. */848/* Defined note types for GNU systems. */
@@ -853,253 +853,253 @@ typedef struct · 4 unmodified lines
853 word 2: minor version of the ABI853 word 2: minor version of the ABI
854 word 3: subminor version of the ABI854 word 3: subminor version of the ABI
855*/855*/
856#define ELF_NOTE_ABI 1856#define ELF_NOTE_ABI 1
857 857
858/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI858/* Known OSes. These value can appear in word 0 of an ELF_NOTE_ABI
859 note section entry. */859 note section entry. */
860#define ELF_NOTE_OS_LINUX 0860#define ELF_NOTE_OS_LINUX 0
861#define ELF_NOTE_OS_GNU 1861#define ELF_NOTE_OS_GNU 1
862#define ELF_NOTE_OS_SOLARIS2 2862#define ELF_NOTE_OS_SOLARIS2 2
863 863
864 864
865/* Motorola 68k specific definitions. */865/* Motorola 68k specific definitions. */
866 866
867/* m68k relocs. */867/* m68k relocs. */
868 868
869#define R_68K_NONE 0 /* No reloc */869#define R_68K_NONE 0 /* No reloc */
870#define R_68K_32 1 /* Direct 32 bit */870#define R_68K_32 1 /* Direct 32 bit */
871#define R_68K_16 2 /* Direct 16 bit */871#define R_68K_16 2 /* Direct 16 bit */
872#define R_68K_8 3 /* Direct 8 bit */872#define R_68K_8 3 /* Direct 8 bit */
873#define R_68K_PC32 4 /* PC relative 32 bit */873#define R_68K_PC32 4 /* PC relative 32 bit */
874#define R_68K_PC16 5 /* PC relative 16 bit */874#define R_68K_PC16 5 /* PC relative 16 bit */
875#define R_68K_PC8 6 /* PC relative 8 bit */875#define R_68K_PC8 6 /* PC relative 8 bit */
876#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */876#define R_68K_GOT32 7 /* 32 bit PC relative GOT entry */
877#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */877#define R_68K_GOT16 8 /* 16 bit PC relative GOT entry */
878#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */878#define R_68K_GOT8 9 /* 8 bit PC relative GOT entry */
879#define R_68K_GOT32O 10 /* 32 bit GOT offset */879#define R_68K_GOT32O 10 /* 32 bit GOT offset */
880#define R_68K_GOT16O 11 /* 16 bit GOT offset */880#define R_68K_GOT16O 11 /* 16 bit GOT offset */
881#define R_68K_GOT8O 12 /* 8 bit GOT offset */881#define R_68K_GOT8O 12 /* 8 bit GOT offset */
882#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */882#define R_68K_PLT32 13 /* 32 bit PC relative PLT address */
883#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */883#define R_68K_PLT16 14 /* 16 bit PC relative PLT address */
884#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */884#define R_68K_PLT8 15 /* 8 bit PC relative PLT address */
885#define R_68K_PLT32O 16 /* 32 bit PLT offset */885#define R_68K_PLT32O 16 /* 32 bit PLT offset */
886#define R_68K_PLT16O 17 /* 16 bit PLT offset */886#define R_68K_PLT16O 17 /* 16 bit PLT offset */
887#define R_68K_PLT8O 18 /* 8 bit PLT offset */887#define R_68K_PLT8O 18 /* 8 bit PLT offset */
888#define R_68K_COPY 19 /* Copy symbol at runtime */888#define R_68K_COPY 19 /* Copy symbol at runtime */
889#define R_68K_GLOB_DAT 20 /* Create GOT entry */889#define R_68K_GLOB_DAT 20 /* Create GOT entry */
890#define R_68K_JMP_SLOT 21 /* Create PLT entry */890#define R_68K_JMP_SLOT 21 /* Create PLT entry */
891#define R_68K_RELATIVE 22 /* Adjust by program base */891#define R_68K_RELATIVE 22 /* Adjust by program base */
892/* Keep this the last entry. */892/* Keep this the last entry. */
893#define R_68K_NUM 23893#define R_68K_NUM 23
894 894
895/* Intel 80386 specific definitions. */895/* Intel 80386 specific definitions. */
896 896
897/* i386 relocs. */897/* i386 relocs. */
898 898
899#define R_386_NONE 0 /* No reloc */899#define R_386_NONE 0 /* No reloc */
900#define R_386_32 1 /* Direct 32 bit */900#define R_386_32 1 /* Direct 32 bit */
901#define R_386_PC32 2 /* PC relative 32 bit */901#define R_386_PC32 2 /* PC relative 32 bit */
902#define R_386_GOT32 3 /* 32 bit GOT entry */902#define R_386_GOT32 3 /* 32 bit GOT entry */
903#define R_386_PLT32 4 /* 32 bit PLT address */903#define R_386_PLT32 4 /* 32 bit PLT address */
904#define R_386_COPY 5 /* Copy symbol at runtime */904#define R_386_COPY 5 /* Copy symbol at runtime */
905#define R_386_GLOB_DAT 6 /* Create GOT entry */905#define R_386_GLOB_DAT 6 /* Create GOT entry */
906#define R_386_JMP_SLOT 7 /* Create PLT entry */906#define R_386_JMP_SLOT 7 /* Create PLT entry */
907#define R_386_RELATIVE 8 /* Adjust by program base */907#define R_386_RELATIVE 8 /* Adjust by program base */
908#define R_386_GOTOFF 9 /* 32 bit offset to GOT */908#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
909#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */909#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
910/* Keep this the last entry. */910/* Keep this the last entry. */
911#define R_386_NUM 11911#define R_386_NUM 11
912 912
913/* SUN SPARC specific definitions. */913/* SUN SPARC specific definitions. */
914 914
915/* Values for Elf64_Ehdr.e_flags. */915/* Values for Elf64_Ehdr.e_flags. */
916 916
917#define EF_SPARCV9_MM 3917#define EF_SPARCV9_MM 3
918#define EF_SPARCV9_TSO 0918#define EF_SPARCV9_TSO 0
919#define EF_SPARCV9_PSO 1919#define EF_SPARCV9_PSO 1
920#define EF_SPARCV9_RMO 2920#define EF_SPARCV9_RMO 2
921#define EF_SPARC_EXT_MASK 0xFFFF00921#define EF_SPARC_EXT_MASK 0xFFFF00
922#define EF_SPARC_SUN_US1 0x000200922#define EF_SPARC_SUN_US1 0x000200
923#define EF_SPARC_HAL_R1 0x000400923#define EF_SPARC_HAL_R1 0x000400
924 924
925/* SPARC relocs. */925/* SPARC relocs. */
926 926
927#define R_SPARC_NONE 0 /* No reloc */927#define R_SPARC_NONE 0 /* No reloc */
928#define R_SPARC_8 1 /* Direct 8 bit */928#define R_SPARC_8 1 /* Direct 8 bit */
929#define R_SPARC_16 2 /* Direct 16 bit */929#define R_SPARC_16 2 /* Direct 16 bit */
930#define R_SPARC_32 3 /* Direct 32 bit */930#define R_SPARC_32 3 /* Direct 32 bit */
931#define R_SPARC_DISP8 4 /* PC relative 8 bit */931#define R_SPARC_DISP8 4 /* PC relative 8 bit */
932#define R_SPARC_DISP16 5 /* PC relative 16 bit */932#define R_SPARC_DISP16 5 /* PC relative 16 bit */
933#define R_SPARC_DISP32 6 /* PC relative 32 bit */933#define R_SPARC_DISP32 6 /* PC relative 32 bit */
934#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */934#define R_SPARC_WDISP30 7 /* PC relative 30 bit shifted */
935#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */935#define R_SPARC_WDISP22 8 /* PC relative 22 bit shifted */
936#define R_SPARC_HI22 9 /* High 22 bit */936#define R_SPARC_HI22 9 /* High 22 bit */
937#define R_SPARC_22 10 /* Direct 22 bit */937#define R_SPARC_22 10 /* Direct 22 bit */
938#define R_SPARC_13 11 /* Direct 13 bit */938#define R_SPARC_13 11 /* Direct 13 bit */
939#define R_SPARC_LO10 12 /* Truncated 10 bit */939#define R_SPARC_LO10 12 /* Truncated 10 bit */
940#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */940#define R_SPARC_GOT10 13 /* Truncated 10 bit GOT entry */
941#define R_SPARC_GOT13 14 /* 13 bit GOT entry */941#define R_SPARC_GOT13 14 /* 13 bit GOT entry */
942#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */942#define R_SPARC_GOT22 15 /* 22 bit GOT entry shifted */
943#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */943#define R_SPARC_PC10 16 /* PC relative 10 bit truncated */
944#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */944#define R_SPARC_PC22 17 /* PC relative 22 bit shifted */
945#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */945#define R_SPARC_WPLT30 18 /* 30 bit PC relative PLT address */
946#define R_SPARC_COPY 19 /* Copy symbol at runtime */946#define R_SPARC_COPY 19 /* Copy symbol at runtime */
947#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */947#define R_SPARC_GLOB_DAT 20 /* Create GOT entry */
948#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */948#define R_SPARC_JMP_SLOT 21 /* Create PLT entry */
949#define R_SPARC_RELATIVE 22 /* Adjust by program base */949#define R_SPARC_RELATIVE 22 /* Adjust by program base */
950#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */950#define R_SPARC_UA32 23 /* Direct 32 bit unaligned */
951 951
952/* Additional Sparc64 relocs. */952/* Additional Sparc64 relocs. */
953 953
954#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */954#define R_SPARC_PLT32 24 /* Direct 32 bit ref to PLT entry */
955#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */955#define R_SPARC_HIPLT22 25 /* High 22 bit PLT entry */
956#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */956#define R_SPARC_LOPLT10 26 /* Truncated 10 bit PLT entry */
957#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */957#define R_SPARC_PCPLT32 27 /* PC rel 32 bit ref to PLT entry */
958#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */958#define R_SPARC_PCPLT22 28 /* PC rel high 22 bit PLT entry */
959#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */959#define R_SPARC_PCPLT10 29 /* PC rel trunc 10 bit PLT entry */
960#define R_SPARC_10 30 /* Direct 10 bit */960#define R_SPARC_10 30 /* Direct 10 bit */
961#define R_SPARC_11 31 /* Direct 11 bit */961#define R_SPARC_11 31 /* Direct 11 bit */
962#define R_SPARC_64 32 /* Direct 64 bit */962#define R_SPARC_64 32 /* Direct 64 bit */
963#define R_SPARC_OLO10 33 /* ?? */963#define R_SPARC_OLO10 33 /* ?? */
964#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */964#define R_SPARC_HH22 34 /* Top 22 bits of direct 64 bit */
965#define R_SPARC_HM10 35 /* High middle 10 bits of ... */965#define R_SPARC_HM10 35 /* High middle 10 bits of ... */
966#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */966#define R_SPARC_LM22 36 /* Low middle 22 bits of ... */
967#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */967#define R_SPARC_PC_HH22 37 /* Top 22 bits of pc rel 64 bit */
968#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */968#define R_SPARC_PC_HM10 38 /* High middle 10 bit of ... */
969#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */969#define R_SPARC_PC_LM22 39 /* Low miggle 22 bits of ... */
970#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */970#define R_SPARC_WDISP16 40 /* PC relative 16 bit shifted */
971#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */971#define R_SPARC_WDISP19 41 /* PC relative 19 bit shifted */
972#define R_SPARC_7 43 /* Direct 7 bit */972#define R_SPARC_7 43 /* Direct 7 bit */
973#define R_SPARC_5 44 /* Direct 5 bit */973#define R_SPARC_5 44 /* Direct 5 bit */
974#define R_SPARC_6 45 /* Direct 6 bit */974#define R_SPARC_6 45 /* Direct 6 bit */
975#define R_SPARC_DISP64 46 /* PC relative 64 bit */975#define R_SPARC_DISP64 46 /* PC relative 64 bit */
976#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */976#define R_SPARC_PLT64 47 /* Direct 64 bit ref to PLT entry */
977#define R_SPARC_HIX22 48 /* High 22 bit complemented */977#define R_SPARC_HIX22 48 /* High 22 bit complemented */
978#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */978#define R_SPARC_LOX10 49 /* Truncated 11 bit complemented */
979#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */979#define R_SPARC_H44 50 /* Direct high 12 of 44 bit */
980#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */980#define R_SPARC_M44 51 /* Direct mid 22 of 44 bit */
981#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */981#define R_SPARC_L44 52 /* Direct low 10 of 44 bit */
982#define R_SPARC_REGISTER 53 /* Global register usage */982#define R_SPARC_REGISTER 53 /* Global register usage */
983#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */983#define R_SPARC_UA64 54 /* Direct 64 bit unaligned */
984#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */984#define R_SPARC_UA16 55 /* Direct 16 bit unaligned */
985/* Keep this the last entry. */985/* Keep this the last entry. */
986#define R_SPARC_NUM 56986#define R_SPARC_NUM 56
987 987
988/* For Sparc64, legal values for d_tag of Elf64_Dyn. */988/* For Sparc64, legal values for d_tag of Elf64_Dyn. */
989 989
990#define DT_SPARC_REGISTER 0x70000001990#define DT_SPARC_REGISTER 0x70000001
991#define DT_SPARC_NUM 2991#define DT_SPARC_NUM 2
992 992
993/* Bits present in AT_HWCAP, primarily for Sparc32. */993/* Bits present in AT_HWCAP, primarily for Sparc32. */
994 994
995#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */995#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */
996#define HWCAP_SPARC_STBAR 2996#define HWCAP_SPARC_STBAR 2
997#define HWCAP_SPARC_SWAP 4997#define HWCAP_SPARC_SWAP 4
998#define HWCAP_SPARC_MULDIV 8998#define HWCAP_SPARC_MULDIV 8
999#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */999#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */
1000 1000
1001/* MIPS R3000 specific definitions. */1001/* MIPS R3000 specific definitions. */
1002 1002
1003/* Legal values for e_flags field of Elf32_Ehdr. */1003/* Legal values for e_flags field of Elf32_Ehdr. */
1004 1004
1005#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */1005#define EF_MIPS_NOREORDER 1 /* A .noreorder directive was used */
1006#define EF_MIPS_PIC 2 /* Contains PIC code */1006#define EF_MIPS_PIC 2 /* Contains PIC code */
1007#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */1007#define EF_MIPS_CPIC 4 /* Uses PIC calling sequence */
1008#define EF_MIPS_XGOT 81008#define EF_MIPS_XGOT 8
1009#define EF_MIPS_64BIT_WHIRL 161009#define EF_MIPS_64BIT_WHIRL 16
1010#define EF_MIPS_ABI2 321010#define EF_MIPS_ABI2 32
1011#define EF_MIPS_ABI_ON32 641011#define EF_MIPS_ABI_ON32 64
1012#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */1012#define EF_MIPS_ARCH 0xf0000000 /* MIPS architecture level */
1013 1013
1014/* Legal values for MIPS architecture level. */1014/* Legal values for MIPS architecture level. */
1015 1015
1016#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */1016#define EF_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
1017#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */1017#define EF_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
1018#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */1018#define EF_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
1019#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */1019#define EF_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
1020#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */1020#define EF_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
1021 1021
1022/* The following are non-official names and should not be used. */1022/* The following are non-official names and should not be used. */
1023 1023
1024#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */1024#define E_MIPS_ARCH_1 0x00000000 /* -mips1 code. */
1025#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */1025#define E_MIPS_ARCH_2 0x10000000 /* -mips2 code. */
1026#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */1026#define E_MIPS_ARCH_3 0x20000000 /* -mips3 code. */
1027#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */1027#define E_MIPS_ARCH_4 0x30000000 /* -mips4 code. */
1028#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */1028#define E_MIPS_ARCH_5 0x40000000 /* -mips5 code. */
1029 1029
1030/* Special section indices. */1030/* Special section indices. */
1031 1031
1032#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */1032#define SHN_MIPS_ACOMMON 0xff00 /* Allocated common symbols */
1033#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */1033#define SHN_MIPS_TEXT 0xff01 /* Allocated test symbols. */
1034#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */1034#define SHN_MIPS_DATA 0xff02 /* Allocated data symbols. */
1035#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */1035#define SHN_MIPS_SCOMMON 0xff03 /* Small common symbols */
1036#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */1036#define SHN_MIPS_SUNDEFINED 0xff04 /* Small undefined symbols */
1037 1037
1038/* Legal values for sh_type field of Elf32_Shdr. */1038/* Legal values for sh_type field of Elf32_Shdr. */
1039 1039
1040#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */1040#define SHT_MIPS_LIBLIST 0x70000000 /* Shared objects used in link */
1041#define SHT_MIPS_MSYM 0x700000011041#define SHT_MIPS_MSYM 0x70000001
1042#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */1042#define SHT_MIPS_CONFLICT 0x70000002 /* Conflicting symbols */
1043#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */1043#define SHT_MIPS_GPTAB 0x70000003 /* Global data area sizes */
1044#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */1044#define SHT_MIPS_UCODE 0x70000004 /* Reserved for SGI/MIPS compilers */
1045#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/1045#define SHT_MIPS_DEBUG 0x70000005 /* MIPS ECOFF debugging information*/
1046#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */1046#define SHT_MIPS_REGINFO 0x70000006 /* Register usage information */
1047#define SHT_MIPS_PACKAGE 0x700000071047#define SHT_MIPS_PACKAGE 0x70000007
1048#define SHT_MIPS_PACKSYM 0x700000081048#define SHT_MIPS_PACKSYM 0x70000008
1049#define SHT_MIPS_RELD 0x700000091049#define SHT_MIPS_RELD 0x70000009
1050#define SHT_MIPS_IFACE 0x7000000b1050#define SHT_MIPS_IFACE 0x7000000b
1051#define SHT_MIPS_CONTENT 0x7000000c1051#define SHT_MIPS_CONTENT 0x7000000c
1052#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */1052#define SHT_MIPS_OPTIONS 0x7000000d /* Miscellaneous options. */
1053#define SHT_MIPS_SHDR 0x700000101053#define SHT_MIPS_SHDR 0x70000010
1054#define SHT_MIPS_FDESC 0x700000111054#define SHT_MIPS_FDESC 0x70000011
1055#define SHT_MIPS_EXTSYM 0x700000121055#define SHT_MIPS_EXTSYM 0x70000012
1056#define SHT_MIPS_DENSE 0x700000131056#define SHT_MIPS_DENSE 0x70000013
1057#define SHT_MIPS_PDESC 0x700000141057#define SHT_MIPS_PDESC 0x70000014
1058#define SHT_MIPS_LOCSYM 0x700000151058#define SHT_MIPS_LOCSYM 0x70000015
1059#define SHT_MIPS_AUXSYM 0x700000161059#define SHT_MIPS_AUXSYM 0x70000016
1060#define SHT_MIPS_OPTSYM 0x700000171060#define SHT_MIPS_OPTSYM 0x70000017
1061#define SHT_MIPS_LOCSTR 0x700000181061#define SHT_MIPS_LOCSTR 0x70000018
1062#define SHT_MIPS_LINE 0x700000191062#define SHT_MIPS_LINE 0x70000019
1063#define SHT_MIPS_RFDESC 0x7000001a1063#define SHT_MIPS_RFDESC 0x7000001a
1064#define SHT_MIPS_DELTASYM 0x7000001b1064#define SHT_MIPS_DELTASYM 0x7000001b
1065#define SHT_MIPS_DELTAINST 0x7000001c1065#define SHT_MIPS_DELTAINST 0x7000001c
1066#define SHT_MIPS_DELTACLASS 0x7000001d1066#define SHT_MIPS_DELTACLASS 0x7000001d
1067#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */1067#define SHT_MIPS_DWARF 0x7000001e /* DWARF debugging information. */
1068#define SHT_MIPS_DELTADECL 0x7000001f1068#define SHT_MIPS_DELTADECL 0x7000001f
1069#define SHT_MIPS_SYMBOL_LIB 0x700000201069#define SHT_MIPS_SYMBOL_LIB 0x70000020
1070#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */1070#define SHT_MIPS_EVENTS 0x70000021 /* Event section. */
1071#define SHT_MIPS_TRANSLATE 0x700000221071#define SHT_MIPS_TRANSLATE 0x70000022
1072#define SHT_MIPS_PIXIE 0x700000231072#define SHT_MIPS_PIXIE 0x70000023
1073#define SHT_MIPS_XLATE 0x700000241073#define SHT_MIPS_XLATE 0x70000024
1074#define SHT_MIPS_XLATE_DEBUG 0x700000251074#define SHT_MIPS_XLATE_DEBUG 0x70000025
1075#define SHT_MIPS_WHIRL 0x700000261075#define SHT_MIPS_WHIRL 0x70000026
1076#define SHT_MIPS_EH_REGION 0x700000271076#define SHT_MIPS_EH_REGION 0x70000027
1077#define SHT_MIPS_XLATE_OLD 0x700000281077#define SHT_MIPS_XLATE_OLD 0x70000028
1078#define SHT_MIPS_PDR_EXCEPTION 0x700000291078#define SHT_MIPS_PDR_EXCEPTION 0x70000029
1079 1079
1080/* Legal values for sh_flags field of Elf32_Shdr. */1080/* Legal values for sh_flags field of Elf32_Shdr. */
1081 1081
1082#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */1082#define SHF_MIPS_GPREL 0x10000000 /* Must be part of global data area */
1083#define SHF_MIPS_MERGE 0x200000001083#define SHF_MIPS_MERGE 0x20000000
1084#define SHF_MIPS_ADDR 0x400000001084#define SHF_MIPS_ADDR 0x40000000
1085#define SHF_MIPS_STRINGS 0x800000001085#define SHF_MIPS_STRINGS 0x80000000
1086#define SHF_MIPS_NOSTRIP 0x080000001086#define SHF_MIPS_NOSTRIP 0x08000000
1087#define SHF_MIPS_LOCAL 0x040000001087#define SHF_MIPS_LOCAL 0x04000000
1088#define SHF_MIPS_NAMES 0x020000001088#define SHF_MIPS_NAMES 0x02000000
1089#define SHF_MIPS_NODUPE 0x010000001089#define SHF_MIPS_NODUPE 0x01000000
1090 1090
1091 1091
1092/* Symbol tables. */1092/* Symbol tables. */
1093 1093
1094/* MIPS specific values for `st_other'. */1094/* MIPS specific values for `st_other'. */
1095#define STO_MIPS_DEFAULT 0x01095#define STO_MIPS_DEFAULT 0x0
1096#define STO_MIPS_INTERNAL 0x11096#define STO_MIPS_INTERNAL 0x1
1097#define STO_MIPS_HIDDEN 0x21097#define STO_MIPS_HIDDEN 0x2
1098#define STO_MIPS_PROTECTED 0x31098#define STO_MIPS_PROTECTED 0x3
1099#define STO_MIPS_SC_ALIGN_UNUSED 0xff1099#define STO_MIPS_SC_ALIGN_UNUSED 0xff
1100 1100
1101/* MIPS specific values for `st_info'. */1101/* MIPS specific values for `st_info'. */
1102#define STB_MIPS_SPLIT_COMMON 131102#define STB_MIPS_SPLIT_COMMON 13
1103 1103
1104/* Entries found in sections of type SHT_MIPS_GPTAB. */1104/* Entries found in sections of type SHT_MIPS_GPTAB. */
1105 1105
@@ -1107,176 +1107,176 @@ typedef union · 1 unmodified line
1107{1107{
1108 struct1108 struct
1109 {1109 {
1110 Elf32_Word gt_current_g_value; /* -G value used for compilation */1110 Elf32_Word gt_current_g_value; /* -G value used for compilation */
1111 Elf32_Word gt_unused; /* Not used */1111 Elf32_Word gt_unused; /* Not used */
1112 } gt_header; /* First entry in section */1112 } gt_header; /* First entry in section */
1113 struct1113 struct
1114 {1114 {
1115 Elf32_Word gt_g_value; /* If this value were used for -G */1115 Elf32_Word gt_g_value; /* If this value were used for -G */
1116 Elf32_Word gt_bytes; /* This many bytes would be used */1116 Elf32_Word gt_bytes; /* This many bytes would be used */
1117 } gt_entry; /* Subsequent entries in section */1117 } gt_entry; /* Subsequent entries in section */
1118} Elf32_gptab;1118} Elf32_gptab;
1119 1119
1120/* Entry found in sections of type SHT_MIPS_REGINFO. */1120/* Entry found in sections of type SHT_MIPS_REGINFO. */
1121 1121
1122typedef struct1122typedef struct
1123{1123{
1124 Elf32_Word ri_gprmask; /* General registers used */1124 Elf32_Word ri_gprmask; /* General registers used */
1125 Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */1125 Elf32_Word ri_cprmask[4]; /* Coprocessor registers used */
1126 Elf32_Sword ri_gp_value; /* $gp register value */1126 Elf32_Sword ri_gp_value; /* $gp register value */
1127} Elf32_RegInfo;1127} Elf32_RegInfo;
1128 1128
1129/* Entries found in sections of type SHT_MIPS_OPTIONS. */1129/* Entries found in sections of type SHT_MIPS_OPTIONS. */
1130 1130
1131typedef struct1131typedef struct
1132{1132{
1133 unsigned char kind; /* Determines interpretation of the1133 unsigned char kind; /* Determines interpretation of the
1134 variable part of descriptor. */1134 variable part of descriptor. */
1135 unsigned char size; /* Size of descriptor, including header. */1135 unsigned char size; /* Size of descriptor, including header. */
1136 Elf32_Section section; /* Section header index of section affected,1136 Elf32_Section section; /* Section header index of section affected,
1137 0 for global options. */1137 0 for global options. */
1138 Elf32_Word info; /* Kind-specific information. */1138 Elf32_Word info; /* Kind-specific information. */
1139} Elf_Options;1139} Elf_Options;
1140 1140
1141/* Values for `kind' field in Elf_Options. */1141/* Values for `kind' field in Elf_Options. */
1142 1142
1143#define ODK_NULL 0 /* Undefined. */1143#define ODK_NULL 0 /* Undefined. */
1144#define ODK_REGINFO 1 /* Register usage information. */1144#define ODK_REGINFO 1 /* Register usage information. */
1145#define ODK_EXCEPTIONS 2 /* Exception processing options. */1145#define ODK_EXCEPTIONS 2 /* Exception processing options. */
1146#define ODK_PAD 3 /* Section padding options. */1146#define ODK_PAD 3 /* Section padding options. */
1147#define ODK_HWPATCH 4 /* Hardware workarounds performed */1147#define ODK_HWPATCH 4 /* Hardware workarounds performed */
1148#define ODK_FILL 5 /* record the fill value used by the linker. */1148#define ODK_FILL 5 /* record the fill value used by the linker. */
1149#define ODK_TAGS 6 /* reserve space for desktop tools to write. */1149#define ODK_TAGS 6 /* reserve space for desktop tools to write. */
1150#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */1150#define ODK_HWAND 7 /* HW workarounds. 'AND' bits when merging. */
1151#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */1151#define ODK_HWOR 8 /* HW workarounds. 'OR' bits when merging. */
1152 1152
1153/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */1153/* Values for `info' in Elf_Options for ODK_EXCEPTIONS entries. */
1154 1154
1155#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */1155#define OEX_FPU_MIN 0x1f /* FPE's which MUST be enabled. */
1156#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */1156#define OEX_FPU_MAX 0x1f00 /* FPE's which MAY be enabled. */
1157#define OEX_PAGE0 0x10000 /* page zero must be mapped. */1157#define OEX_PAGE0 0x10000 /* page zero must be mapped. */
1158#define OEX_SMM 0x20000 /* Force sequential memory mode? */1158#define OEX_SMM 0x20000 /* Force sequential memory mode? */
1159#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */1159#define OEX_FPDBUG 0x40000 /* Force floating point debug mode? */
1160#define OEX_PRECISEFP OEX_FPDBUG1160#define OEX_PRECISEFP OEX_FPDBUG
1161#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */1161#define OEX_DISMISS 0x80000 /* Dismiss invalid address faults? */
1162 1162
1163#define OEX_FPU_INVAL 0x101163#define OEX_FPU_INVAL 0x10
1164#define OEX_FPU_DIV0 0x081164#define OEX_FPU_DIV0 0x08
1165#define OEX_FPU_OFLO 0x041165#define OEX_FPU_OFLO 0x04
1166#define OEX_FPU_UFLO 0x021166#define OEX_FPU_UFLO 0x02
1167#define OEX_FPU_INEX 0x011167#define OEX_FPU_INEX 0x01
1168 1168
1169/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */1169/* Masks for `info' in Elf_Options for an ODK_HWPATCH entry. */
1170 1170
1171#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */1171#define OHW_R4KEOP 0x1 /* R4000 end-of-page patch. */
1172#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */1172#define OHW_R8KPFETCH 0x2 /* may need R8000 prefetch patch. */
1173#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */1173#define OHW_R5KEOP 0x4 /* R5000 end-of-page patch. */
1174#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */1174#define OHW_R5KCVTL 0x8 /* R5000 cvt.[ds].l bug. clean=1. */
1175 1175
1176#define OPAD_PREFIX 0x11176#define OPAD_PREFIX 0x1
1177#define OPAD_POSTFIX 0x21177#define OPAD_POSTFIX 0x2
1178#define OPAD_SYMBOL 0x41178#define OPAD_SYMBOL 0x4
1179 1179
1180/* Entry found in `.options' section. */1180/* Entry found in `.options' section. */
1181 1181
1182typedef struct1182typedef struct
1183{1183{
1184 Elf32_Word hwp_flags1; /* Extra flags. */1184 Elf32_Word hwp_flags1; /* Extra flags. */
1185 Elf32_Word hwp_flags2; /* Extra flags. */1185 Elf32_Word hwp_flags2; /* Extra flags. */
1186} Elf_Options_Hw;1186} Elf_Options_Hw;
1187 1187
1188/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */1188/* Masks for `info' in ElfOptions for ODK_HWAND and ODK_HWOR entries. */
1189 1189
1190#define OHWA0_R4KEOP_CHECKED 0x000000011190#define OHWA0_R4KEOP_CHECKED 0x00000001
1191#define OHWA1_R4KEOP_CLEAN 0x000000021191#define OHWA1_R4KEOP_CLEAN 0x00000002
1192 1192
1193/* MIPS relocs. */1193/* MIPS relocs. */
1194 1194
1195#define R_MIPS_NONE 0 /* No reloc */1195#define R_MIPS_NONE 0 /* No reloc */
1196#define R_MIPS_16 1 /* Direct 16 bit */1196#define R_MIPS_16 1 /* Direct 16 bit */
1197#define R_MIPS_32 2 /* Direct 32 bit */1197#define R_MIPS_32 2 /* Direct 32 bit */
1198#define R_MIPS_REL32 3 /* PC relative 32 bit */1198#define R_MIPS_REL32 3 /* PC relative 32 bit */
1199#define R_MIPS_26 4 /* Direct 26 bit shifted */1199#define R_MIPS_26 4 /* Direct 26 bit shifted */
1200#define R_MIPS_HI16 5 /* High 16 bit */1200#define R_MIPS_HI16 5 /* High 16 bit */
1201#define R_MIPS_LO16 6 /* Low 16 bit */1201#define R_MIPS_LO16 6 /* Low 16 bit */
1202#define R_MIPS_GPREL16 7 /* GP relative 16 bit */1202#define R_MIPS_GPREL16 7 /* GP relative 16 bit */
1203#define R_MIPS_LITERAL 8 /* 16 bit literal entry */1203#define R_MIPS_LITERAL 8 /* 16 bit literal entry */
1204#define R_MIPS_GOT16 9 /* 16 bit GOT entry */1204#define R_MIPS_GOT16 9 /* 16 bit GOT entry */
1205#define R_MIPS_PC16 10 /* PC relative 16 bit */1205#define R_MIPS_PC16 10 /* PC relative 16 bit */
1206#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */1206#define R_MIPS_CALL16 11 /* 16 bit GOT entry for function */
1207#define R_MIPS_GPREL32 12 /* GP relative 32 bit */1207#define R_MIPS_GPREL32 12 /* GP relative 32 bit */
1208 1208
1209#define R_MIPS_SHIFT5 161209#define R_MIPS_SHIFT5 16
1210#define R_MIPS_SHIFT6 171210#define R_MIPS_SHIFT6 17
1211#define R_MIPS_64 181211#define R_MIPS_64 18
1212#define R_MIPS_GOT_DISP 191212#define R_MIPS_GOT_DISP 19
1213#define R_MIPS_GOT_PAGE 201213#define R_MIPS_GOT_PAGE 20
1214#define R_MIPS_GOT_OFST 211214#define R_MIPS_GOT_OFST 21
1215#define R_MIPS_GOT_HI16 221215#define R_MIPS_GOT_HI16 22
1216#define R_MIPS_GOT_LO16 231216#define R_MIPS_GOT_LO16 23
1217#define R_MIPS_SUB 241217#define R_MIPS_SUB 24
1218#define R_MIPS_INSERT_A 251218#define R_MIPS_INSERT_A 25
1219#define R_MIPS_INSERT_B 261219#define R_MIPS_INSERT_B 26
1220#define R_MIPS_DELETE 271220#define R_MIPS_DELETE 27
1221#define R_MIPS_HIGHER 281221#define R_MIPS_HIGHER 28
1222#define R_MIPS_HIGHEST 291222#define R_MIPS_HIGHEST 29
1223#define R_MIPS_CALL_HI16 301223#define R_MIPS_CALL_HI16 30
1224#define R_MIPS_CALL_LO16 311224#define R_MIPS_CALL_LO16 31
1225#define R_MIPS_SCN_DISP 321225#define R_MIPS_SCN_DISP 32
1226#define R_MIPS_REL16 331226#define R_MIPS_REL16 33
1227#define R_MIPS_ADD_IMMEDIATE 341227#define R_MIPS_ADD_IMMEDIATE 34
1228#define R_MIPS_PJUMP 351228#define R_MIPS_PJUMP 35
1229#define R_MIPS_RELGOT 361229#define R_MIPS_RELGOT 36
1230#define R_MIPS_JALR 371230#define R_MIPS_JALR 37
1231/* Keep this the last entry. */1231/* Keep this the last entry. */
1232#define R_MIPS_NUM 381232#define R_MIPS_NUM 38
1233 1233
1234/* Legal values for p_type field of Elf32_Phdr. */1234/* Legal values for p_type field of Elf32_Phdr. */
1235 1235
1236#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */1236#define PT_MIPS_REGINFO 0x70000000 /* Register usage information */
1237#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */1237#define PT_MIPS_RTPROC 0x70000001 /* Runtime procedure table. */
1238#define PT_MIPS_OPTIONS 0x700000021238#define PT_MIPS_OPTIONS 0x70000002
1239 1239
1240/* Special program header types. */1240/* Special program header types. */
1241 1241
1242#define PF_MIPS_LOCAL 0x100000001242#define PF_MIPS_LOCAL 0x10000000
1243 1243
1244/* Legal values for d_tag field of Elf32_Dyn. */1244/* Legal values for d_tag field of Elf32_Dyn. */
1245 1245
1246#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */1246#define DT_MIPS_RLD_VERSION 0x70000001 /* Runtime linker interface version */
1247#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */1247#define DT_MIPS_TIME_STAMP 0x70000002 /* Timestamp */
1248#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */1248#define DT_MIPS_ICHECKSUM 0x70000003 /* Checksum */
1249#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */1249#define DT_MIPS_IVERSION 0x70000004 /* Version string (string tbl index) */
1250#define DT_MIPS_FLAGS 0x70000005 /* Flags */1250#define DT_MIPS_FLAGS 0x70000005 /* Flags */
1251#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */1251#define DT_MIPS_BASE_ADDRESS 0x70000006 /* Base address */
1252#define DT_MIPS_MSYM 0x700000071252#define DT_MIPS_MSYM 0x70000007
1253#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */1253#define DT_MIPS_CONFLICT 0x70000008 /* Address of CONFLICT section */
1254#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */1254#define DT_MIPS_LIBLIST 0x70000009 /* Address of LIBLIST section */
1255#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */1255#define DT_MIPS_LOCAL_GOTNO 0x7000000a /* Number of local GOT entries */
1256#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */1256#define DT_MIPS_CONFLICTNO 0x7000000b /* Number of CONFLICT entries */
1257#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */1257#define DT_MIPS_LIBLISTNO 0x70000010 /* Number of LIBLIST entries */
1258#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */1258#define DT_MIPS_SYMTABNO 0x70000011 /* Number of DYNSYM entries */
1259#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */1259#define DT_MIPS_UNREFEXTNO 0x70000012 /* First external DYNSYM */
1260#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */1260#define DT_MIPS_GOTSYM 0x70000013 /* First GOT entry in DYNSYM */
1261#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */1261#define DT_MIPS_HIPAGENO 0x70000014 /* Number of GOT page table entries */
1262#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */1262#define DT_MIPS_RLD_MAP 0x70000016 /* Address of run time loader map. */
1263#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */1263#define DT_MIPS_DELTA_CLASS 0x70000017 /* Delta C++ class definition. */
1264#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in1264#define DT_MIPS_DELTA_CLASS_NO 0x70000018 /* Number of entries in
1265 DT_MIPS_DELTA_CLASS. */1265 DT_MIPS_DELTA_CLASS. */
1266#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */1266#define DT_MIPS_DELTA_INSTANCE 0x70000019 /* Delta C++ class instances. */
1267#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in1267#define DT_MIPS_DELTA_INSTANCE_NO 0x7000001a /* Number of entries in
1268 DT_MIPS_DELTA_INSTANCE. */1268 DT_MIPS_DELTA_INSTANCE. */
1269#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */1269#define DT_MIPS_DELTA_RELOC 0x7000001b /* Delta relocations. */
1270#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in1270#define DT_MIPS_DELTA_RELOC_NO 0x7000001c /* Number of entries in
1271 DT_MIPS_DELTA_RELOC. */1271 DT_MIPS_DELTA_RELOC. */
1272#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta1272#define DT_MIPS_DELTA_SYM 0x7000001d /* Delta symbols that Delta
1273 relocations refer to. */1273 relocations refer to. */
1274#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in1274#define DT_MIPS_DELTA_SYM_NO 0x7000001e /* Number of entries in
1275 DT_MIPS_DELTA_SYM. */1275 DT_MIPS_DELTA_SYM. */
1276#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the1276#define DT_MIPS_DELTA_CLASSSYM 0x70000020 /* Delta symbols that hold the
1277 class declaration. */1277 class declaration. */
1278#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in1278#define DT_MIPS_DELTA_CLASSSYM_NO 0x70000021 /* Number of entries in
1279 DT_MIPS_DELTA_CLASSSYM. */1279 DT_MIPS_DELTA_CLASSSYM. */
1280#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */1280#define DT_MIPS_CXX_FLAGS 0x70000022 /* Flags indicating for C++ flavor. */
1281#define DT_MIPS_PIXIE_INIT 0x700000231281#define DT_MIPS_PIXIE_INIT 0x70000023
1282#define DT_MIPS_SYMBOL_LIB 0x700000241282#define DT_MIPS_SYMBOL_LIB 0x70000024
@@ -1284,68 +1284,68 @@ typedef struct · 1 unmodified line
1284#define DT_MIPS_LOCAL_GOTIDX 0x700000261284#define DT_MIPS_LOCAL_GOTIDX 0x70000026
1285#define DT_MIPS_HIDDEN_GOTIDX 0x700000271285#define DT_MIPS_HIDDEN_GOTIDX 0x70000027
1286#define DT_MIPS_PROTECTED_GOTIDX 0x700000281286#define DT_MIPS_PROTECTED_GOTIDX 0x70000028
1287#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */1287#define DT_MIPS_OPTIONS 0x70000029 /* Address of .options. */
1288#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */1288#define DT_MIPS_INTERFACE 0x7000002a /* Address of .interface. */
1289#define DT_MIPS_DYNSTR_ALIGN 0x7000002b1289#define DT_MIPS_DYNSTR_ALIGN 0x7000002b
1290#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */1290#define DT_MIPS_INTERFACE_SIZE 0x7000002c /* Size of the .interface section. */
1291#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve1291#define DT_MIPS_RLD_TEXT_RESOLVE_ADDR 0x7000002d /* Address of rld_text_rsolve
1292 function stored in GOT. */1292 function stored in GOT. */
1293#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added1293#define DT_MIPS_PERF_SUFFIX 0x7000002e /* Default suffix of dso to be added
1294 by rld on dlopen() calls. */1294 by rld on dlopen() calls. */
1295#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */1295#define DT_MIPS_COMPACT_SIZE 0x7000002f /* (O32)Size of compact rel section. */
1296#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */1296#define DT_MIPS_GP_VALUE 0x70000030 /* GP value for aux GOTs. */
1297#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */1297#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
1298#define DT_MIPS_NUM 0x321298#define DT_MIPS_NUM 0x32
1299 1299
1300/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */1300/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
1301 1301
1302#define RHF_NONE 0 /* No flags */1302#define RHF_NONE 0 /* No flags */
1303#define RHF_QUICKSTART (1 << 0) /* Use quickstart */1303#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
1304#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */1304#define RHF_NOTPOT (1 << 1) /* Hash size not power of 2 */
1305#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */1305#define RHF_NO_LIBRARY_REPLACEMENT (1 << 2) /* Ignore LD_LIBRARY_PATH */
1306#define RHF_NO_MOVE (1 << 3)1306#define RHF_NO_MOVE (1 << 3)
1307#define RHF_SGI_ONLY (1 << 4)1307#define RHF_SGI_ONLY (1 << 4)
1308#define RHF_GUARANTEE_INIT (1 << 5)1308#define RHF_GUARANTEE_INIT (1 << 5)
1309#define RHF_DELTA_C_PLUS_PLUS (1 << 6)1309#define RHF_DELTA_C_PLUS_PLUS (1 << 6)
1310#define RHF_GUARANTEE_START_INIT (1 << 7)1310#define RHF_GUARANTEE_START_INIT (1 << 7)
1311#define RHF_PIXIE (1 << 8)1311#define RHF_PIXIE (1 << 8)
1312#define RHF_DEFAULT_DELAY_LOAD (1 << 9)1312#define RHF_DEFAULT_DELAY_LOAD (1 << 9)
1313#define RHF_REQUICKSTART (1 << 10)1313#define RHF_REQUICKSTART (1 << 10)
1314#define RHF_REQUICKSTARTED (1 << 11)1314#define RHF_REQUICKSTARTED (1 << 11)
1315#define RHF_CORD (1 << 12)1315#define RHF_CORD (1 << 12)
1316#define RHF_NO_UNRES_UNDEF (1 << 13)1316#define RHF_NO_UNRES_UNDEF (1 << 13)
1317#define RHF_RLD_ORDER_SAFE (1 << 14)1317#define RHF_RLD_ORDER_SAFE (1 << 14)
1318 1318
1319/* Entries found in sections of type SHT_MIPS_LIBLIST. */1319/* Entries found in sections of type SHT_MIPS_LIBLIST. */
1320 1320
1321typedef struct1321typedef struct
1322{1322{
1323 Elf32_Word l_name; /* Name (string table index) */1323 Elf32_Word l_name; /* Name (string table index) */
1324 Elf32_Word l_time_stamp; /* Timestamp */1324 Elf32_Word l_time_stamp; /* Timestamp */
1325 Elf32_Word l_checksum; /* Checksum */1325 Elf32_Word l_checksum; /* Checksum */
1326 Elf32_Word l_version; /* Interface version */1326 Elf32_Word l_version; /* Interface version */
1327 Elf32_Word l_flags; /* Flags */1327 Elf32_Word l_flags; /* Flags */
1328} Elf32_Lib;1328} Elf32_Lib;
1329 1329
1330typedef struct1330typedef struct
1331{1331{
1332 Elf64_Word l_name; /* Name (string table index) */1332 Elf64_Word l_name; /* Name (string table index) */
1333 Elf64_Word l_time_stamp; /* Timestamp */1333 Elf64_Word l_time_stamp; /* Timestamp */
1334 Elf64_Word l_checksum; /* Checksum */1334 Elf64_Word l_checksum; /* Checksum */
1335 Elf64_Word l_version; /* Interface version */1335 Elf64_Word l_version; /* Interface version */
1336 Elf64_Word l_flags; /* Flags */1336 Elf64_Word l_flags; /* Flags */
1337} Elf64_Lib;1337} Elf64_Lib;
1338 1338
1339 1339
1340/* Legal values for l_flags. */1340/* Legal values for l_flags. */
1341 1341
1342#define LL_NONE 01342#define LL_NONE 0
1343#define LL_EXACT_MATCH (1 << 0) /* Require exact match */1343#define LL_EXACT_MATCH (1 << 0) /* Require exact match */
1344#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */1344#define LL_IGNORE_INT_VER (1 << 1) /* Ignore interface version */
1345#define LL_REQUIRE_MINOR (1 << 2)1345#define LL_REQUIRE_MINOR (1 << 2)
1346#define LL_EXPORTS (1 << 3)1346#define LL_EXPORTS (1 << 3)
1347#define LL_DELAY_LOAD (1 << 4)1347#define LL_DELAY_LOAD (1 << 4)
1348#define LL_DELTA (1 << 5)1348#define LL_DELTA (1 << 5)
1349 1349
1350/* Entries found in sections of type SHT_MIPS_CONFLICT. */1350/* Entries found in sections of type SHT_MIPS_CONFLICT. */
1351 1351
@@ -1356,193 +1356,193 @@ typedef Elf32_Addr Elf32_Conflict; · 4 unmodified lines
1356 1356
1357/* Legal values for e_flags field of Elf32_Ehdr. */1357/* Legal values for e_flags field of Elf32_Ehdr. */
1358 1358
1359#define EF_PARISC_TRAPNL 1 /* Trap nil pointer dereference. */1359#define EF_PARISC_TRAPNL 1 /* Trap nil pointer dereference. */
1360#define EF_PARISC_EXT 2 /* Program uses arch. extensions. */1360#define EF_PARISC_EXT 2 /* Program uses arch. extensions. */
1361#define EF_PARISC_ARCH 0xffff0000 /* Architecture version. */1361#define EF_PARISC_ARCH 0xffff0000 /* Architecture version. */
1362/* Defined values are:1362/* Defined values are:
1363 0x020b PA-RISC 1.0 big-endian1363 0x020b PA-RISC 1.0 big-endian
1364 0x0210 PA-RISC 1.1 big-endian1364 0x0210 PA-RISC 1.1 big-endian
1365 0x028b PA-RISC 1.0 little-endian1365 0x028b PA-RISC 1.0 little-endian
1366 0x0290 PA-RISC 1.1 little-endian1366 0x0290 PA-RISC 1.1 little-endian
1367*/1367*/
1368 1368
1369/* Legal values for sh_type field of Elf32_Shdr. */1369/* Legal values for sh_type field of Elf32_Shdr. */
1370 1370
1371#define SHT_PARISC_GOT 0x70000000 /* GOT for external data. */1371#define SHT_PARISC_GOT 0x70000000 /* GOT for external data. */
1372#define SHT_PARISC_ARCH 0x70000001 /* Architecture extensions. */1372#define SHT_PARISC_ARCH 0x70000001 /* Architecture extensions. */
1373#define SHT_PARISC_GLOBAL 0x70000002 /* Definition of $global$. */1373#define SHT_PARISC_GLOBAL 0x70000002 /* Definition of $global$. */
1374#define SHT_PARISC_MILLI 0x70000003 /* Millicode routines. */1374#define SHT_PARISC_MILLI 0x70000003 /* Millicode routines. */
1375#define SHT_PARISC_UNWIND 0x70000004 /* Unwind information. */1375#define SHT_PARISC_UNWIND 0x70000004 /* Unwind information. */
1376#define SHT_PARISC_PLT 0x70000005 /* Procedure linkage table. */1376#define SHT_PARISC_PLT 0x70000005 /* Procedure linkage table. */
1377#define SHT_PARISC_SDATA 0x70000006 /* Short initialized data. */1377#define SHT_PARISC_SDATA 0x70000006 /* Short initialized data. */
1378#define SHT_PARISC_SBSS 0x70000007 /* Short uninitialized data. */1378#define SHT_PARISC_SBSS 0x70000007 /* Short uninitialized data. */
1379#define SHT_PARISC_SYMEXTN 0x70000008 /* Argument/relocation info. */1379#define SHT_PARISC_SYMEXTN 0x70000008 /* Argument/relocation info. */
1380#define SHT_PARISC_STUBS 0x70000009 /* Linker stubs. */1380#define SHT_PARISC_STUBS 0x70000009 /* Linker stubs. */
1381 1381
1382/* Legal values for sh_flags field of Elf32_Shdr. */1382/* Legal values for sh_flags field of Elf32_Shdr. */
1383 1383
1384#define SHF_PARISC_GLOBAL 0x10000000 /* Section defines dp. */1384#define SHF_PARISC_GLOBAL 0x10000000 /* Section defines dp. */
1385#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */1385#define SHF_PARISC_SHORT 0x20000000 /* Section with short addressing. */
1386 1386
1387/* Legal values for ST_TYPE subfield of st_info (symbol type). */1387/* Legal values for ST_TYPE subfield of st_info (symbol type). */
1388 1388
1389#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */1389#define STT_PARISC_MILLICODE 13 /* Millicode function entry point. */
1390 1390
1391/* HPPA relocs. */1391/* HPPA relocs. */
1392 1392
1393#define R_PARISC_NONE 0 /* No reloc. */1393#define R_PARISC_NONE 0 /* No reloc. */
1394#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */1394#define R_PARISC_DIR32 1 /* Direct 32-bit reference. */
1395#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */1395#define R_PARISC_DIR21L 2 /* Left 21 bits of eff. address. */
1396#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */1396#define R_PARISC_DIR17R 3 /* Right 17 bits of eff. address. */
1397#define R_PARISC_DIR14R 4 /* Right 14 bits of eff. address. */1397#define R_PARISC_DIR14R 4 /* Right 14 bits of eff. address. */
1398#define R_PARISC_PCREL21L 5 /* PC-relative, left 21 bits. */1398#define R_PARISC_PCREL21L 5 /* PC-relative, left 21 bits. */
1399#define R_PARISC_PCREL14R 6 /* PC-relative, right 14 bits. */1399#define R_PARISC_PCREL14R 6 /* PC-relative, right 14 bits. */
1400#define R_PARISC_PCREL17C 7 /* Conditional PC-relative, ignore1400#define R_PARISC_PCREL17C 7 /* Conditional PC-relative, ignore
1401 if displacement > 17bits. */1401 if displacement > 17bits. */
1402#define R_PARISC_PCREL17F 8 /* Conditional PC-relative, must1402#define R_PARISC_PCREL17F 8 /* Conditional PC-relative, must
1403 fit in 17bits. */1403 fit in 17bits. */
1404#define R_PARISC_DPREL21L 9 /* DP-relative, left 21 bits. */1404#define R_PARISC_DPREL21L 9 /* DP-relative, left 21 bits. */
1405#define R_PARISC_DPREL14R 10 /* DP-relative, right 14 bits. */1405#define R_PARISC_DPREL14R 10 /* DP-relative, right 14 bits. */
1406#define R_PARISC_DPREL14F 11 /* DP-relative, must bit in 14 bits. */1406#define R_PARISC_DPREL14F 11 /* DP-relative, must bit in 14 bits. */
1407#define R_PARISC_DLTREL21L 12 /* DLT-relative, left 21 bits. */1407#define R_PARISC_DLTREL21L 12 /* DLT-relative, left 21 bits. */
1408#define R_PARISC_DLTREL14R 13 /* DLT-relative, right 14 bits. */1408#define R_PARISC_DLTREL14R 13 /* DLT-relative, right 14 bits. */
1409#define R_PARISC_DLTREL14F 14 /* DLT-relative, must fit in 14 bits.*/1409#define R_PARISC_DLTREL14F 14 /* DLT-relative, must fit in 14 bits.*/
1410#define R_PARISC_DLTIND21L 15 /* DLT-relative indirect, left1410#define R_PARISC_DLTIND21L 15 /* DLT-relative indirect, left
1411 21 bits. */1411 21 bits. */
1412#define R_PARISC_DLTIND14R 16 /* DLT-relative indirect, right1412#define R_PARISC_DLTIND14R 16 /* DLT-relative indirect, right
1413 14 bits. */1413 14 bits. */
1414#define R_PARISC_DLTIND14F 17 /* DLT-relative indirect, must fit1414#define R_PARISC_DLTIND14F 17 /* DLT-relative indirect, must fit
1415 int 14 bits. */1415 int 14 bits. */
1416#define R_PARISC_PLABEL32 18 /* Direct 32-bit reference to proc. */1416#define R_PARISC_PLABEL32 18 /* Direct 32-bit reference to proc. */
1417 1417
1418/* Alpha specific definitions. */1418/* Alpha specific definitions. */
1419 1419
1420/* Legal values for e_flags field of Elf64_Ehdr. */1420/* Legal values for e_flags field of Elf64_Ehdr. */
1421 1421
1422#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */1422#define EF_ALPHA_32BIT 1 /* All addresses must be < 2GB. */
1423#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */1423#define EF_ALPHA_CANRELAX 2 /* Relocations for relaxing exist. */
1424 1424
1425/* Legal values for sh_type field of Elf64_Shdr. */1425/* Legal values for sh_type field of Elf64_Shdr. */
1426 1426
1427/* These two are primerily concerned with ECOFF debugging info. */1427/* These two are primerily concerned with ECOFF debugging info. */
1428#define SHT_ALPHA_DEBUG 0x700000011428#define SHT_ALPHA_DEBUG 0x70000001
1429#define SHT_ALPHA_REGINFO 0x700000021429#define SHT_ALPHA_REGINFO 0x70000002
1430 1430
1431/* Legal values for sh_flags field of Elf64_Shdr. */1431/* Legal values for sh_flags field of Elf64_Shdr. */
1432 1432
1433#define SHF_ALPHA_GPREL 0x100000001433#define SHF_ALPHA_GPREL 0x10000000
1434 1434
1435/* Legal values for st_other field of Elf64_Sym. */1435/* Legal values for st_other field of Elf64_Sym. */
1436#define STO_ALPHA_NOPV 0x80 /* No PV required. */1436#define STO_ALPHA_NOPV 0x80 /* No PV required. */
1437#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */1437#define STO_ALPHA_STD_GPLOAD 0x88 /* PV only used for initial ldgp. */
1438 1438
1439/* Alpha relocs. */1439/* Alpha relocs. */
1440 1440
1441#define R_ALPHA_NONE 0 /* No reloc */1441#define R_ALPHA_NONE 0 /* No reloc */
1442#define R_ALPHA_REFLONG 1 /* Direct 32 bit */1442#define R_ALPHA_REFLONG 1 /* Direct 32 bit */
1443#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */1443#define R_ALPHA_REFQUAD 2 /* Direct 64 bit */
1444#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */1444#define R_ALPHA_GPREL32 3 /* GP relative 32 bit */
1445#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */1445#define R_ALPHA_LITERAL 4 /* GP relative 16 bit w/optimization */
1446#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */1446#define R_ALPHA_LITUSE 5 /* Optimization hint for LITERAL */
1447#define R_ALPHA_GPDISP 6 /* Add displacement to GP */1447#define R_ALPHA_GPDISP 6 /* Add displacement to GP */
1448#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */1448#define R_ALPHA_BRADDR 7 /* PC+4 relative 23 bit shifted */
1449#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */1449#define R_ALPHA_HINT 8 /* PC+4 relative 16 bit shifted */
1450#define R_ALPHA_SREL16 9 /* PC relative 16 bit */1450#define R_ALPHA_SREL16 9 /* PC relative 16 bit */
1451#define R_ALPHA_SREL32 10 /* PC relative 32 bit */1451#define R_ALPHA_SREL32 10 /* PC relative 32 bit */
1452#define R_ALPHA_SREL64 11 /* PC relative 64 bit */1452#define R_ALPHA_SREL64 11 /* PC relative 64 bit */
1453#define R_ALPHA_OP_PUSH 12 /* OP stack push */1453#define R_ALPHA_OP_PUSH 12 /* OP stack push */
1454#define R_ALPHA_OP_STORE 13 /* OP stack pop and store */1454#define R_ALPHA_OP_STORE 13 /* OP stack pop and store */
1455#define R_ALPHA_OP_PSUB 14 /* OP stack subtract */1455#define R_ALPHA_OP_PSUB 14 /* OP stack subtract */
1456#define R_ALPHA_OP_PRSHIFT 15 /* OP stack right shift */1456#define R_ALPHA_OP_PRSHIFT 15 /* OP stack right shift */
1457#define R_ALPHA_GPVALUE 161457#define R_ALPHA_GPVALUE 16
1458#define R_ALPHA_GPRELHIGH 171458#define R_ALPHA_GPRELHIGH 17
1459#define R_ALPHA_GPRELLOW 181459#define R_ALPHA_GPRELLOW 18
1460#define R_ALPHA_IMMED_GP_16 191460#define R_ALPHA_IMMED_GP_16 19
1461#define R_ALPHA_IMMED_GP_HI32 201461#define R_ALPHA_IMMED_GP_HI32 20
1462#define R_ALPHA_IMMED_SCN_HI32 211462#define R_ALPHA_IMMED_SCN_HI32 21
1463#define R_ALPHA_IMMED_BR_HI32 221463#define R_ALPHA_IMMED_BR_HI32 22
1464#define R_ALPHA_IMMED_LO32 231464#define R_ALPHA_IMMED_LO32 23
1465#define R_ALPHA_COPY 24 /* Copy symbol at runtime */1465#define R_ALPHA_COPY 24 /* Copy symbol at runtime */
1466#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */1466#define R_ALPHA_GLOB_DAT 25 /* Create GOT entry */
1467#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */1467#define R_ALPHA_JMP_SLOT 26 /* Create PLT entry */
1468#define R_ALPHA_RELATIVE 27 /* Adjust by program base */1468#define R_ALPHA_RELATIVE 27 /* Adjust by program base */
1469/* Keep this the last entry. */1469/* Keep this the last entry. */
1470#define R_ALPHA_NUM 281470#define R_ALPHA_NUM 28
1471 1471
1472 1472
1473/* PowerPC specific declarations */1473/* PowerPC specific declarations */
1474 1474
1475/* PowerPC relocations defined by the ABIs */1475/* PowerPC relocations defined by the ABIs */
1476#define R_PPC_NONE 01476#define R_PPC_NONE 0
1477#define R_PPC_ADDR32 1 /* 32bit absolute address */1477#define R_PPC_ADDR32 1 /* 32bit absolute address */
1478#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */1478#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
1479#define R_PPC_ADDR16 3 /* 16bit absolute address */1479#define R_PPC_ADDR16 3 /* 16bit absolute address */
1480#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */1480#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
1481#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */1481#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
1482#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */1482#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
1483#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */1483#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
1484#define R_PPC_ADDR14_BRTAKEN 81484#define R_PPC_ADDR14_BRTAKEN 8
1485#define R_PPC_ADDR14_BRNTAKEN 91485#define R_PPC_ADDR14_BRNTAKEN 9
1486#define R_PPC_REL24 10 /* PC relative 26 bit */1486#define R_PPC_REL24 10 /* PC relative 26 bit */
1487#define R_PPC_REL14 11 /* PC relative 16 bit */1487#define R_PPC_REL14 11 /* PC relative 16 bit */
1488#define R_PPC_REL14_BRTAKEN 121488#define R_PPC_REL14_BRTAKEN 12
1489#define R_PPC_REL14_BRNTAKEN 131489#define R_PPC_REL14_BRNTAKEN 13
1490#define R_PPC_GOT16 141490#define R_PPC_GOT16 14
1491#define R_PPC_GOT16_LO 151491#define R_PPC_GOT16_LO 15
1492#define R_PPC_GOT16_HI 161492#define R_PPC_GOT16_HI 16
1493#define R_PPC_GOT16_HA 171493#define R_PPC_GOT16_HA 17
1494#define R_PPC_PLTREL24 181494#define R_PPC_PLTREL24 18
1495#define R_PPC_COPY 191495#define R_PPC_COPY 19
1496#define R_PPC_GLOB_DAT 201496#define R_PPC_GLOB_DAT 20
1497#define R_PPC_JMP_SLOT 211497#define R_PPC_JMP_SLOT 21
1498#define R_PPC_RELATIVE 221498#define R_PPC_RELATIVE 22
1499#define R_PPC_LOCAL24PC 231499#define R_PPC_LOCAL24PC 23
1500#define R_PPC_UADDR32 241500#define R_PPC_UADDR32 24
1501#define R_PPC_UADDR16 251501#define R_PPC_UADDR16 25
1502#define R_PPC_REL32 261502#define R_PPC_REL32 26
1503#define R_PPC_PLT32 271503#define R_PPC_PLT32 27
1504#define R_PPC_PLTREL32 281504#define R_PPC_PLTREL32 28
1505#define R_PPC_PLT16_LO 291505#define R_PPC_PLT16_LO 29
1506#define R_PPC_PLT16_HI 301506#define R_PPC_PLT16_HI 30
1507#define R_PPC_PLT16_HA 311507#define R_PPC_PLT16_HA 31
1508#define R_PPC_SDAREL16 321508#define R_PPC_SDAREL16 32
1509#define R_PPC_SECTOFF 331509#define R_PPC_SECTOFF 33
1510#define R_PPC_SECTOFF_LO 341510#define R_PPC_SECTOFF_LO 34
1511#define R_PPC_SECTOFF_HI 351511#define R_PPC_SECTOFF_HI 35
1512#define R_PPC_SECTOFF_HA 361512#define R_PPC_SECTOFF_HA 36
1513/* Keep this the last entry. */1513/* Keep this the last entry. */
1514#define R_PPC_NUM 371514#define R_PPC_NUM 37
1515 1515
1516/* The remaining relocs are from the Embedded ELF ABI, and are not1516/* The remaining relocs are from the Embedded ELF ABI, and are not
1517 in the SVR4 ELF ABI. */1517 in the SVR4 ELF ABI. */
1518#define R_PPC_EMB_NADDR32 1011518#define R_PPC_EMB_NADDR32 101
1519#define R_PPC_EMB_NADDR16 1021519#define R_PPC_EMB_NADDR16 102
1520#define R_PPC_EMB_NADDR16_LO 1031520#define R_PPC_EMB_NADDR16_LO 103
1521#define R_PPC_EMB_NADDR16_HI 1041521#define R_PPC_EMB_NADDR16_HI 104
1522#define R_PPC_EMB_NADDR16_HA 1051522#define R_PPC_EMB_NADDR16_HA 105
1523#define R_PPC_EMB_SDAI16 1061523#define R_PPC_EMB_SDAI16 106
1524#define R_PPC_EMB_SDA2I16 1071524#define R_PPC_EMB_SDA2I16 107
1525#define R_PPC_EMB_SDA2REL 1081525#define R_PPC_EMB_SDA2REL 108
1526#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */1526#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */
1527#define R_PPC_EMB_MRKREF 1101527#define R_PPC_EMB_MRKREF 110
1528#define R_PPC_EMB_RELSEC16 1111528#define R_PPC_EMB_RELSEC16 111
1529#define R_PPC_EMB_RELST_LO 1121529#define R_PPC_EMB_RELST_LO 112
1530#define R_PPC_EMB_RELST_HI 1131530#define R_PPC_EMB_RELST_HI 113
1531#define R_PPC_EMB_RELST_HA 1141531#define R_PPC_EMB_RELST_HA 114
1532#define R_PPC_EMB_BIT_FLD 1151532#define R_PPC_EMB_BIT_FLD 115
1533#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */1533#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA */
1534 1534
1535/* Diab tool relocations. */1535/* Diab tool relocations. */
1536#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */1536#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */
1537#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */1537#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */
1538#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */1538#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */
1539#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */1539#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */
1540#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */1540#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */
1541#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */1541#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 */
1542 1542
1543/* This is a phony reloc to handle any old fashioned TOC16 references1543/* This is a phony reloc to handle any old fashioned TOC16 references
1544 that may still be in object files. */1544 that may still be in object files. */
1545#define R_PPC_TOC16 2551545#define R_PPC_TOC16 255
1546 1546
1547 1547
1548/* ARM specific declarations */1548/* ARM specific declarations */
@@ -1554,7 +1554,7 @@ typedef Elf32_Addr Elf32_Conflict; · 5 unmodified lines
1554#define EF_ARM_APCS_26 0x081554#define EF_ARM_APCS_26 0x08
1555#define EF_ARM_APCS_FLOAT 0x101555#define EF_ARM_APCS_FLOAT 0x10
1556#define EF_ARM_PIC 0x201556#define EF_ARM_PIC 0x20
1557#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */1557#define EF_ALIGN8 0x40 /* 8-bit structure alignment is in use */
1558#define EF_NEW_ABI 0x801558#define EF_NEW_ABI 0x80
1559#define EF_OLD_ABI 0x1001559#define EF_OLD_ABI 0x100
1560 1560
@@ -1564,70 +1564,70 @@ typedef Elf32_Addr Elf32_Conflict; · 3 unmodified lines
1564/* ARM-specific values for sh_flags */1564/* ARM-specific values for sh_flags */
1565#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */1565#define SHF_ARM_ENTRYSECT 0x10000000 /* Section contains an entry point */
1566#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined1566#define SHF_ARM_COMDEF 0x80000000 /* Section may be multiply defined
1567 in the input to a link step */1567 in the input to a link step */
1568 1568
1569/* ARM-specific program header flags */1569/* ARM-specific program header flags */
1570#define PF_ARM_SB 0x10000000 /* Segment contains the location1570#define PF_ARM_SB 0x10000000 /* Segment contains the location
1571 addressed by the static base */1571 addressed by the static base */
1572 1572
1573/* ARM relocs. */1573/* ARM relocs. */
1574#define R_ARM_NONE 0 /* No reloc */1574#define R_ARM_NONE 0 /* No reloc */
1575#define R_ARM_PC24 1 /* PC relative 26 bit branch */1575#define R_ARM_PC24 1 /* PC relative 26 bit branch */
1576#define R_ARM_ABS32 2 /* Direct 32 bit */1576#define R_ARM_ABS32 2 /* Direct 32 bit */
1577#define R_ARM_REL32 3 /* PC relative 32 bit */1577#define R_ARM_REL32 3 /* PC relative 32 bit */
1578#define R_ARM_PC13 41578#define R_ARM_PC13 4
1579#define R_ARM_ABS16 5 /* Direct 16 bit */1579#define R_ARM_ABS16 5 /* Direct 16 bit */
1580#define R_ARM_ABS12 6 /* Direct 12 bit */1580#define R_ARM_ABS12 6 /* Direct 12 bit */
1581#define R_ARM_THM_ABS5 71581#define R_ARM_THM_ABS5 7
1582#define R_ARM_ABS8 8 /* Direct 8 bit */1582#define R_ARM_ABS8 8 /* Direct 8 bit */
1583#define R_ARM_SBREL32 91583#define R_ARM_SBREL32 9
1584#define R_ARM_THM_PC22 101584#define R_ARM_THM_PC22 10
1585#define R_ARM_THM_PC8 111585#define R_ARM_THM_PC8 11
1586#define R_ARM_AMP_VCALL9 121586#define R_ARM_AMP_VCALL9 12
1587#define R_ARM_SWI24 131587#define R_ARM_SWI24 13
1588#define R_ARM_THM_SWI8 141588#define R_ARM_THM_SWI8 14
1589#define R_ARM_XPC25 151589#define R_ARM_XPC25 15
1590#define R_ARM_THM_XPC22 161590#define R_ARM_THM_XPC22 16
1591#define R_ARM_COPY 20 /* Copy symbol at runtime */1591#define R_ARM_COPY 20 /* Copy symbol at runtime */
1592#define R_ARM_GLOB_DAT 21 /* Create GOT entry */1592#define R_ARM_GLOB_DAT 21 /* Create GOT entry */
1593#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */1593#define R_ARM_JUMP_SLOT 22 /* Create PLT entry */
1594#define R_ARM_RELATIVE 23 /* Adjust by program base */1594#define R_ARM_RELATIVE 23 /* Adjust by program base */
1595#define R_ARM_GOTOFF32 24 /* 32 bit offset to GOT */1595#define R_ARM_GOTOFF32 24 /* 32 bit offset to GOT */
1596#define R_ARM_BASE_PREL 25 /* 32 bit PC relative offset to GOT */1596#define R_ARM_BASE_PREL 25 /* 32 bit PC relative offset to GOT */
1597#define R_ARM_GOT_BREL 26 /* 32 bit GOT entry */1597#define R_ARM_GOT_BREL 26 /* 32 bit GOT entry */
1598#define R_ARM_PLT32 27 /* 32 bit PLT address */1598#define R_ARM_PLT32 27 /* 32 bit PLT address */
1599#define R_ARM_CALL 281599#define R_ARM_CALL 28
1600#define R_ARM_JUMP24 291600#define R_ARM_JUMP24 29
1601#define R_ARM_PREL31 421601#define R_ARM_PREL31 42
1602#define R_ARM_GNU_VTENTRY 1001602#define R_ARM_GNU_VTENTRY 100
1603#define R_ARM_GNU_VTINHERIT 1011603#define R_ARM_GNU_VTINHERIT 101
1604#define R_ARM_THM_PC11 102 /* thumb unconditional branch */1604#define R_ARM_THM_PC11 102 /* thumb unconditional branch */
1605#define R_ARM_THM_PC9 103 /* thumb conditional branch */1605#define R_ARM_THM_PC9 103 /* thumb conditional branch */
1606#define R_ARM_RXPC25 2491606#define R_ARM_RXPC25 249
1607#define R_ARM_RSBREL32 2501607#define R_ARM_RSBREL32 250
1608#define R_ARM_THM_RPC22 2511608#define R_ARM_THM_RPC22 251
1609#define R_ARM_RREL32 2521609#define R_ARM_RREL32 252
1610#define R_ARM_RABS22 2531610#define R_ARM_RABS22 253
1611#define R_ARM_RPC24 2541611#define R_ARM_RPC24 254
1612#define R_ARM_RBASE 2551612#define R_ARM_RBASE 255
1613/* Keep this the last entry. */1613/* Keep this the last entry. */
1614#define R_ARM_NUM 2561614#define R_ARM_NUM 256
1615 1615
1616/* TMS320C67xx specific declarations */1616/* TMS320C67xx specific declarations */
1617/* XXX: no ELF standard yet */1617/* XXX: no ELF standard yet */
1618 1618
1619/* TMS320C67xx relocs. */1619/* TMS320C67xx relocs. */
1620#define R_C60_32 11620#define R_C60_32 1
1621#define R_C60_GOT32 3 /* 32 bit GOT entry */1621#define R_C60_GOT32 3 /* 32 bit GOT entry */
1622#define R_C60_PLT32 4 /* 32 bit PLT address */1622#define R_C60_PLT32 4 /* 32 bit PLT address */
1623#define R_C60_COPY 5 /* Copy symbol at runtime */1623#define R_C60_COPY 5 /* Copy symbol at runtime */
1624#define R_C60_GLOB_DAT 6 /* Create GOT entry */1624#define R_C60_GLOB_DAT 6 /* Create GOT entry */
1625#define R_C60_JMP_SLOT 7 /* Create PLT entry */1625#define R_C60_JMP_SLOT 7 /* Create PLT entry */
1626#define R_C60_RELATIVE 8 /* Adjust by program base */1626#define R_C60_RELATIVE 8 /* Adjust by program base */
1627#define R_C60_GOTOFF 9 /* 32 bit offset to GOT */1627#define R_C60_GOTOFF 9 /* 32 bit offset to GOT */
1628#define R_C60_GOTPC 10 /* 32 bit PC relative offset to GOT */1628#define R_C60_GOTPC 10 /* 32 bit PC relative offset to GOT */
1629 1629
1630#define R_C60HI16 0x55 // high 16 bit MVKH embedded1630#define R_C60HI16 0x55 // high 16 bit MVKH embedded
1631#define R_C60LO16 0x54 // low 16 bit MVKL embedded1631#define R_C60LO16 0x54 // low 16 bit MVKL embedded
1632 1632
1633#endif /* elf.h */1633#endif /* elf.h */
tcc.c+52−48
@@ -38,11 +38,11 @@ · 37 unmodified lines
38#include <fcntl.h>38#include <fcntl.h>
39#include <setjmp.h>39#include <setjmp.h>
40#include <time.h>40#include <time.h>
41#ifdef WIN3241#ifdef _WIN32
42#include <sys/timeb.h>42#include <sys/timeb.h>
43// #include <windows.h>43// #include <windows.h>
44#endif44#endif
45#ifndef WIN3245#ifndef _WIN32
46#include <sys/time.h>46#include <sys/time.h>
47#include <sys/ucontext.h>47#include <sys/ucontext.h>
48#include <sys/mman.h>48#include <sys/mman.h>
@@ -86,12 +86,12 @@ · 37 unmodified lines
86#define TCC_TARGET_I38686#define TCC_TARGET_I386
87#endif87#endif
88 88
89#if !defined(WIN32) && !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \89#if !defined(_WIN32) && !defined(TCC_UCLIBC) && !defined(TCC_TARGET_ARM) && \
90 !defined(TCC_TARGET_C67)90 !defined(TCC_TARGET_C67)
91#define CONFIG_TCC_BCHECK /* enable bound checking code */91#define CONFIG_TCC_BCHECK /* enable bound checking code */
92#endif92#endif
93 93
94#if defined(WIN32) && !defined(TCC_TARGET_PE)94#if defined(_WIN32) && !defined(TCC_TARGET_PE)
95#define CONFIG_TCC_STATIC95#define CONFIG_TCC_STATIC
96#endif96#endif
97 97
@@ -722,7 +722,7 @@ static const char tcc_keywords[] = · 624 unmodified lines
722 722
723#define TOK_UIDENT TOK_DEFINE723#define TOK_UIDENT TOK_DEFINE
724 724
725#ifdef WIN32725#ifdef _WIN32
726int __stdcall GetModuleFileNameA(void *, char *, int);726int __stdcall GetModuleFileNameA(void *, char *, int);
727void *__stdcall GetProcAddress(void *, const char *);727void *__stdcall GetProcAddress(void *, const char *);
728void *__stdcall GetModuleHandleA(const char *);728void *__stdcall GetModuleHandleA(const char *);
@@ -967,7 +967,7 @@ void *resolve_sym(TCCState *s1, const char *symbol, int type) · 238 unmodified lines
967 return NULL;967 return NULL;
968}968}
969 969
970#elif !defined(WIN32)970#elif !defined(_WIN32)
971 971
972#include <dlfcn.h>972#include <dlfcn.h>
973 973
@@ -1035,7 +1035,7 @@ static int strstart(const char *str, const char *val, const char **ptr) · 61 unmodified lines
1035 return 1;1035 return 1;
1036}1036}
1037 1037
1038#ifdef WIN321038#ifdef _WIN32
1039char *normalize_slashes(char *path)1039char *normalize_slashes(char *path)
1040{1040{
1041 char *p;1041 char *p;
@@ -1053,14 +1053,28 @@ char *w32_tcc_lib_path(void) · 11 unmodified lines
1053 GetModuleFileNameA(NULL, path, sizeof path);1053 GetModuleFileNameA(NULL, path, sizeof path);
1054 p = tcc_basename(normalize_slashes(strlwr(path)));1054 p = tcc_basename(normalize_slashes(strlwr(path)));
1055 if (p - 5 > path && 0 == strncmp(p - 5, "/bin/", 5))1055 if (p - 5 > path && 0 == strncmp(p - 5, "/bin/", 5))
1056 p -= 5;1056 p -= 5;
1057 else if (p > path)1057 else if (p > path)
1058 p--;1058 p--;
1059 *p = 0;1059 *p = 0;
1060 return strdup(path);1060 return strdup(path);
1061}1061}
1062#endif1062#endif
1063 1063
1064void set_pages_executable(void *ptr, unsigned long length)
1065{
1066#ifdef _WIN32
1067 unsigned long old_protect;
1068 VirtualProtect(ptr, length, PAGE_EXECUTE_READWRITE, &old_protect);
1069#else
1070 unsigned long start, end;
1071 start = (unsigned long)ptr & ~(PAGESIZE - 1);
1072 end = (unsigned long)ptr + length;
1073 end = (end + PAGESIZE - 1) & ~(PAGESIZE - 1);
1074 mprotect((void *)start, end - start, PROT_READ | PROT_WRITE | PROT_EXEC);
1075#endif
1076}
1077
1064/* memory management */1078/* memory management */
1065#ifdef MEM_DEBUG1079#ifdef MEM_DEBUG
1066int mem_cur_size;1080int mem_cur_size;
@@ -1887,7 +1901,9 @@ BufferedFile *tcc_open(TCCState *s1, const char *filename) · 820 unmodified lines
1887 bf->buf_end = bf->buffer;1901 bf->buf_end = bf->buffer;
1888 bf->buffer[0] = CH_EOB; /* put eob symbol */1902 bf->buffer[0] = CH_EOB; /* put eob symbol */
1889 pstrcpy(bf->filename, sizeof(bf->filename), filename);1903 pstrcpy(bf->filename, sizeof(bf->filename), filename);
1904#ifdef _WIN32
1890 normalize_slashes(bf->filename);1905 normalize_slashes(bf->filename);
1906#endif
1891 bf->line_num = 1;1907 bf->line_num = 1;
1892 bf->ifndef_macro = 0;1908 bf->ifndef_macro = 0;
1893 bf->ifdef_stack_ptr = s1->ifdef_stack_ptr;1909 bf->ifdef_stack_ptr = s1->ifdef_stack_ptr;
@@ -3566,16 +3582,16 @@ static inline void next_nomacro1(void) · 1672 unmodified lines
3566 {3582 {
3567 TCCState *s1 = tcc_state;3583 TCCState *s1 = tcc_state;
3568 if ((parse_flags & PARSE_FLAG_LINEFEED)3584 if ((parse_flags & PARSE_FLAG_LINEFEED)
3569 && !(tok_flags & TOK_FLAG_EOF)) {3585 && !(tok_flags & TOK_FLAG_EOF)) {
3570 tok_flags |= TOK_FLAG_EOF;3586 tok_flags |= TOK_FLAG_EOF;
3571 tok = TOK_LINEFEED;3587 tok = TOK_LINEFEED;
3572 goto keep_tok_flags;3588 goto keep_tok_flags;
3573 } else if (s1->include_stack_ptr == s1->include_stack ||3589 } else if (s1->include_stack_ptr == s1->include_stack ||
3574 !(parse_flags & PARSE_FLAG_PREPROCESS)) {3590 !(parse_flags & PARSE_FLAG_PREPROCESS)) {
3575 /* no include left : end of file. */3591 /* no include left : end of file. */
3576 tok = TOK_EOF;3592 tok = TOK_EOF;
3577 } else {3593 } else {
3578 tok_flags &= ~TOK_FLAG_EOF;3594 tok_flags &= ~TOK_FLAG_EOF;
3579 /* pop include file */3595 /* pop include file */
3580 3596
3581 /* test if previous '#endif' was after a #ifdef at3597 /* test if previous '#endif' was after a #ifdef at
@@ -3603,13 +3619,13 @@ static inline void next_nomacro1(void) · 21 unmodified lines
3603 break;3619 break;
3604 3620
3605 case '\n':3621 case '\n':
3606 file->line_num++;3622 file->line_num++;
3607 tok_flags |= TOK_FLAG_BOL;3623 tok_flags |= TOK_FLAG_BOL;
3608 p++;3624 p++;
3609 if (0 == (parse_flags & PARSE_FLAG_LINEFEED))3625 if (0 == (parse_flags & PARSE_FLAG_LINEFEED))
3610 goto redo_no_start;3626 goto redo_no_start;
3611 tok = TOK_LINEFEED;3627 tok = TOK_LINEFEED;
3612 goto keep_tok_flags;3628 goto keep_tok_flags;
3613 3629
3614 case '#':3630 case '#':
3615 /* XXX: simplify */3631 /* XXX: simplify */
@@ -4168,8 +4184,8 @@ static int macro_subst_tok(TokenString *tok_str, · 552 unmodified lines
4168 parlevel++;4184 parlevel++;
4169 else if (tok == ')')4185 else if (tok == ')')
4170 parlevel--;4186 parlevel--;
4171 if (tok != TOK_LINEFEED)4187 if (tok != TOK_LINEFEED)
4172 tok_str_add2(&str, tok, &tokc);4188 tok_str_add2(&str, tok, &tokc);
4173 next_nomacro();4189 next_nomacro();
4174 }4190 }
4175 tok_str_add(&str, 0);4191 tok_str_add(&str, 0);
@@ -9388,6 +9404,9 @@ static int tcc_compile(TCCState *s1) · 5212 unmodified lines
9388 ELF32_ST_INFO(STB_LOCAL, STT_SECTION), 0, 9404 ELF32_ST_INFO(STB_LOCAL, STT_SECTION), 0,
9389 text_section->sh_num, NULL);9405 text_section->sh_num, NULL);
9390 getcwd(buf, sizeof(buf));9406 getcwd(buf, sizeof(buf));
9407#ifdef _WIN32
9408 normalize_slashes(buf);
9409#endif
9391 pstrcat(buf, sizeof(buf), "/");9410 pstrcat(buf, sizeof(buf), "/");
9392 put_stabs_r(buf, N_SO, 0, 0, 9411 put_stabs_r(buf, N_SO, 0, 0,
9393 text_section->data_offset, text_section, section_sym);9412 text_section->data_offset, text_section, section_sym);
@@ -9489,9 +9508,9 @@ static int tcc_preprocess(TCCState *s1) · 95 unmodified lines
9489 break;9508 break;
9490 } else if (tok == TOK_LINEFEED) {9509 } else if (tok == TOK_LINEFEED) {
9491 last_is_space = 1;9510 last_is_space = 1;
9492 } else {9511 } else {
9493 if (!last_is_space)9512 if (!last_is_space)
9494 fputc(' ', s1->outfile);9513 fputc(' ', s1->outfile);
9495 last_is_space = 0;9514 last_is_space = 0;
9496 }9515 }
9497 fputs(get_tok_str(tok, &tokc), s1->outfile);9516 fputs(get_tok_str(tok, &tokc), s1->outfile);
@@ -9724,7 +9743,7 @@ static void rt_printline(unsigned long wanted_pc) · 226 unmodified lines
9724 fprintf(stderr, "\n");9743 fprintf(stderr, "\n");
9725}9744}
9726 9745
9727#if !defined(WIN32) && !defined(CONFIG_TCCBOOT)9746#if !defined(_WIN32) && !defined(CONFIG_TCCBOOT)
9728 9747
9729#ifdef __i386__9748#ifdef __i386__
9730 9749
@@ -9888,24 +9907,8 @@ int tcc_relocate(TCCState *s1) · 157 unmodified lines
9888 for(i = 1; i < s1->nb_sections; i++) {9907 for(i = 1; i < s1->nb_sections; i++) {
9889 s = s1->sections[i];9908 s = s1->sections[i];
9890 if ((s->sh_flags & (SHF_ALLOC | SHF_EXECINSTR)) == 9909 if ((s->sh_flags & (SHF_ALLOC | SHF_EXECINSTR)) ==
9891 (SHF_ALLOC | SHF_EXECINSTR)) {9910 (SHF_ALLOC | SHF_EXECINSTR))
9892#ifdef WIN329911 set_pages_executable(s->data, s->data_offset);
9893 {
9894 unsigned long old_protect;
9895 VirtualProtect(s->data, s->data_offset,
9896 PAGE_EXECUTE_READWRITE, &old_protect);
9897 }
9898#else
9899 {
9900 unsigned long start, end;
9901 start = (unsigned long)(s->data) & ~(PAGESIZE - 1);
9902 end = (unsigned long)(s->data + s->data_offset);
9903 end = (end + PAGESIZE - 1) & ~(PAGESIZE - 1);
9904 mprotect((void *)start, end - start,
9905 PROT_READ | PROT_WRITE | PROT_EXEC);
9906 }
9907#endif
9908 }
9909 }9912 }
9910 return 0;9913 return 0;
9911}9914}
@@ -9921,7 +9924,7 @@ int tcc_run(TCCState *s1, int argc, char **argv) · 9 unmodified lines
9921 prog_main = tcc_get_symbol_err(s1, "main");9924 prog_main = tcc_get_symbol_err(s1, "main");
9922 9925
9923 if (do_debug) {9926 if (do_debug) {
9924#if defined(WIN32) || defined(CONFIG_TCCBOOT)9927#if defined(_WIN32) || defined(CONFIG_TCCBOOT)
9925 error("debug mode currently not available for Windows");9928 error("debug mode currently not available for Windows");
9926#else 9929#else
9927 struct sigaction sigact;9930 struct sigaction sigact;
@@ -10022,6 +10025,7 @@ TCCState *tcc_new(void) · 94 unmodified lines
10022 tcc_define_symbol(s, "__PTRDIFF_TYPE__", "int");10025 tcc_define_symbol(s, "__PTRDIFF_TYPE__", "int");
10023#ifdef TCC_TARGET_PE10026#ifdef TCC_TARGET_PE
10024 tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");10027 tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");
10028 tcc_define_symbol(s, "_WIN32", NULL);
10025#else10029#else
10026 tcc_define_symbol(s, "__WCHAR_TYPE__", "int");10030 tcc_define_symbol(s, "__WCHAR_TYPE__", "int");
10027#endif10031#endif
@@ -10461,7 +10465,7 @@ static char *tcc_basename(const char *name) · 433 unmodified lines
10461 char *p = strchr(name, 0);10465 char *p = strchr(name, 0);
10462 while (p > name10466 while (p > name
10463 && p[-1] != '/'10467 && p[-1] != '/'
10464#ifdef WIN3210468#ifdef _WIN32
10465 && p[-1] != '\\'10469 && p[-1] != '\\'
10466#endif10470#endif
10467 )10471 )
@@ -10473,7 +10477,7 @@ static char *tcc_basename(const char *name) · 5 unmodified lines
10473 10477
10474static int64_t getclock_us(void)10478static int64_t getclock_us(void)
10475{10479{
10476#ifdef WIN3210480#ifdef _WIN32
10477 struct _timeb tb;10481 struct _timeb tb;
10478 _ftime(&tb);10482 _ftime(&tb);
10479 return (tb.time * 1000LL + tb.millitm) * 1000LL;10483 return (tb.time * 1000LL + tb.millitm) * 1000LL;
@@ -10849,7 +10853,7 @@ int main(int argc, char **argv) · 369 unmodified lines
10849 char objfilename[1024];10853 char objfilename[1024];
10850 int64_t start_time = 0;10854 int64_t start_time = 0;
10851 10855
10852#ifdef WIN3210856#ifdef _WIN32
10853 tcc_lib_path = w32_tcc_lib_path();10857 tcc_lib_path = w32_tcc_lib_path();
10854#endif10858#endif
10855 10859
@@ -10898,7 +10902,7 @@ int main(int argc, char **argv) · 42 unmodified lines
10898 }10902 }
10899 } else if (output_type != TCC_OUTPUT_MEMORY) {10903 } else if (output_type != TCC_OUTPUT_MEMORY) {
10900 if (!outfile) {10904 if (!outfile) {
10901 /* compute default outfile name */10905 /* compute default outfile name */
10902 pstrcpy(objfilename, sizeof(objfilename) - 1, 10906 pstrcpy(objfilename, sizeof(objfilename) - 1,
10903 /* strip path */10907 /* strip path */
10904 tcc_basename(files[0]));10908 tcc_basename(files[0]));
@@ -10907,10 +10911,10 @@ int main(int argc, char **argv) · 2 unmodified lines
10907#else10911#else
10908 if (output_type == TCC_OUTPUT_OBJ && !reloc_output) {10912 if (output_type == TCC_OUTPUT_OBJ && !reloc_output) {
10909 char *ext = strrchr(objfilename, '.');10913 char *ext = strrchr(objfilename, '.');
10910 if (!ext)10914 if (!ext)
10911 goto default_outfile;10915 goto default_outfile;
10912 /* add .o extension */10916 /* add .o extension */
10913 strcpy(ext + 1, "o");10917 strcpy(ext + 1, "o");
10914 } else {10918 } else {
10915 default_outfile:10919 default_outfile:
10916 pstrcpy(objfilename, sizeof(objfilename), "a.out");10920 pstrcpy(objfilename, sizeof(objfilename), "a.out");
tccpe.c+523−523
@@ -28,31 +28,31 @@ int verbose = 0; · 27 unmodified lines
28 28
29/* definitions below are from winnt.h */29/* definitions below are from winnt.h */
30 30
31typedef struct _IMAGE_DOS_HEADER { /* DOS .EXE header */31typedef struct _IMAGE_DOS_HEADER { /* DOS .EXE header */
32 WORD e_magic; /* Magic number */32 WORD e_magic; /* Magic number */
33 WORD e_cblp; /* Bytes on last page of file */33 WORD e_cblp; /* Bytes on last page of file */
34 WORD e_cp; /* Pages in file */34 WORD e_cp; /* Pages in file */
35 WORD e_crlc; /* Relocations */35 WORD e_crlc; /* Relocations */
36 WORD e_cparhdr; /* Size of header in paragraphs */36 WORD e_cparhdr; /* Size of header in paragraphs */
37 WORD e_minalloc; /* Minimum extra paragraphs needed */37 WORD e_minalloc; /* Minimum extra paragraphs needed */
38 WORD e_maxalloc; /* Maximum extra paragraphs needed */38 WORD e_maxalloc; /* Maximum extra paragraphs needed */
39 WORD e_ss; /* Initial (relative) SS value */39 WORD e_ss; /* Initial (relative) SS value */
40 WORD e_sp; /* Initial SP value */40 WORD e_sp; /* Initial SP value */
41 WORD e_csum; /* Checksum */41 WORD e_csum; /* Checksum */
42 WORD e_ip; /* Initial IP value */42 WORD e_ip; /* Initial IP value */
43 WORD e_cs; /* Initial (relative) CS value */43 WORD e_cs; /* Initial (relative) CS value */
44 WORD e_lfarlc; /* File address of relocation table */44 WORD e_lfarlc; /* File address of relocation table */
45 WORD e_ovno; /* Overlay number */45 WORD e_ovno; /* Overlay number */
46 WORD e_res[4]; /* Reserved words */46 WORD e_res[4]; /* Reserved words */
47 WORD e_oemid; /* OEM identifier (for e_oeminfo) */47 WORD e_oemid; /* OEM identifier (for e_oeminfo) */
48 WORD e_oeminfo; /* OEM information; e_oemid specific */48 WORD e_oeminfo; /* OEM information; e_oemid specific */
49 WORD e_res2[10]; /* Reserved words */49 WORD e_res2[10]; /* Reserved words */
50 DWORD e_lfanew; /* File address of new exe header */50 DWORD e_lfanew; /* File address of new exe header */
51 BYTE e_code[0x40];51 BYTE e_code[0x40];
52 52
53} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;53} IMAGE_DOS_HEADER, *PIMAGE_DOS_HEADER;
54 54
55#define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */55#define IMAGE_NT_SIGNATURE 0x00004550 /* PE00 */
56#define SIZE_OF_NT_SIGNATURE 456#define SIZE_OF_NT_SIGNATURE 4
57 57
58typedef struct _IMAGE_FILE_HEADER {58typedef struct _IMAGE_FILE_HEADER {
@@ -113,22 +113,22 @@ typedef struct _IMAGE_OPTIONAL_HEADER { · 54 unmodified lines
113} IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;113} IMAGE_OPTIONAL_HEADER32, *PIMAGE_OPTIONAL_HEADER32;
114 114
115 115
116#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 /* Export Directory */116#define IMAGE_DIRECTORY_ENTRY_EXPORT 0 /* Export Directory */
117#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 /* Import Directory */117#define IMAGE_DIRECTORY_ENTRY_IMPORT 1 /* Import Directory */
118#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 /* Resource Directory */118#define IMAGE_DIRECTORY_ENTRY_RESOURCE 2 /* Resource Directory */
119#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 /* Exception Directory */119#define IMAGE_DIRECTORY_ENTRY_EXCEPTION 3 /* Exception Directory */
120#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 /* Security Directory */120#define IMAGE_DIRECTORY_ENTRY_SECURITY 4 /* Security Directory */
121#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 /* Base Relocation Table */121#define IMAGE_DIRECTORY_ENTRY_BASERELOC 5 /* Base Relocation Table */
122#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 /* Debug Directory */122#define IMAGE_DIRECTORY_ENTRY_DEBUG 6 /* Debug Directory */
123/* IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 (X86 usage) */123/* IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7 (X86 usage) */
124#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 7 /* Architecture Specific Data */124#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE 7 /* Architecture Specific Data */
125#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* RVA of GP */125#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8 /* RVA of GP */
126#define IMAGE_DIRECTORY_ENTRY_TLS 9 /* TLS Directory */126#define IMAGE_DIRECTORY_ENTRY_TLS 9 /* TLS Directory */
127#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 /* Load Configuration Directory */127#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10 /* Load Configuration Directory */
128#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 /* Bound Import Directory in headers */128#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT 11 /* Bound Import Directory in headers */
129#define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */129#define IMAGE_DIRECTORY_ENTRY_IAT 12 /* Import Address Table */
130#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13 /* Delay Load Import Descriptors */130#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT 13 /* Delay Load Import Descriptors */
131#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14 /* COM Runtime descriptor */131#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR 14 /* COM Runtime descriptor */
132 132
133/* Section header format. */133/* Section header format. */
134#define IMAGE_SIZEOF_SHORT_NAME 8134#define IMAGE_SIZEOF_SHORT_NAME 8
@@ -136,8 +136,8 @@ typedef struct _IMAGE_OPTIONAL_HEADER { · 1 unmodified line
136typedef struct _IMAGE_SECTION_HEADER {136typedef struct _IMAGE_SECTION_HEADER {
137 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];137 BYTE Name[IMAGE_SIZEOF_SHORT_NAME];
138 union {138 union {
139 DWORD PhysicalAddress;139 DWORD PhysicalAddress;
140 DWORD VirtualSize;140 DWORD VirtualSize;
141 } Misc;141 } Misc;
142 DWORD VirtualAddress;142 DWORD VirtualAddress;
143 DWORD SizeOfRawData;143 DWORD SizeOfRawData;
@@ -173,28 +173,28 @@ typedef struct _IMAGE_BASE_RELOCATION { · 29 unmodified lines
173 173
174/* ----------------------------------------------------------- */174/* ----------------------------------------------------------- */
175IMAGE_DOS_HEADER pe_dos_hdr = {175IMAGE_DOS_HEADER pe_dos_hdr = {
176 0x5A4D, /*WORD e_magic; Magic number */176 0x5A4D, /*WORD e_magic; Magic number */
177 0x0090, /*WORD e_cblp; Bytes on last page of file */177 0x0090, /*WORD e_cblp; Bytes on last page of file */
178 0x0003, /*WORD e_cp; Pages in file */178 0x0003, /*WORD e_cp; Pages in file */
179 0x0000, /*WORD e_crlc; Relocations */179 0x0000, /*WORD e_crlc; Relocations */
180 180
181 0x0004, /*WORD e_cparhdr; Size of header in paragraphs */181 0x0004, /*WORD e_cparhdr; Size of header in paragraphs */
182 0x0000, /*WORD e_minalloc; Minimum extra paragraphs needed */182 0x0000, /*WORD e_minalloc; Minimum extra paragraphs needed */
183 0xFFFF, /*WORD e_maxalloc; Maximum extra paragraphs needed */183 0xFFFF, /*WORD e_maxalloc; Maximum extra paragraphs needed */
184 0x0000, /*WORD e_ss; Initial (relative) SS value */184 0x0000, /*WORD e_ss; Initial (relative) SS value */
185 185
186 0x00B8, /*WORD e_sp; Initial SP value */186 0x00B8, /*WORD e_sp; Initial SP value */
187 0x0000, /*WORD e_csum; Checksum */187 0x0000, /*WORD e_csum; Checksum */
188 0x0000, /*WORD e_ip; Initial IP value */188 0x0000, /*WORD e_ip; Initial IP value */
189 0x0000, /*WORD e_cs; Initial (relative) CS value */189 0x0000, /*WORD e_cs; Initial (relative) CS value */
190 0x0040, /*WORD e_lfarlc; File address of relocation table */190 0x0040, /*WORD e_lfarlc; File address of relocation table */
191 0x0000, /*WORD e_ovno; Overlay number */191 0x0000, /*WORD e_ovno; Overlay number */
192 {0, 0, 0, 0}, /*WORD e_res[4]; Reserved words */192 {0, 0, 0, 0}, /*WORD e_res[4]; Reserved words */
193 0x0000, /*WORD e_oemid; OEM identifier (for e_oeminfo) */193 0x0000, /*WORD e_oemid; OEM identifier (for e_oeminfo) */
194 0x0000, /*WORD e_oeminfo; OEM information; e_oemid specific */194 0x0000, /*WORD e_oeminfo; OEM information; e_oemid specific */
195 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /*WORD e_res2[10]; Reserved words */195 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /*WORD e_res2[10]; Reserved words */
196 0x00000080, /*DWORD e_lfanew; File address of new exe header */196 0x00000080, /*DWORD e_lfanew; File address of new exe header */
197 { /* 14 code bytes + "This program cannot be run in DOS mode.\r\r\n$" + 6 * 0x00 */197 { /* 14 code bytes + "This program cannot be run in DOS mode.\r\r\n$" + 6 * 0x00 */
198 /*0040 */ 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, 0x21, 0xb8,198 /*0040 */ 0x0e, 0x1f, 0xba, 0x0e, 0x00, 0xb4, 0x09, 0xcd, 0x21, 0xb8,
199 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68,199 0x01, 0x4c, 0xcd, 0x21, 0x54, 0x68,
200 /*0050 */ 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d,200 /*0050 */ 0x69, 0x73, 0x20, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x61, 0x6d,
@@ -210,49 +210,49 @@ IMAGE_DOS_HEADER pe_dos_hdr = { · 9 unmodified lines
210DWORD pe_magic = IMAGE_NT_SIGNATURE;210DWORD pe_magic = IMAGE_NT_SIGNATURE;
211 211
212IMAGE_FILE_HEADER pe_file_hdr = {212IMAGE_FILE_HEADER pe_file_hdr = {
213 0x014C, /*WORD Machine; */213 0x014C, /*WORD Machine; */
214 0x0003, /*WORD NumberOfSections; */214 0x0003, /*WORD NumberOfSections; */
215 0x00000000, /*DWORD TimeDateStamp; */215 0x00000000, /*DWORD TimeDateStamp; */
216 0x00000000, /*DWORD PointerToSymbolTable; */216 0x00000000, /*DWORD PointerToSymbolTable; */
217 0x00000000, /*DWORD NumberOfSymbols; */217 0x00000000, /*DWORD NumberOfSymbols; */
218 0x00E0, /*WORD SizeOfOptionalHeader; */218 0x00E0, /*WORD SizeOfOptionalHeader; */
219 0x030F /*WORD Characteristics; */219 0x030F /*WORD Characteristics; */
220};220};
221 221
222IMAGE_OPTIONAL_HEADER32 pe_opt_hdr = {222IMAGE_OPTIONAL_HEADER32 pe_opt_hdr = {
223 /* Standard fields. */223 /* Standard fields. */
224 0x010B, /*WORD Magic; */224 0x010B, /*WORD Magic; */
225 0x06, /*BYTE MajorLinkerVersion; */225 0x06, /*BYTE MajorLinkerVersion; */
226 0x00, /*BYTE MinorLinkerVersion; */226 0x00, /*BYTE MinorLinkerVersion; */
227 0x00000000, /*DWORD SizeOfCode; */227 0x00000000, /*DWORD SizeOfCode; */
228 0x00000000, /*DWORD SizeOfInitializedData; */228 0x00000000, /*DWORD SizeOfInitializedData; */
229 0x00000000, /*DWORD SizeOfUninitializedData; */229 0x00000000, /*DWORD SizeOfUninitializedData; */
230 0x00000000, /*DWORD AddressOfEntryPoint; */230 0x00000000, /*DWORD AddressOfEntryPoint; */
231 0x00000000, /*DWORD BaseOfCode; */231 0x00000000, /*DWORD BaseOfCode; */
232 0x00000000, /*DWORD BaseOfData; */232 0x00000000, /*DWORD BaseOfData; */
233 233
234 /* NT additional fields. */234 /* NT additional fields. */
235 0x00400000, /*DWORD ImageBase; */235 0x00400000, /*DWORD ImageBase; */
236 0x00001000, /*DWORD SectionAlignment; */236 0x00001000, /*DWORD SectionAlignment; */
237 0x00000200, /*DWORD FileAlignment; */237 0x00000200, /*DWORD FileAlignment; */
238 0x0004, /*WORD MajorOperatingSystemVersion; */238 0x0004, /*WORD MajorOperatingSystemVersion; */
239 0x0000, /*WORD MinorOperatingSystemVersion; */239 0x0000, /*WORD MinorOperatingSystemVersion; */
240 0x0000, /*WORD MajorImageVersion; */240 0x0000, /*WORD MajorImageVersion; */
241 0x0000, /*WORD MinorImageVersion; */241 0x0000, /*WORD MinorImageVersion; */
242 0x0004, /*WORD MajorSubsystemVersion; */242 0x0004, /*WORD MajorSubsystemVersion; */
243 0x0000, /*WORD MinorSubsystemVersion; */243 0x0000, /*WORD MinorSubsystemVersion; */
244 0x00000000, /*DWORD Win32VersionValue; */244 0x00000000, /*DWORD Win32VersionValue; */
245 0x00000000, /*DWORD SizeOfImage; */245 0x00000000, /*DWORD SizeOfImage; */
246 0x00000200, /*DWORD SizeOfHeaders; */246 0x00000200, /*DWORD SizeOfHeaders; */
247 0x00000000, /*DWORD CheckSum; */247 0x00000000, /*DWORD CheckSum; */
248 0x0002, /*WORD Subsystem; */248 0x0002, /*WORD Subsystem; */
249 0x0000, /*WORD DllCharacteristics; */249 0x0000, /*WORD DllCharacteristics; */
250 0x00100000, /*DWORD SizeOfStackReserve; */250 0x00100000, /*DWORD SizeOfStackReserve; */
251 0x00001000, /*DWORD SizeOfStackCommit; */251 0x00001000, /*DWORD SizeOfStackCommit; */
252 0x00100000, /*DWORD SizeOfHeapReserve; */252 0x00100000, /*DWORD SizeOfHeapReserve; */
253 0x00001000, /*DWORD SizeOfHeapCommit; */253 0x00001000, /*DWORD SizeOfHeapCommit; */
254 0x00000000, /*DWORD LoaderFlags; */254 0x00000000, /*DWORD LoaderFlags; */
255 0x00000010, /*DWORD NumberOfRvaAndSizes; */255 0x00000010, /*DWORD NumberOfRvaAndSizes; */
256 256
257 /* IMAGE_DATA_DIRECTORY DataDirectory[16]; */257 /* IMAGE_DATA_DIRECTORY DataDirectory[16]; */
258 {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},258 {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},
@@ -314,13 +314,13 @@ enum { · 55 unmodified lines
314};314};
315 315
316ST DWORD pe_flags[] = {316ST DWORD pe_flags[] = {
317 0x60000020, /* ".text", */317 0x60000020, /* ".text", */
318 0xC0000040, /* ".data", */318 0xC0000040, /* ".data", */
319 0xC0000080, /* ".bss", */319 0xC0000080, /* ".bss", */
320 0x40000040, /* ".rsrc", */320 0x40000040, /* ".rsrc", */
321 0x42000040, /* ".reloc", */321 0x42000040, /* ".reloc", */
322 0x42000802, /* ".stab", */322 0x42000802, /* ".stab", */
323 0x42000802 /* ".stabstr", */323 0x42000802 /* ".stabstr", */
324};324};
325 325
326struct section_info {326struct section_info {
@@ -384,20 +384,20 @@ ST int pe_find_import(TCCState * s1, const char *symbol, char *ret) · 57 unmodified lines
384{384{
385 int sym_index = find_elf_sym(s1->dynsymtab_section, symbol);385 int sym_index = find_elf_sym(s1->dynsymtab_section, symbol);
386 if (0 == sym_index) {386 if (0 == sym_index) {
387 /* Hm, maybe it's '_symbol' instead of 'symbol' or '__imp__symbol' */387 /* Hm, maybe it's '_symbol' instead of 'symbol' or '__imp__symbol' */
388 char buffer[100];388 char buffer[100];
389 if (0 == memcmp(symbol, "__imp__", 7))389 if (0 == memcmp(symbol, "__imp__", 7))
390 symbol += 6;390 symbol += 6;
391 else391 else
392 buffer[0] = '_', strcpy(buffer + 1, symbol), symbol = buffer;392 buffer[0] = '_', strcpy(buffer + 1, symbol), symbol = buffer;
393 sym_index = find_elf_sym(s1->dynsymtab_section, symbol);393 sym_index = find_elf_sym(s1->dynsymtab_section, symbol);
394 }394 }
395 if (ret)395 if (ret)
396 strcpy(ret, symbol);396 strcpy(ret, symbol);
397 return sym_index;397 return sym_index;
398}398}
399 399
400#ifdef WIN32400#ifdef _WIN32
401ST void **pe_imp;401ST void **pe_imp;
402ST int nb_pe_imp;402ST int nb_pe_imp;
403 403
@@ -411,10 +411,10 @@ void *resolve_sym(struct TCCState *s1, const char *symbol, int type) · 7 unmodified lines
411 void *hm;411 void *hm;
412 412
413 if (sym_index) {413 if (sym_index) {
414 dll_index = ((Elf32_Sym *) s1->dynsymtab_section->data)[sym_index].414 dll_index = ((Elf32_Sym *) s1->dynsymtab_section->data)[sym_index].
415 st_other;415 st_other;
416 dll_name = s1->loaded_dlls[dll_index]->name;416 dll_name = s1->loaded_dlls[dll_index]->name;
417 hm = GetModuleHandleA(dll_name);417 hm = GetModuleHandleA(dll_name);
418 if (NULL == hm)418 if (NULL == hm)
419 hm = LoadLibraryA(dll_name);419 hm = LoadLibraryA(dll_name);
420 if (hm) {420 if (hm) {
@@ -432,20 +432,20 @@ void *resolve_sym(struct TCCState *s1, const char *symbol, int type) · 11 unmodified lines
432 432
433#define for_sym_in_symtab(sym) \433#define for_sym_in_symtab(sym) \
434for (sym = (Elf32_Sym *)symtab_section->data + 1; \434for (sym = (Elf32_Sym *)symtab_section->data + 1; \
435 sym < (Elf32_Sym *)(symtab_section->data + \435 sym < (Elf32_Sym *)(symtab_section->data + \
436 symtab_section->data_offset); \436 symtab_section->data_offset); \
437 ++sym)437 ++sym)
438 438
439#define pe_set_datadir(dir,addr,size) \439#define pe_set_datadir(dir,addr,size) \
440 pe_opt_hdr.DataDirectory[dir].VirtualAddress = addr, \440 pe_opt_hdr.DataDirectory[dir].VirtualAddress = addr, \
441 pe_opt_hdr.DataDirectory[dir].Size = size441 pe_opt_hdr.DataDirectory[dir].Size = size
442 442
443/*----------------------------------------------------------------------------*/443/*----------------------------------------------------------------------------*/
444ST void dynarray_reset(void ***pp, int *n)444ST void dynarray_reset(void ***pp, int *n)
445{445{
446 int i;446 int i;
447 for (i = 0; i < *n; ++i)447 for (i = 0; i < *n; ++i)
448 tcc_free((*pp)[i]);448 tcc_free((*pp)[i]);
449 tcc_free(*pp);449 tcc_free(*pp);
450 *pp = NULL;450 *pp = NULL;
451 *n = 0;451 *n = 0;
@@ -455,8 +455,8 @@ ST int dynarray_assoc(void **pp, int n, int key) · 3 unmodified lines
455{455{
456 int i;456 int i;
457 for (i = 0; i < n; ++i, ++pp)457 for (i = 0; i < n; ++i, ++pp)
458 if (key == **(int **) pp)458 if (key == **(int **) pp)
459 return i;459 return i;
460 return -1;460 return -1;
461}461}
462 462
@@ -476,7 +476,7 @@ ST void pe_fpad(FILE * fp, DWORD new_pos) · 13 unmodified lines
476{476{
477 DWORD pos = ftell(fp);477 DWORD pos = ftell(fp);
478 while (++pos <= new_pos)478 while (++pos <= new_pos)
479 fputc(0, fp);479 fputc(0, fp);
480}480}
481 481
482ST DWORD pe_file_align(DWORD n)482ST DWORD pe_file_align(DWORD n)
@@ -493,7 +493,7 @@ ST void pe_align_section(Section * s, int a) · 10 unmodified lines
493{493{
494 int i = s->data_offset & (a - 1);494 int i = s->data_offset & (a - 1);
495 if (i)495 if (i)
496 section_ptr_add(s, a - i);496 section_ptr_add(s, a - i);
497}497}
498 498
499 499
@@ -508,104 +508,104 @@ ST int pe_write_pe(struct pe_info *pe) · 8 unmodified lines
508 508
509 op = fopen(pe->filename, "wb");509 op = fopen(pe->filename, "wb");
510 if (NULL == op) {510 if (NULL == op) {
511 error_noabort("could not create file: %s", pe->filename);511 error_noabort("could not create file: %s", pe->filename);
512 return 1;512 return 1;
513 }513 }
514 514
515 memset(&ish, 0, sizeof ish);515 memset(&ish, 0, sizeof ish);
516 516
517 pe->sizeofheaders = pe_file_align(sizeof pe_dos_hdr517 pe->sizeofheaders = pe_file_align(sizeof pe_dos_hdr
518 + sizeof pe_magic518 + sizeof pe_magic
519 + sizeof pe_file_hdr519 + sizeof pe_file_hdr
520 + sizeof pe_opt_hdr520 + sizeof pe_opt_hdr
521 +521 +
522 pe->sec_count *522 pe->sec_count *
523 sizeof(IMAGE_SECTION_HEADER)523 sizeof(IMAGE_SECTION_HEADER)
524 );524 );
525 525
526 file_offset = pe->sizeofheaders;526 file_offset = pe->sizeofheaders;
527 pe_fpad(op, file_offset);527 pe_fpad(op, file_offset);
528 528
529 if (2 == verbose)529 if (2 == verbose)
530 printf("-------------------------------"530 printf("-------------------------------"
531 "\n virt file size section" "\n");531 "\n virt file size section" "\n");
532 532
533 for (i = 0; i < pe->sec_count; ++i) {533 for (i = 0; i < pe->sec_count; ++i) {
534 struct section_info *si = pe->sh_info + i;534 struct section_info *si = pe->sh_info + i;
535 const char *sh_name = pe_sec_names[si->id];535 const char *sh_name = pe_sec_names[si->id];
536 unsigned long addr = si->sh_addr - pe->imagebase;536 unsigned long addr = si->sh_addr - pe->imagebase;
537 unsigned long size = si->sh_size;537 unsigned long size = si->sh_size;
538 538
539 if (2 == verbose)539 if (2 == verbose)
540 printf("%6lx %6lx %6lx %s\n",540 printf("%6lx %6lx %6lx %s\n",
541 addr, file_offset, size, sh_name);541 addr, file_offset, size, sh_name);
542 542
543 switch (si->id) {543 switch (si->id) {
544 case sec_text:544 case sec_text:
545 pe_opt_hdr.BaseOfCode = addr;545 pe_opt_hdr.BaseOfCode = addr;
546 pe_opt_hdr.AddressOfEntryPoint = addr + pe->start_addr;546 pe_opt_hdr.AddressOfEntryPoint = addr + pe->start_addr;
547 break;547 break;
548 548
549 case sec_data:549 case sec_data:
550 pe_opt_hdr.BaseOfData = addr;550 pe_opt_hdr.BaseOfData = addr;
551 if (pe->imp_size) {551 if (pe->imp_size) {
552 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_IMPORT,552 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_IMPORT,
553 pe->imp_offs + addr, pe->imp_size);553 pe->imp_offs + addr, pe->imp_size);
554 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_IAT,554 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_IAT,
555 pe->iat_offs + addr, pe->iat_size);555 pe->iat_offs + addr, pe->iat_size);
556 }556 }
557 if (pe->exp_size) {557 if (pe->exp_size) {
558 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_EXPORT,558 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_EXPORT,
559 pe->exp_offs + addr, pe->exp_size);559 pe->exp_offs + addr, pe->exp_size);
560 }560 }
561 break;561 break;
562 562
563 case sec_bss:563 case sec_bss:
564 break;564 break;
565 565
566 case sec_reloc:566 case sec_reloc:
567 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_BASERELOC, addr, size);567 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_BASERELOC, addr, size);
568 break;568 break;
569 569
570 case sec_rsrc:570 case sec_rsrc:
571 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_RESOURCE, addr, size);571 pe_set_datadir(IMAGE_DIRECTORY_ENTRY_RESOURCE, addr, size);
572 break;572 break;
573 573
574 case sec_stab:574 case sec_stab:
575 break;575 break;
576 576
577 case sec_stabstr:577 case sec_stabstr:
578 break;578 break;
579 }579 }
580 580
581 psh = &ish[sec_index++];581 psh = &ish[sec_index++];
582 strcpy((char *) psh->Name, sh_name);582 strcpy((char *) psh->Name, sh_name);
583 583
584 psh->Characteristics = pe_flags[si->id];584 psh->Characteristics = pe_flags[si->id];
585 psh->VirtualAddress = addr;585 psh->VirtualAddress = addr;
586 psh->Misc.VirtualSize = size;586 psh->Misc.VirtualSize = size;
587 pe_opt_hdr.SizeOfImage =587 pe_opt_hdr.SizeOfImage =
588 umax(psh->VirtualAddress + psh->Misc.VirtualSize,588 umax(psh->VirtualAddress + psh->Misc.VirtualSize,
589 pe_opt_hdr.SizeOfImage);589 pe_opt_hdr.SizeOfImage);
590 590
591 if (si->data_size) {591 if (si->data_size) {
592 psh->PointerToRawData = file_offset;592 psh->PointerToRawData = file_offset;
593 fwrite(si->data, 1, si->data_size, op);593 fwrite(si->data, 1, si->data_size, op);
594 file_offset = pe_file_align(file_offset + si->data_size);594 file_offset = pe_file_align(file_offset + si->data_size);
595 psh->SizeOfRawData = file_offset - psh->PointerToRawData;595 psh->SizeOfRawData = file_offset - psh->PointerToRawData;
596 pe_fpad(op, file_offset);596 pe_fpad(op, file_offset);
597 }597 }
598 }598 }
599 599
600 /*----------------------------------------------------- */600 /*----------------------------------------------------- */
601 601
602 pe_file_hdr.NumberOfSections = sec_index;602 pe_file_hdr.NumberOfSections = sec_index;
603 pe_opt_hdr.SizeOfHeaders = pe->sizeofheaders;603 pe_opt_hdr.SizeOfHeaders = pe->sizeofheaders;
604 pe_opt_hdr.ImageBase = pe->imagebase;604 pe_opt_hdr.ImageBase = pe->imagebase;
605 if (PE_DLL == pe_type)605 if (PE_DLL == pe_type)
606 pe_file_hdr.Characteristics = 0x230E;606 pe_file_hdr.Characteristics = 0x230E;
607 else if (PE_GUI != pe_type)607 else if (PE_GUI != pe_type)
608 pe_opt_hdr.Subsystem = 3;608 pe_opt_hdr.Subsystem = 3;
609 609
610 fseek(op, SEEK_SET, 0);610 fseek(op, SEEK_SET, 0);
611 fwrite(&pe_dos_hdr, 1, sizeof pe_dos_hdr, op);611 fwrite(&pe_dos_hdr, 1, sizeof pe_dos_hdr, op);
@@ -613,13 +613,13 @@ ST int pe_write_pe(struct pe_info *pe) · 1 unmodified line
613 fwrite(&pe_file_hdr, 1, sizeof pe_file_hdr, op);613 fwrite(&pe_file_hdr, 1, sizeof pe_file_hdr, op);
614 fwrite(&pe_opt_hdr, 1, sizeof pe_opt_hdr, op);614 fwrite(&pe_opt_hdr, 1, sizeof pe_opt_hdr, op);
615 for (i = 0; i < sec_index; ++i)615 for (i = 0; i < sec_index; ++i)
616 fwrite(&ish[i], 1, sizeof(IMAGE_SECTION_HEADER), op);616 fwrite(&ish[i], 1, sizeof(IMAGE_SECTION_HEADER), op);
617 fclose(op);617 fclose(op);
618 618
619 if (2 == verbose)619 if (2 == verbose)
620 printf("-------------------------------\n");620 printf("-------------------------------\n");
621 if (verbose)621 if (verbose)
622 printf("<-- %s (%lu bytes)\n", pe->filename, file_offset);622 printf("<-- %s (%lu bytes)\n", pe->filename, file_offset);
623 623
624 return 0;624 return 0;
625}625}
@@ -633,12 +633,12 @@ ST int pe_add_import(struct pe_info *pe, int sym_index, DWORD offset) · 7 unmodified lines
633 struct import_symbol *s;633 struct import_symbol *s;
634 634
635 dll_index =635 dll_index =
636 ((Elf32_Sym *) pe->s1->dynsymtab_section->data)[sym_index].636 ((Elf32_Sym *) pe->s1->dynsymtab_section->data)[sym_index].
637 st_other;637 st_other;
638 i = dynarray_assoc((void **) pe->imp_info, pe->imp_count, dll_index);638 i = dynarray_assoc((void **) pe->imp_info, pe->imp_count, dll_index);
639 if (-1 != i) {639 if (-1 != i) {
640 p = pe->imp_info[i];640 p = pe->imp_info[i];
641 goto found_dll;641 goto found_dll;
642 }642 }
643 p = tcc_mallocz(sizeof *p);643 p = tcc_mallocz(sizeof *p);
644 p->dll_index = dll_index;644 p->dll_index = dll_index;
@@ -647,7 +647,7 @@ ST int pe_add_import(struct pe_info *pe, int sym_index, DWORD offset) · 2 unmodified lines
647 found_dll:647 found_dll:
648 i = dynarray_assoc((void **) p->symbols, p->sym_count, sym_index);648 i = dynarray_assoc((void **) p->symbols, p->sym_count, sym_index);
649 if (-1 != i)649 if (-1 != i)
650 goto found_sym;650 goto found_sym;
651 s = tcc_mallocz(sizeof *s);651 s = tcc_mallocz(sizeof *s);
652 s->sym_index = sym_index;652 s->sym_index = sym_index;
653 s->offset = offset;653 s->offset = offset;
@@ -665,10 +665,10 @@ ST void pe_build_imports(struct pe_info *pe) · 11 unmodified lines
665 int ndlls = pe->imp_count;665 int ndlls = pe->imp_count;
666 666
667 for (sym_cnt = i = 0; i < ndlls; ++i)667 for (sym_cnt = i = 0; i < ndlls; ++i)
668 sym_cnt += pe->imp_info[i]->sym_count;668 sym_cnt += pe->imp_info[i]->sym_count;
669 669
670 if (0 == sym_cnt)670 if (0 == sym_cnt)
671 return;671 return;
672 672
673 pe_align_section(pe->thunk, 16);673 pe_align_section(pe->thunk, 16);
674 674
@@ -681,62 +681,62 @@ ST void pe_build_imports(struct pe_info *pe) · 6 unmodified lines
681 thk_ptr = pe->iat_offs;681 thk_ptr = pe->iat_offs;
682 ent_ptr = pe->iat_offs + pe->iat_size;682 ent_ptr = pe->iat_offs + pe->iat_size;
683 for (i = 0; i < pe->imp_count; ++i) {683 for (i = 0; i < pe->imp_count; ++i) {
684 struct pe_import_header *hdr;684 struct pe_import_header *hdr;
685 int k, n, v;685 int k, n, v;
686 struct pe_import_info *p = pe->imp_info[i];686 struct pe_import_info *p = pe->imp_info[i];
687 const char *name = pe->s1->loaded_dlls[p->dll_index]->name;687 const char *name = pe->s1->loaded_dlls[p->dll_index]->name;
688 688
689 /* put the dll name into the import header */689 /* put the dll name into the import header */
690 if (0 == strncmp(name, "lib", 3))690 if (0 == strncmp(name, "lib", 3))
691 name += 3;691 name += 3;
692 v = put_elf_str(pe->thunk, name);692 v = put_elf_str(pe->thunk, name);
693 693
694 hdr = (struct pe_import_header *) (pe->thunk->data + dll_ptr);694 hdr = (struct pe_import_header *) (pe->thunk->data + dll_ptr);
695 hdr->first_thunk = thk_ptr + voffset;695 hdr->first_thunk = thk_ptr + voffset;
696 hdr->first_entry = ent_ptr + voffset;696 hdr->first_entry = ent_ptr + voffset;
697 hdr->lib_name_offset = v + voffset;697 hdr->lib_name_offset = v + voffset;
698 698
699 for (k = 0, n = p->sym_count; k <= n; ++k) {699 for (k = 0, n = p->sym_count; k <= n; ++k) {
700 if (k < n) {700 if (k < n) {
701 DWORD offset = p->symbols[k]->offset;701 DWORD offset = p->symbols[k]->offset;
702 int sym_index = p->symbols[k]->sym_index;702 int sym_index = p->symbols[k]->sym_index;
703 Elf32_Sym *sym =703 Elf32_Sym *sym =
704 (Elf32_Sym *) pe->s1->dynsymtab_section->data +704 (Elf32_Sym *) pe->s1->dynsymtab_section->data +
705 sym_index;705 sym_index;
706 const char *name =706 const char *name =
707 pe->s1->dynsymtab_section->link->data + sym->st_name;707 pe->s1->dynsymtab_section->link->data + sym->st_name;
708 708
709 if (offset & 0x80000000) { /* ref to data */709 if (offset & 0x80000000) { /* ref to data */
710 Elf32_Sym *sym =710 Elf32_Sym *sym =
711 &((Elf32_Sym *) symtab_section->711 &((Elf32_Sym *) symtab_section->
712 data)[offset & 0x7FFFFFFF];712 data)[offset & 0x7FFFFFFF];
713 sym->st_value = thk_ptr;713 sym->st_value = thk_ptr;
714 sym->st_shndx = pe->thunk->sh_num;714 sym->st_shndx = pe->thunk->sh_num;
715 } else { /* ref to function */715 } else { /* ref to function */
716 716
717 char buffer[100];717 char buffer[100];
718 sprintf(buffer, "IAT.%s", name);718 sprintf(buffer, "IAT.%s", name);
719 sym_index =719 sym_index =
720 put_elf_sym(symtab_section, thk_ptr, sizeof(DWORD),720 put_elf_sym(symtab_section, thk_ptr, sizeof(DWORD),
721 ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT),721 ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT),
722 0, pe->thunk->sh_num, buffer);722 0, pe->thunk->sh_num, buffer);
723 723
724 put_elf_reloc(symtab_section, text_section, offset, R_386_32, /*R_JMP_SLOT, */724 put_elf_reloc(symtab_section, text_section, offset, R_386_32, /*R_JMP_SLOT, */
725 sym_index);725 sym_index);
726 }726 }
727 v = pe->thunk->data_offset + voffset;727 v = pe->thunk->data_offset + voffset;
728 section_ptr_add(pe->thunk, sizeof(WORD)); /* hint, not used */728 section_ptr_add(pe->thunk, sizeof(WORD)); /* hint, not used */
729 put_elf_str(pe->thunk, name);729 put_elf_str(pe->thunk, name);
730 } else {730 } else {
731 v = 0; // last entry is zero731 v = 0; // last entry is zero
732 }732 }
733 *(DWORD *) (pe->thunk->data + thk_ptr) =733 *(DWORD *) (pe->thunk->data + thk_ptr) =
734 *(DWORD *) (pe->thunk->data + ent_ptr) = v;734 *(DWORD *) (pe->thunk->data + ent_ptr) = v;
735 thk_ptr += sizeof(DWORD);735 thk_ptr += sizeof(DWORD);
736 ent_ptr += sizeof(DWORD);736 ent_ptr += sizeof(DWORD);
737 }737 }
738 dll_ptr += sizeof(struct pe_import_header);738 dll_ptr += sizeof(struct pe_import_header);
739 dynarray_reset((void ***) &p->symbols, &p->sym_count);739 dynarray_reset((void ***) &p->symbols, &p->sym_count);
740 }740 }
741 dynarray_reset((void ***) &pe->imp_info, &pe->imp_count);741 dynarray_reset((void ***) &pe->imp_info, &pe->imp_count);
742}742}
@@ -771,15 +771,15 @@ ST void pe_build_exports(struct pe_info *pe) · 28 unmodified lines
771 }771 }
772 772
773 if (0 == sym_count)773 if (0 == sym_count)
774 return;774 return;
775 775
776 qsort (sorted, sym_count, sizeof sorted[0], sym_cmp);776 qsort (sorted, sym_count, sizeof sorted[0], sym_cmp);
777 pe_align_section(pe->thunk, 16);777 pe_align_section(pe->thunk, 16);
778 778
779 pe->exp_offs = pe->thunk->data_offset;779 pe->exp_offs = pe->thunk->data_offset;
780 hdr = section_ptr_add(pe->thunk,780 hdr = section_ptr_add(pe->thunk,
781 sizeof(struct pe_export_header) +781 sizeof(struct pe_export_header) +
782 sym_count * (2 * sizeof(DWORD) + sizeof(WORD)));782 sym_count * (2 * sizeof(DWORD) + sizeof(WORD)));
783 783
784 func_offset = pe->exp_offs + sizeof(struct pe_export_header);784 func_offset = pe->exp_offs + sizeof(struct pe_export_header);
785 785
@@ -803,10 +803,10 @@ ST void pe_build_exports(struct pe_info *pe) · 17 unmodified lines
803 pname = p + sym_count + ord;803 pname = p + sym_count + ord;
804 pord = (WORD *)(p + 2*sym_count) + ord;804 pord = (WORD *)(p + 2*sym_count) + ord;
805 *pfunc = sym->st_value + pe->s1->sections[sym->st_shndx]->sh_addr - pe->imagebase;805 *pfunc = sym->st_value + pe->s1->sections[sym->st_shndx]->sh_addr - pe->imagebase;
806 *pname = pe->thunk->data_offset + voffset;806 *pname = pe->thunk->data_offset + voffset;
807 *pord = ord;807 *pord = ord;
808 put_elf_str(pe->thunk, name);808 put_elf_str(pe->thunk, name);
809 /* printf("export: %s\n", name); */809 /* printf("export: %s\n", name); */
810 }810 }
811 pe->exp_size = pe->thunk->data_offset - pe->exp_offs;811 pe->exp_size = pe->thunk->data_offset - pe->exp_offs;
812 tcc_free(sorted);812 tcc_free(sorted);
@@ -814,7 +814,7 @@ ST void pe_build_exports(struct pe_info *pe) · 1 unmodified line
814 814
815/* ------------------------------------------------------------- */815/* ------------------------------------------------------------- */
816ST void pe_build_reloc(struct pe_info *pe, int *section_order,816ST void pe_build_reloc(struct pe_info *pe, int *section_order,
817 int section_count)817 int section_count)
818{818{
819 DWORD offset, block_ptr, addr;819 DWORD offset, block_ptr, addr;
820 int count, i;820 int count, i;
@@ -823,45 +823,45 @@ ST void pe_build_reloc(struct pe_info *pe, int *section_order, · 2 unmodified lines
823 offset = addr = block_ptr = count = i = 0;823 offset = addr = block_ptr = count = i = 0;
824 rel = rel_end = NULL;824 rel = rel_end = NULL;
825 for (;;) {825 for (;;) {
826 if (rel < rel_end) {826 if (rel < rel_end) {
827 int type = ELF32_R_TYPE(rel->r_info);827 int type = ELF32_R_TYPE(rel->r_info);
828 addr = rel->r_offset + s->sh_addr;828 addr = rel->r_offset + s->sh_addr;
829 ++rel;829 ++rel;
830 if (type != R_386_32)830 if (type != R_386_32)
831 continue;831 continue;
832 if (count == 0) { /* new block */832 if (count == 0) { /* new block */
833 block_ptr = pe->reloc->data_offset;833 block_ptr = pe->reloc->data_offset;
834 section_ptr_add(pe->reloc, sizeof(struct pe_reloc_header));834 section_ptr_add(pe->reloc, sizeof(struct pe_reloc_header));
835 offset = addr & 0xFFFFFFFF << 12;835 offset = addr & 0xFFFFFFFF << 12;
836 }836 }
837 if ((addr -= offset) < (1 << 12)) { /* one block spans 4k addresses */837 if ((addr -= offset) < (1 << 12)) { /* one block spans 4k addresses */
838 WORD *wp = section_ptr_add(pe->reloc, sizeof(WORD));838 WORD *wp = section_ptr_add(pe->reloc, sizeof(WORD));
839 *wp = addr | IMAGE_REL_BASED_HIGHLOW << 12;839 *wp = addr | IMAGE_REL_BASED_HIGHLOW << 12;
840 ++count;840 ++count;
841 continue;841 continue;
842 }842 }
843 --rel;843 --rel;
844 } else if (i < section_count) {844 } else if (i < section_count) {
845 sr = (s = pe->s1->sections[section_order[i++]])->reloc;845 sr = (s = pe->s1->sections[section_order[i++]])->reloc;
846 if (sr) {846 if (sr) {
847 rel = (Elf32_Rel *) sr->data;847 rel = (Elf32_Rel *) sr->data;
848 rel_end = (Elf32_Rel *) (sr->data + sr->data_offset);848 rel_end = (Elf32_Rel *) (sr->data + sr->data_offset);
849 }849 }
850 continue;850 continue;
851 }851 }
852 852
853 if (count) { /* store the last block and ready for a new one */853 if (count) { /* store the last block and ready for a new one */
854 struct pe_reloc_header *hdr;854 struct pe_reloc_header *hdr;
855 if (count & 1)855 if (count & 1)
856 section_ptr_add(pe->reloc, 2), ++count;856 section_ptr_add(pe->reloc, 2), ++count;
857 hdr = (struct pe_reloc_header *) (pe->reloc->data + block_ptr);857 hdr = (struct pe_reloc_header *) (pe->reloc->data + block_ptr);
858 hdr->offset = offset - pe->imagebase;858 hdr->offset = offset - pe->imagebase;
859 hdr->size =859 hdr->size =
860 count * sizeof(WORD) + sizeof(struct pe_reloc_header);860 count * sizeof(WORD) + sizeof(struct pe_reloc_header);
861 count = 0;861 count = 0;
862 }862 }
863 if (rel >= rel_end)863 if (rel >= rel_end)
864 break;864 break;
865 }865 }
866}866}
867 867
@@ -877,50 +877,50 @@ ST int pe_assign_addresses(struct pe_info *pe) · 9 unmodified lines
877 addr = pe->imagebase + 1;877 addr = pe->imagebase + 1;
878 878
879 if (PE_DLL == pe_type)879 if (PE_DLL == pe_type)
880 pe->reloc = new_section(pe->s1, ".reloc", SHT_DYNAMIC, SHF_ALLOC);880 pe->reloc = new_section(pe->s1, ".reloc", SHT_DYNAMIC, SHF_ALLOC);
881 881
882 for (n = k = 0; n < pe_sec_number; ++n) {882 for (n = k = 0; n < pe_sec_number; ++n) {
883 for (i = 1; i < pe->s1->nb_sections; ++i) {883 for (i = 1; i < pe->s1->nb_sections; ++i) {
884 Section *s = pe->s1->sections[i];884 Section *s = pe->s1->sections[i];
885 if (0 == strcmp(s->name, pe_sec_names[n])) {885 if (0 == strcmp(s->name, pe_sec_names[n])) {
886 struct section_info *si = &pe->sh_info[pe->sec_count];886 struct section_info *si = &pe->sh_info[pe->sec_count];
887#ifdef PE_MERGE_DATA887#ifdef PE_MERGE_DATA
888 if (n == sec_bss && si_data) {888 if (n == sec_bss && si_data) {
889 /* append .bss to .data */889 /* append .bss to .data */
890 s->sh_addr = addr = ((addr - 1) | 15) + 1;890 s->sh_addr = addr = ((addr - 1) | 15) + 1;
891 addr += s->data_offset;891 addr += s->data_offset;
892 si_data->sh_size = addr - si_data->sh_addr;892 si_data->sh_size = addr - si_data->sh_addr;
893 } else893 } else
894#endif894#endif
895 {895 {
896 si->sh_addr = s->sh_addr = addr =896 si->sh_addr = s->sh_addr = addr =
897 pe_virtual_align(addr);897 pe_virtual_align(addr);
898 si->id = n;898 si->id = n;
899 899
900 if (n == sec_data) {900 if (n == sec_data) {
901 pe->thunk = s;901 pe->thunk = s;
902 si_data = si;902 si_data = si;
903 pe_build_imports(pe);903 pe_build_imports(pe);
904 pe_build_exports(pe);904 pe_build_exports(pe);
905 } else if (n == sec_reloc) {905 } else if (n == sec_reloc) {
906 pe_build_reloc(pe, section_order, k);906 pe_build_reloc(pe, section_order, k);
907 }907 }
908 908
909 if (s->data_offset) {909 if (s->data_offset) {
910 if (n != sec_bss) {910 if (n != sec_bss) {
911 si->data = s->data;911 si->data = s->data;
912 si->data_size = s->data_offset;912 si->data_size = s->data_offset;
913 }913 }
914 914
915 addr += s->data_offset;915 addr += s->data_offset;
916 si->sh_size = s->data_offset;916 si->sh_size = s->data_offset;
917 ++pe->sec_count;917 ++pe->sec_count;
918 }918 }
919 //printf("Section %08X %04X %s\n", si->sh_addr, si->data_size, s->name);919 //printf("Section %08X %04X %s\n", si->sh_addr, si->data_size, s->name);
920 }920 }
921 section_order[k] = i, ++k;921 section_order[k] = i, ++k;
922 }922 }
923 }923 }
924 }924 }
925 return 0;925 return 0;
926}926}
@@ -934,38 +934,38 @@ ST int pe_check_symbols(struct pe_info *pe) · 7 unmodified lines
934 pe_align_section(text_section, 8);934 pe_align_section(text_section, 8);
935 935
936 for_sym_in_symtab(sym) {936 for_sym_in_symtab(sym) {
937 if (sym->st_shndx == SHN_UNDEF) {937 if (sym->st_shndx == SHN_UNDEF) {
938 const char *symbol = symtab_section->link->data + sym->st_name;938 const char *symbol = symtab_section->link->data + sym->st_name;
939 unsigned type = ELF32_ST_TYPE(sym->st_info);939 unsigned type = ELF32_ST_TYPE(sym->st_info);
940 int sym_index = pe_find_import(pe->s1, symbol, NULL);940 int sym_index = pe_find_import(pe->s1, symbol, NULL);
941 if (sym_index) {941 if (sym_index) {
942 if (type == STT_FUNC) {942 if (type == STT_FUNC) {
943 unsigned long offset = text_section->data_offset;943 unsigned long offset = text_section->data_offset;
944 if (pe_add_import(pe, sym_index, offset + 2)) {944 if (pe_add_import(pe, sym_index, offset + 2)) {
945 /* add the 'jmp IAT[x]' instruction */945 /* add the 'jmp IAT[x]' instruction */
946 *(WORD *) section_ptr_add(text_section, 8) =946 *(WORD *) section_ptr_add(text_section, 8) =
947 0x25FF;947 0x25FF;
948 /* patch the symbol */948 /* patch the symbol */
949 sym->st_shndx = text_section->sh_num;949 sym->st_shndx = text_section->sh_num;
950 sym->st_value = offset;950 sym->st_value = offset;
951 continue;951 continue;
952 }952 }
953 } else if (type == STT_OBJECT) { /* data, ptr to that should be */953 } else if (type == STT_OBJECT) { /* data, ptr to that should be */
954 if (pe_add_import(pe, sym_index,954 if (pe_add_import(pe, sym_index,
955 (sym -955 (sym -
956 (Elf32_Sym *) symtab_section->data) | 956 (Elf32_Sym *) symtab_section->data) |
957 0x80000000))957 0x80000000))
958 continue;958 continue;
959 }959 }
960 }960 }
961 error_noabort("undefined symbol '%s'", symbol);961 error_noabort("undefined symbol '%s'", symbol);
962 ret = 1;962 ret = 1;
963 } else963 } else
964 if (pe->s1->rdynamic964 if (pe->s1->rdynamic
965 && ELF32_ST_BIND(sym->st_info) != STB_LOCAL) {965 && ELF32_ST_BIND(sym->st_info) != STB_LOCAL) {
966 /* if -rdynamic option, then export all non local symbols */966 /* if -rdynamic option, then export all non local symbols */
967 sym->st_other |= 1;967 sym->st_other |= 1;
968 }968 }
969 }969 }
970 return ret;970 return ret;
971}971}
@@ -973,7 +973,7 @@ ST int pe_check_symbols(struct pe_info *pe) · 1 unmodified line
973/*----------------------------------------------------------------------------*/973/*----------------------------------------------------------------------------*/
974#ifdef PE_PRINT_SECTIONS974#ifdef PE_PRINT_SECTIONS
975ST void pe_print_section(FILE * f, Section * s)975ST void pe_print_section(FILE * f, Section * s)
976{ /* just if you'r curious */976{ /* just if you'r curious */
977 BYTE *p, *e, b;977 BYTE *p, *e, b;
978 int i, n, l, m;978 int i, n, l, m;
979 p = s->data;979 p = s->data;
@@ -982,76 +982,76 @@ ST void pe_print_section(FILE * f, Section * s) · 2 unmodified lines
982 982
983 fprintf(f, "section \"%s\"", s->name);983 fprintf(f, "section \"%s\"", s->name);
984 if (s->link)984 if (s->link)
985 fprintf(f, "\nlink \"%s\"", s->link->name);985 fprintf(f, "\nlink \"%s\"", s->link->name);
986 if (s->reloc)986 if (s->reloc)
987 fprintf(f, "\nreloc \"%s\"", s->reloc->name);987 fprintf(f, "\nreloc \"%s\"", s->reloc->name);
988 fprintf(f, "\nv_addr %08X", s->sh_addr);988 fprintf(f, "\nv_addr %08X", s->sh_addr);
989 fprintf(f, "\ncontents %08X", l);989 fprintf(f, "\ncontents %08X", l);
990 fprintf(f, "\n\n");990 fprintf(f, "\n\n");
991 991
992 if (s->sh_type == SHT_NOBITS)992 if (s->sh_type == SHT_NOBITS)
993 return;993 return;
994 994
995 if (s->sh_type == SHT_SYMTAB)995 if (s->sh_type == SHT_SYMTAB)
996 m = sizeof(Elf32_Sym);996 m = sizeof(Elf32_Sym);
997 if (s->sh_type == SHT_REL)997 if (s->sh_type == SHT_REL)
998 m = sizeof(Elf32_Rel);998 m = sizeof(Elf32_Rel);
999 else999 else
1000 m = 16;1000 m = 16;
1001 1001
1002 for (i = 0; i < l;) {1002 for (i = 0; i < l;) {
1003 fprintf(f, "%08X", i);1003 fprintf(f, "%08X", i);
1004 for (n = 0; n < m; ++n) {1004 for (n = 0; n < m; ++n) {
1005 if (n + i < l)1005 if (n + i < l)
1006 fprintf(f, " %02X", p[i + n]);1006 fprintf(f, " %02X", p[i + n]);
1007 else1007 else
1008 fprintf(f, " ");1008 fprintf(f, " ");
1009 }1009 }
1010 1010
1011 if (s->sh_type == SHT_SYMTAB) {1011 if (s->sh_type == SHT_SYMTAB) {
1012 Elf32_Sym *sym = (Elf32_Sym *) (p + i);1012 Elf32_Sym *sym = (Elf32_Sym *) (p + i);
1013 const char *name = s->link->data + sym->st_name;1013 const char *name = s->link->data + sym->st_name;
1014 fprintf(f,1014 fprintf(f,
1015 " name:%04X"1015 " name:%04X"
1016 " value:%04X"1016 " value:%04X"
1017 " size:%04X"1017 " size:%04X"
1018 " bind:%02X"1018 " bind:%02X"
1019 " type:%02X"1019 " type:%02X"
1020 " other:%02X"1020 " other:%02X"
1021 " shndx:%04X"1021 " shndx:%04X"
1022 " \"%s\"",1022 " \"%s\"",
1023 sym->st_name,1023 sym->st_name,
1024 sym->st_value,1024 sym->st_value,
1025 sym->st_size,1025 sym->st_size,
1026 ELF32_ST_BIND(sym->st_info),1026 ELF32_ST_BIND(sym->st_info),
1027 ELF32_ST_TYPE(sym->st_info),1027 ELF32_ST_TYPE(sym->st_info),
1028 sym->st_other, sym->st_shndx, name);1028 sym->st_other, sym->st_shndx, name);
1029 } else if (s->sh_type == SHT_REL) {1029 } else if (s->sh_type == SHT_REL) {
1030 Elf32_Rel *rel = (Elf32_Rel *) (p + i);1030 Elf32_Rel *rel = (Elf32_Rel *) (p + i);
1031 Elf32_Sym *sym =1031 Elf32_Sym *sym =
1032 (Elf32_Sym *) s->link->data + ELF32_R_SYM(rel->r_info);1032 (Elf32_Sym *) s->link->data + ELF32_R_SYM(rel->r_info);
1033 const char *name = s->link->link->data + sym->st_name;1033 const char *name = s->link->link->data + sym->st_name;
1034 fprintf(f,1034 fprintf(f,
1035 " offset:%04X"1035 " offset:%04X"
1036 " type:%02X"1036 " type:%02X"
1037 " symbol:%04X"1037 " symbol:%04X"
1038 " \"%s\"",1038 " \"%s\"",
1039 rel->r_offset,1039 rel->r_offset,
1040 ELF32_R_TYPE(rel->r_info),1040 ELF32_R_TYPE(rel->r_info),
1041 ELF32_R_SYM(rel->r_info), name);1041 ELF32_R_SYM(rel->r_info), name);
1042 } else {1042 } else {
1043 fprintf(f, " ");1043 fprintf(f, " ");
1044 for (n = 0; n < m; ++n) {1044 for (n = 0; n < m; ++n) {
1045 if (n + i < l) {1045 if (n + i < l) {
1046 b = p[i + n];1046 b = p[i + n];
1047 if (b < 32 || b >= 127)1047 if (b < 32 || b >= 127)
1048 b = '.';1048 b = '.';
1049 fprintf(f, "%c", b);1049 fprintf(f, "%c", b);
1050 }1050 }
1051 }1051 }
1052 }1052 }
1053 i += m;1053 i += m;
1054 fprintf(f, "\n");1054 fprintf(f, "\n");
1055 }1055 }
1056 fprintf(f, "\n\n");1056 fprintf(f, "\n\n");
1057}1057}
@@ -1083,50 +1083,50 @@ int pe_load_def_file(TCCState * s1, FILE * fp) · 25 unmodified lines
1083 int f = 0, sym_index;1083 int f = 0, sym_index;
1084 char *p, line[120], dllname[40];1084 char *p, line[120], dllname[40];
1085 while (fgets(line, sizeof line, fp)) {1085 while (fgets(line, sizeof line, fp)) {
1086 p = strchr(line, 0);1086 p = strchr(line, 0);
1087 while (p > line && p[-1] <= ' ')1087 while (p > line && p[-1] <= ' ')
1088 --p;1088 --p;
1089 *p = 0;1089 *p = 0;
1090 p = line;1090 p = line;
1091 while (*p && *p <= ' ')1091 while (*p && *p <= ' ')
1092 ++p;1092 ++p;
1093 1093
1094 if (*p && ';' != *p)1094 if (*p && ';' != *p)
1095 switch (f) {1095 switch (f) {
1096 case 0:1096 case 0:
1097 if (!pe_test_cmd((const char **)&p, "LIBRARY"))1097 if (!pe_test_cmd((const char **)&p, "LIBRARY"))
1098 return -1;1098 return -1;
1099 while (is_space(*p))1099 while (is_space(*p))
1100 p++;1100 p++;
1101 pstrcpy(dllname, sizeof(dllname), p);1101 pstrcpy(dllname, sizeof(dllname), p);
1102 ++f;1102 ++f;
1103 continue;1103 continue;
1104 1104
1105 case 1:1105 case 1:
1106 if (!pe_test_cmd((const char **)&p, "EXPORTS"))1106 if (!pe_test_cmd((const char **)&p, "EXPORTS"))
1107 return -1;1107 return -1;
1108 ++f;1108 ++f;
1109 continue;1109 continue;
1110 1110
1111 case 2:1111 case 2:
1112 dllref =1112 dllref =
1113 tcc_malloc(sizeof(DLLReference) + strlen(dllname));1113 tcc_malloc(sizeof(DLLReference) + strlen(dllname));
1114 strcpy(dllref->name, dllname);1114 strcpy(dllref->name, dllname);
1115 dllref->level = 0;1115 dllref->level = 0;
1116 dynarray_add((void ***) &s1->loaded_dlls,1116 dynarray_add((void ***) &s1->loaded_dlls,
1117 &s1->nb_loaded_dlls, dllref);1117 &s1->nb_loaded_dlls, dllref);
1118 ++f;1118 ++f;
1119 1119
1120 default:1120 default:
1121 /* tccpe needs to know from what dll it should import1121 /* tccpe needs to know from what dll it should import
1122 the sym */1122 the sym */
1123 sym_index = add_elf_sym(s1->dynsymtab_section,1123 sym_index = add_elf_sym(s1->dynsymtab_section,
1124 0, 0, ELF32_ST_INFO(STB_GLOBAL,1124 0, 0, ELF32_ST_INFO(STB_GLOBAL,
1125 STT_FUNC),1125 STT_FUNC),
1126 s1->nb_loaded_dlls - 1,1126 s1->nb_loaded_dlls - 1,
1127 text_section->sh_num, p);1127 text_section->sh_num, p);
1128 continue;1128 continue;
1129 }1129 }
1130 }1130 }
1131 return 0;1131 return 0;
1132}1132}
@@ -1156,7 +1156,7 @@ unsigned long pe_add_runtime(TCCState * s1) · 23 unmodified lines
1156 unsigned long addr;1156 unsigned long addr;
1157 1157
1158 if (find_elf_sym(symtab_section, "WinMain"))1158 if (find_elf_sym(symtab_section, "WinMain"))
1159 pe_type = PE_GUI;1159 pe_type = PE_GUI;
1160 else1160 else
1161 if (TCC_OUTPUT_DLL == s1->output_type)1161 if (TCC_OUTPUT_DLL == s1->output_type)
1162 {1162 {
@@ -1166,39 +1166,39 @@ unsigned long pe_add_runtime(TCCState * s1) · 3 unmodified lines
1166 }1166 }
1167 1167
1168 start_symbol =1168 start_symbol =
1169 TCC_OUTPUT_MEMORY == s1->output_type1169 TCC_OUTPUT_MEMORY == s1->output_type
1170 ? PE_GUI == pe_type ? "_runwinmain" : NULL1170 ? PE_GUI == pe_type ? "_runwinmain" : NULL
1171 : PE_DLL == pe_type ? "_dllstart"1171 : PE_DLL == pe_type ? "_dllstart"
1172 : PE_GUI == pe_type ? "_winstart" : "_start";1172 : PE_GUI == pe_type ? "_winstart" : "_start";
1173 1173
1174 /* grab the startup code from libtcc1 */1174 /* grab the startup code from libtcc1 */
1175 if (start_symbol)1175 if (start_symbol)
1176 add_elf_sym(symtab_section,1176 add_elf_sym(symtab_section,
1177 0, 0,1177 0, 0,
1178 ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE), 0,1178 ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE), 0,
1179 SHN_UNDEF, start_symbol);1179 SHN_UNDEF, start_symbol);
1180 1180
1181 if (0 == s1->nostdlib) {1181 if (0 == s1->nostdlib) {
1182 tcc_add_library(s1, "tcc1");1182 tcc_add_library(s1, "tcc1");
1183 tcc_add_library(s1, "msvcrt");1183 tcc_add_library(s1, "msvcrt");
1184 if (PE_DLL == pe_type || PE_GUI == pe_type) {1184 if (PE_DLL == pe_type || PE_GUI == pe_type) {
1185 tcc_add_library(s1, "kernel32");1185 tcc_add_library(s1, "kernel32");
1186 tcc_add_library(s1, "user32");1186 tcc_add_library(s1, "user32");
1187 tcc_add_library(s1, "gdi32");1187 tcc_add_library(s1, "gdi32");
1188 }1188 }
1189 }1189 }
1190 1190
1191 addr = start_symbol ?1191 addr = start_symbol ?
1192 (unsigned long) tcc_get_symbol_err(s1, start_symbol) : 0;1192 (unsigned long) tcc_get_symbol_err(s1, start_symbol) : 0;
1193 1193
1194 if (s1->output_type == TCC_OUTPUT_MEMORY && addr) {1194 if (s1->output_type == TCC_OUTPUT_MEMORY && addr) {
1195 /* for -run GUI's, put '_runwinmain' instead of 'main' */1195 /* for -run GUI's, put '_runwinmain' instead of 'main' */
1196 add_elf_sym(symtab_section,1196 add_elf_sym(symtab_section,
1197 addr, 0,1197 addr, 0,
1198 ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE), 0,1198 ELF32_ST_INFO(STB_GLOBAL, STT_NOTYPE), 0,
1199 text_section->sh_num, "main");1199 text_section->sh_num, "main");
1200 1200
1201 /* FreeConsole(); */1201 /* FreeConsole(); */
1202 }1202 }
1203 return addr;1203 return addr;
1204}1204}
@@ -1213,29 +1213,29 @@ int tcc_output_pe(TCCState * s1, const char *filename) · 8 unmodified lines
1213 pe.s1 = s1;1213 pe.s1 = s1;
1214 pe.start_addr = pe_add_runtime(s1);1214 pe.start_addr = pe_add_runtime(s1);
1215 1215
1216 relocate_common_syms(); /* assign bss adresses */1216 relocate_common_syms(); /* assign bss adresses */
1217 ret = pe_check_symbols(&pe);1217 ret = pe_check_symbols(&pe);
1218 if (0 == ret) {1218 if (0 == ret) {
1219 pe_assign_addresses(&pe);1219 pe_assign_addresses(&pe);
1220 relocate_syms(s1, 0);1220 relocate_syms(s1, 0);
1221 for (i = 1; i < s1->nb_sections; ++i) {1221 for (i = 1; i < s1->nb_sections; ++i) {
1222 Section *s = s1->sections[i];1222 Section *s = s1->sections[i];
1223 if (s->reloc)1223 if (s->reloc)
1224 relocate_section(s1, s);1224 relocate_section(s1, s);
1225 }1225 }
1226 ret = pe_write_pe(&pe);1226 ret = pe_write_pe(&pe);
1227 }1227 }
1228#ifdef PE_PRINT_SECTIONS1228#ifdef PE_PRINT_SECTIONS
1229 {1229 {
1230 Section *s;1230 Section *s;
1231 FILE *f;1231 FILE *f;
1232 f = fopen("tccpe.log", "wt");1232 f = fopen("tccpe.log", "wt");
1233 for (i = 1; i < s1->nb_sections; ++i) {1233 for (i = 1; i < s1->nb_sections; ++i) {
1234 s = s1->sections[i];1234 s = s1->sections[i];
1235 pe_print_section(f, s);1235 pe_print_section(f, s);
1236 }1236 }
1237 pe_print_section(f, s1->dynsymtab_section);1237 pe_print_section(f, s1->dynsymtab_section);
1238 fclose(f);1238 fclose(f);
1239 }1239 }
1240#endif1240#endif
1241 return ret;1241 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t