5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
8 Desc: Definition of ELF file structures.
12 #include <exec/types.h>
15 * Define one of ELF_64BIT or ELF_32BIT in your code if you want to enforce specific
16 * version of ELF structures. Otherwize it fails back to your native machine's size.
19 #define elf_ptr_t UQUAD
20 #define elf_uintptr_t UQUAD
21 #define elf_intptr_t QUAD
25 #define elf_ptr_t ULONG
26 #define elf_uintptr_t ULONG
27 #define elf_intptr_t LONG
31 #define elf_ptr_t APTR
32 #define elf_uintptr_t IPTR
33 #define elf_intptr_t SIPTR
35 #if (__WORDSIZE == 64)
41 #define SHT_PROGBITS 1
47 #define SHT_SYMTAB_SHNDX 18
48 #define SHT_ARM_ATTRIBUTES 0x70000003
57 #define EM_X86_64 62 /* AMD x86-64 */
63 /* AMD x86-64 relocations. */
64 #define R_X86_64_NONE 0 /* No reloc */
65 #define R_X86_64_64 1 /* Direct 64 bit */
66 #define R_X86_64_PC32 2 /* PC relative 32 bit signed */
67 #define R_X86_64_32 10
68 #define R_X86_64_32S 11
79 #define R_PPC_ADDR32 1
80 #define R_PPC_ADDR16_LO 4
81 #define R_PPC_ADDR16_HA 6
82 #define R_PPC_REL24 10
83 #define R_PPC_REL32 26
84 #define R_PPC_REL16_LO 250
85 #define R_PPC_REL16_HA 252
91 #define R_ARM_JUMP24 29
92 #define R_ARM_TARGET1 38
94 #define R_ARM_TARGET2 41
95 #define R_ARM_PREL31 42
96 #define R_ARM_MOVW_ABS_NC 43
97 #define R_ARM_MOVT_ABS 44
98 #define R_ARM_THM_CALL 10
99 #define R_ARM_THM_JUMP24 30
100 #define R_ARM_THM_MOVW_ABS_NC 47
101 #define R_ARM_THM_MOVT_ABS 48
106 #define STT_SECTION 3
108 #define STT_LOPROC 13
109 #define STT_HIPROC 15
115 #define STB_GNU_UNIQUE 10
117 #define STB_LOPROC 13
118 #define STB_HIPROC 15
121 #define SHN_LORESERVE 0xff00
122 #define SHN_ABS 0xfff1
123 #define SHN_COMMON 0xfff2
124 #define SHN_XINDEX 0xffff
125 #define SHN_HIRESERVE 0xffff
127 #define SHF_WRITE (1 << 0)
128 #define SHF_ALLOC (1 << 1)
129 #define SHF_EXECINSTR (1 << 2)
131 #define ELF_ST_TYPE(i) ((i) & 0x0F)
137 #define ELFDATA2LSB 1
138 #define ELFDATA2MSB 2
142 #define ELFCLASS64 2 /* 64-bit objects */
145 #define EI_ABIVERSION 8
147 #define ELFOSABI_AROS 15
149 #define PF_X (1 << 0)
175 elf_uintptr_t offset
;
179 elf_uintptr_t addralign
;
180 elf_uintptr_t entsize
;
191 elf_uintptr_t offset
;
194 elf_uintptr_t filesz
;
201 ULONG name
; /* Offset of the name string in the string table */
202 UBYTE info
; /* What kind of symbol is this ? (global, variable, etc) */
203 UBYTE other
; /* undefined */
204 UWORD shindex
; /* In which section is the symbol defined ? */
205 elf_uintptr_t value
; /* Varies; eg. the offset of the symbol in its hunk */
206 elf_uintptr_t size
; /* How much memory does the symbol occupy */
209 #define ELF_R_SYM(i) (ULONG)((i) >> 32)
210 #define ELF_R_TYPE(i) (ULONG)((i) & 0xffffffffULL)
211 #define ELF_R_INFO(sym, type) (((UQUAD)(sym) << 32) + (type))
229 ULONG name
; /* Offset of the name string in the string table */
230 elf_uintptr_t value
; /* Varies; eg. the offset of the symbol in its hunk */
231 elf_uintptr_t size
; /* How much memory does the symbol occupy */
232 UBYTE info
; /* What kind of symbol is this ? (global, variable, etc) */
233 UBYTE other
; /* undefined */
234 UWORD shindex
; /* In which section is the symbol defined ? */
237 #define ELF_R_SYM(val) ((val) >> 8)
238 #define ELF_R_TYPE(val) ((val) & 0xff)
239 #define ELF_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
243 #define ELF_S_BIND(val) ((val) >> 4)
244 #define ELF_S_TYPE(val) ((val) & 0xF)
245 #define ELF_S_INFO(bind, type) (((bind) << 4) + ((type) & 0xF))
249 elf_uintptr_t offset
; /* Address of the relocation relative to the section it refers to */
250 elf_uintptr_t info
; /* Type of the relocation */
255 elf_uintptr_t offset
; /* Address of the relocation relative to the section it refers to */
256 elf_uintptr_t info
; /* Type of the relocation */
257 elf_intptr_t addend
; /* Constant addend used to compute value */
260 /* Note: the conversion below is not in line with ELF specification and is fixed in GNU binutils since 2008
261 * See: https://sourceware.org/bugzilla/show_bug.cgi?id=5900
263 /* convert section header number to array index */
264 /*#define SHINDEX(n) \
265 ((n) < SHN_LORESERVE ? (n) : ((n) <= SHN_HIRESERVE ? 0 : (n) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))*/
267 /* convert section header array index to section number */
269 ((i) < SHN_LORESERVE ? (i) : (i) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))*/
271 /* ARM-specific attributes section definitions follow */
273 #define ATTR_VERSION_CURRENT 0x41
278 char vendor
[1]; /* NULL-terminated name */
279 /* Vendor-specific subsections follow */
282 struct attrs_subsection
286 } __attribute__((packed
));
289 #define Tag_Section 2
291 #define Tag_CPU_raw_name 4
292 #define Tag_CPU_name 5
293 #define Tag_CPU_arch 6
294 #define Tag_FP_arch 10
295 #define Tag_compatibility 32
296 #define Tag_also_compatible_with 65
297 #define Tag_conformance 67
299 /* Tag_CPU_arch values */
300 #define ELF_CPU_PREv4 0
301 #define ELF_CPU_ARMv4 1
302 #define ELF_CPU_ARMv4T 2
303 #define ELF_CPU_ARMv5T 3
304 #define ELF_CPU_ARMv5TE 4
305 #define ELF_CPU_ARMv5TEJ 5
306 #define ELF_CPU_ARMv6 6
307 #define ELF_CPU_ARMv6KZ 7
308 #define ELF_CPU_ARMv6T2 8
309 #define ELF_CPU_ARMv6K 9
310 #define ELF_CPU_ARMv7 10
311 #define ELF_CPU_ARM_v6M 11
312 #define ELF_CPU_ARMv6SM 12
313 #define ELF_CPU_ARMv7EM 13
315 /* Tag_FP_arch values */
316 #define ELF_FP_None 0
320 #define ELF_FP_v3_Short 4
322 #define ELF_FP_v4_Short 6
324 /* Machine's native values */
326 #define AROS_ELF_CLASS ELFCLASS64
328 #define AROS_ELF_CLASS ELFCLASS32
332 #define AROS_ELF_DATA ELFDATA2MSB
334 #define AROS_ELF_DATA ELFDATA2LSB
337 #if defined(__i386__) || defined(__x86_64__)
339 #define AROS_ELF_MACHINE EM_X86_64
340 #define AROS_ELF_REL SHT_RELA
343 #define AROS_ELF_MACHINE EM_386
344 #define AROS_ELF_REL SHT_REL
349 #define AROS_ELF_MACHINE EM_68K
350 #define AROS_ELF_REL SHT_RELA
354 #define AROS_ELF_MACHINE EM_PPC
355 #define AROS_ELF_REL SHT_RELA
359 #define AROS_ELF_MACHINE EM_ARM
360 #define AROS_ELF_REL SHT_REL