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
93 #define R_ARM_PREL31 42
94 #define R_ARM_MOVW_ABS_NC 43
95 #define R_ARM_MOVT_ABS 44
96 #define R_ARM_THM_CALL 10
97 #define R_ARM_THM_JUMP24 30
98 #define R_ARM_THM_MOVW_ABS_NC 47
99 #define R_ARM_THM_MOVT_ABS 48
104 #define STT_SECTION 3
106 #define STT_LOPROC 13
107 #define STT_HIPROC 15
113 #define STB_GNU_UNIQUE 10
115 #define STB_LOPROC 13
116 #define STB_HIPROC 15
119 #define SHN_LORESERVE 0xff00
120 #define SHN_ABS 0xfff1
121 #define SHN_COMMON 0xfff2
122 #define SHN_XINDEX 0xffff
123 #define SHN_HIRESERVE 0xffff
125 #define SHF_WRITE (1 << 0)
126 #define SHF_ALLOC (1 << 1)
127 #define SHF_EXECINSTR (1 << 2)
129 #define ELF_ST_TYPE(i) ((i) & 0x0F)
135 #define ELFDATA2LSB 1
136 #define ELFDATA2MSB 2
140 #define ELFCLASS64 2 /* 64-bit objects */
143 #define EI_ABIVERSION 8
145 #define ELFOSABI_AROS 15
147 #define PF_X (1 << 0)
173 elf_uintptr_t offset
;
177 elf_uintptr_t addralign
;
178 elf_uintptr_t entsize
;
189 elf_uintptr_t offset
;
192 elf_uintptr_t filesz
;
199 ULONG name
; /* Offset of the name string in the string table */
200 UBYTE info
; /* What kind of symbol is this ? (global, variable, etc) */
201 UBYTE other
; /* undefined */
202 UWORD shindex
; /* In which section is the symbol defined ? */
203 elf_uintptr_t value
; /* Varies; eg. the offset of the symbol in its hunk */
204 elf_uintptr_t size
; /* How much memory does the symbol occupy */
207 #define ELF_R_SYM(i) (ULONG)((i) >> 32)
208 #define ELF_R_TYPE(i) (ULONG)((i) & 0xffffffffULL)
209 #define ELF_R_INFO(sym, type) (((UQUAD)(sym) << 32) + (type))
227 ULONG name
; /* Offset of the name string in the string table */
228 elf_uintptr_t value
; /* Varies; eg. the offset of the symbol in its hunk */
229 elf_uintptr_t size
; /* How much memory does the symbol occupy */
230 UBYTE info
; /* What kind of symbol is this ? (global, variable, etc) */
231 UBYTE other
; /* undefined */
232 UWORD shindex
; /* In which section is the symbol defined ? */
235 #define ELF_R_SYM(val) ((val) >> 8)
236 #define ELF_R_TYPE(val) ((val) & 0xff)
237 #define ELF_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff))
241 #define ELF_S_BIND(val) ((val) >> 4)
242 #define ELF_S_TYPE(val) ((val) & 0xF)
243 #define ELF_S_INFO(bind, type) (((bind) << 4) + ((type) & 0xF))
247 elf_uintptr_t offset
; /* Address of the relocation relative to the section it refers to */
248 elf_uintptr_t info
; /* Type of the relocation */
253 elf_uintptr_t offset
; /* Address of the relocation relative to the section it refers to */
254 elf_uintptr_t info
; /* Type of the relocation */
255 elf_intptr_t addend
; /* Constant addend used to compute value */
258 /* convert section header number to array index */
260 ((n) < SHN_LORESERVE ? (n) : ((n) <= SHN_HIRESERVE ? 0 : (n) - (SHN_HIRESERVE + 1 - SHN_LORESERVE)))
262 /* convert section header array index to section number */
264 ((i) < SHN_LORESERVE ? (i) : (i) + (SHN_HIRESERVE + 1 - SHN_LORESERVE))
266 /* ARM-specific attributes section definitions follow */
268 #define ATTR_VERSION_CURRENT 0x41
273 char vendor
[1]; /* NULL-terminated name */
274 /* Vendor-specific subsections follow */
277 struct attrs_subsection
281 } __attribute__((packed
));
284 #define Tag_Section 2
286 #define Tag_CPU_raw_name 4
287 #define Tag_CPU_name 5
288 #define Tag_CPU_arch 6
289 #define Tag_FP_arch 10
290 #define Tag_compatibility 32
291 #define Tag_also_compatible_with 65
292 #define Tag_conformance 67
294 /* Tag_CPU_arch values */
295 #define ELF_CPU_PREv4 0
296 #define ELF_CPU_ARMv4 1
297 #define ELF_CPU_ARMv4T 2
298 #define ELF_CPU_ARMv5T 3
299 #define ELF_CPU_ARMv5TE 4
300 #define ELF_CPU_ARMv5TEJ 5
301 #define ELF_CPU_ARMv6 6
302 #define ELF_CPU_ARMv6KZ 7
303 #define ELF_CPU_ARMv6T2 8
304 #define ELF_CPU_ARMv6K 9
305 #define ELF_CPU_ARMv7 10
306 #define ELF_CPU_ARM_v6M 11
307 #define ELF_CPU_ARMv6SM 12
308 #define ELF_CPU_ARMv7EM 13
310 /* Tag_FP_arch values */
311 #define ELF_FP_None 0
315 #define ELF_FP_v3_Short 4
317 #define ELF_FP_v4_Short 6
319 /* Machine's native values */
321 #define AROS_ELF_CLASS ELFCLASS64
323 #define AROS_ELF_CLASS ELFCLASS32
327 #define AROS_ELF_DATA ELFDATA2MSB
329 #define AROS_ELF_DATA ELFDATA2LSB
332 #if defined(__i386__) || defined(__x86_64__)
334 #define AROS_ELF_MACHINE EM_X86_64
335 #define AROS_ELF_REL SHT_RELA
338 #define AROS_ELF_MACHINE EM_386
339 #define AROS_ELF_REL SHT_REL
344 #define AROS_ELF_MACHINE EM_68K
345 #define AROS_ELF_REL SHT_RELA
349 #define AROS_ELF_MACHINE EM_PPC
350 #define AROS_ELF_REL SHT_RELA
354 #define AROS_ELF_MACHINE EM_ARM
355 #define AROS_ELF_REL SHT_REL