4 #include <linux/types.h>
7 #ifndef elf_read_implies_exec
8 /* Executables for which elf_read_implies_exec() returns TRUE will
9 have the READ_IMPLIES_EXEC personality flag set automatically.
10 Override in asm/elf.h as needed. */
11 # define elf_read_implies_exec(ex, have_pt_gnu_stack) 0
14 /* 32-bit ELF base types. */
15 typedef __u32 Elf32_Addr
;
16 typedef __u16 Elf32_Half
;
17 typedef __u32 Elf32_Off
;
18 typedef __s32 Elf32_Sword
;
19 typedef __u32 Elf32_Word
;
21 /* 64-bit ELF base types. */
22 typedef __u64 Elf64_Addr
;
23 typedef __u16 Elf64_Half
;
24 typedef __s16 Elf64_SHalf
;
25 typedef __u64 Elf64_Off
;
26 typedef __s32 Elf64_Sword
;
27 typedef __u32 Elf64_Word
;
28 typedef __u64 Elf64_Xword
;
29 typedef __s64 Elf64_Sxword
;
31 /* These constants are for the segment types stored in the image headers */
39 #define PT_TLS 7 /* Thread local storage segment */
40 #define PT_LOOS 0x60000000 /* OS-specific */
41 #define PT_HIOS 0x6fffffff /* OS-specific */
42 #define PT_LOPROC 0x70000000
43 #define PT_HIPROC 0x7fffffff
44 #define PT_GNU_EH_FRAME 0x6474e550
46 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
48 /* These constants define the different elf file types */
54 #define ET_LOPROC 0xff00
55 #define ET_HIPROC 0xffff
57 /* These constants define the various ELF target machines */
64 #define EM_486 6 /* Perhaps disused */
67 #define EM_MIPS 8 /* MIPS R3000 (officially, big-endian only) */
69 #define EM_MIPS_RS4_BE 10 /* MIPS R4000 big-endian */
71 #define EM_PARISC 15 /* HPPA */
73 #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
75 #define EM_PPC 20 /* PowerPC */
76 #define EM_PPC64 21 /* PowerPC64 */
78 #define EM_SH 42 /* SuperH */
80 #define EM_SPARCV9 43 /* SPARC v9 64-bit */
82 #define EM_IA_64 50 /* HP/Intel IA-64 */
84 #define EM_X86_64 62 /* AMD x86-64 */
86 #define EM_S390 22 /* IBM S/390 */
88 #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */
90 #define EM_V850 87 /* NEC v850 */
92 #define EM_M32R 88 /* Renesas M32R */
94 #define EM_H8_300 46 /* Renesas H8/300,300H,H8S */
97 * This is an interim value that we will use until the committee comes
98 * up with a final number.
100 #define EM_ALPHA 0x9026
102 /* Bogus old v850 magic number, used by old tools. */
103 #define EM_CYGNUS_V850 0x9080
105 /* Bogus old m32r magic number, used by old tools. */
106 #define EM_CYGNUS_M32R 0x9041
109 * This is the old interim value for S/390 architecture
111 #define EM_S390_OLD 0xA390
113 #define EM_FRV 0x5441 /* Fujitsu FR-V */
115 /* This is the info that is needed to parse the dynamic section of the file */
118 #define DT_PLTRELSZ 2
132 #define DT_SYMBOLIC 16
138 #define DT_TEXTREL 22
140 #define DT_LOPROC 0x70000000
141 #define DT_HIPROC 0x7fffffff
143 /* This info is needed when parsing the symbol table */
151 #define STT_SECTION 3
154 #define ELF_ST_BIND(x) ((x) >> 4)
155 #define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf)
156 #define ELF32_ST_BIND(x) ELF_ST_BIND(x)
157 #define ELF32_ST_TYPE(x) ELF_ST_TYPE(x)
158 #define ELF64_ST_BIND(x) ELF_ST_BIND(x)
159 #define ELF64_ST_TYPE(x) ELF_ST_TYPE(x)
161 /* Symbolic values for the entries in the auxiliary table
162 put on the initial stack */
163 #define AT_NULL 0 /* end of vector */
164 #define AT_IGNORE 1 /* entry should be ignored */
165 #define AT_EXECFD 2 /* file descriptor of program */
166 #define AT_PHDR 3 /* program headers for program */
167 #define AT_PHENT 4 /* size of program header entry */
168 #define AT_PHNUM 5 /* number of program headers */
169 #define AT_PAGESZ 6 /* system page size */
170 #define AT_BASE 7 /* base address of interpreter */
171 #define AT_FLAGS 8 /* flags */
172 #define AT_ENTRY 9 /* entry point of program */
173 #define AT_NOTELF 10 /* program is not ELF */
174 #define AT_UID 11 /* real uid */
175 #define AT_EUID 12 /* effective uid */
176 #define AT_GID 13 /* real gid */
177 #define AT_EGID 14 /* effective gid */
178 #define AT_PLATFORM 15 /* string identifying CPU for optimizations */
179 #define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */
180 #define AT_CLKTCK 17 /* frequency at which times() increments */
182 #define AT_SECURE 23 /* secure mode boolean */
184 typedef struct dynamic
{
193 Elf64_Sxword d_tag
; /* entry tag value */
200 /* The following are used with relocations */
201 #define ELF32_R_SYM(x) ((x) >> 8)
202 #define ELF32_R_TYPE(x) ((x) & 0xff)
204 #define ELF64_R_SYM(i) ((i) >> 32)
205 #define ELF64_R_TYPE(i) ((i) & 0xffffffff)
207 typedef struct elf32_rel
{
212 typedef struct elf64_rel
{
213 Elf64_Addr r_offset
; /* Location at which to apply the action */
214 Elf64_Xword r_info
; /* index and type of relocation */
217 typedef struct elf32_rela
{
220 Elf32_Sword r_addend
;
223 typedef struct elf64_rela
{
224 Elf64_Addr r_offset
; /* Location at which to apply the action */
225 Elf64_Xword r_info
; /* index and type of relocation */
226 Elf64_Sxword r_addend
; /* Constant addend used to compute value */
229 typedef struct elf32_sym
{
233 unsigned char st_info
;
234 unsigned char st_other
;
238 typedef struct elf64_sym
{
239 Elf64_Word st_name
; /* Symbol name, index in string tbl */
240 unsigned char st_info
; /* Type and binding attributes */
241 unsigned char st_other
; /* No defined meaning, 0 */
242 Elf64_Half st_shndx
; /* Associated section index */
243 Elf64_Addr st_value
; /* Value of the symbol */
244 Elf64_Xword st_size
; /* Associated symbol size */
250 typedef struct elf32_hdr
{
251 unsigned char e_ident
[EI_NIDENT
];
253 Elf32_Half e_machine
;
254 Elf32_Word e_version
;
255 Elf32_Addr e_entry
; /* Entry point */
260 Elf32_Half e_phentsize
;
262 Elf32_Half e_shentsize
;
264 Elf32_Half e_shstrndx
;
267 typedef struct elf64_hdr
{
268 unsigned char e_ident
[16]; /* ELF "magic number" */
270 Elf64_Half e_machine
;
271 Elf64_Word e_version
;
272 Elf64_Addr e_entry
; /* Entry point virtual address */
273 Elf64_Off e_phoff
; /* Program header table file offset */
274 Elf64_Off e_shoff
; /* Section header table file offset */
277 Elf64_Half e_phentsize
;
279 Elf64_Half e_shentsize
;
281 Elf64_Half e_shstrndx
;
284 /* These constants define the permissions on sections in the program
290 typedef struct elf32_phdr
{
301 typedef struct elf64_phdr
{
304 Elf64_Off p_offset
; /* Segment file offset */
305 Elf64_Addr p_vaddr
; /* Segment virtual address */
306 Elf64_Addr p_paddr
; /* Segment physical address */
307 Elf64_Xword p_filesz
; /* Segment size in file */
308 Elf64_Xword p_memsz
; /* Segment size in memory */
309 Elf64_Xword p_align
; /* Segment alignment, file & memory */
314 #define SHT_PROGBITS 1
319 #define SHT_DYNAMIC 6
324 #define SHT_DYNSYM 11
326 #define SHT_LOPROC 0x70000000
327 #define SHT_HIPROC 0x7fffffff
328 #define SHT_LOUSER 0x80000000
329 #define SHT_HIUSER 0xffffffff
332 #define SHF_WRITE 0x1
333 #define SHF_ALLOC 0x2
334 #define SHF_EXECINSTR 0x4
335 #define SHF_MASKPROC 0xf0000000
337 /* special section indexes */
339 #define SHN_LORESERVE 0xff00
340 #define SHN_LOPROC 0xff00
341 #define SHN_HIPROC 0xff1f
342 #define SHN_ABS 0xfff1
343 #define SHN_COMMON 0xfff2
344 #define SHN_HIRESERVE 0xffff
355 Elf32_Word sh_addralign
;
356 Elf32_Word sh_entsize
;
359 typedef struct elf64_shdr
{
360 Elf64_Word sh_name
; /* Section name, index in string tbl */
361 Elf64_Word sh_type
; /* Type of section */
362 Elf64_Xword sh_flags
; /* Miscellaneous section attributes */
363 Elf64_Addr sh_addr
; /* Section virtual addr at execution */
364 Elf64_Off sh_offset
; /* Section file offset */
365 Elf64_Xword sh_size
; /* Size of section in bytes */
366 Elf64_Word sh_link
; /* Index of another section */
367 Elf64_Word sh_info
; /* Additional section information */
368 Elf64_Xword sh_addralign
; /* Section alignment */
369 Elf64_Xword sh_entsize
; /* Entry size if section holds table */
372 #define EI_MAG0 0 /* e_ident[] indexes */
382 #define ELFMAG0 0x7f /* EI_MAG */
386 #define ELFMAG "\177ELF"
389 #define ELFCLASSNONE 0 /* EI_CLASS */
392 #define ELFCLASSNUM 3
394 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
395 #define ELFDATA2LSB 1
396 #define ELFDATA2MSB 2
398 #define EV_NONE 0 /* e_version, EI_VERSION */
402 #define ELFOSABI_NONE 0
403 #define ELFOSABI_LINUX 3
406 #define ELF_OSABI ELFOSABI_NONE
409 /* Notes used in ET_CORE */
410 #define NT_PRSTATUS 1
412 #define NT_PRPSINFO 3
413 #define NT_TASKSTRUCT 4
415 #define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */
418 /* Note header in a PT_NOTE section */
419 typedef struct elf32_note
{
420 Elf32_Word n_namesz
; /* Name size */
421 Elf32_Word n_descsz
; /* Content size */
422 Elf32_Word n_type
; /* Content type */
425 /* Note header in a PT_NOTE section */
426 typedef struct elf64_note
{
427 Elf64_Word n_namesz
; /* Name size */
428 Elf64_Word n_descsz
; /* Content size */
429 Elf64_Word n_type
; /* Content type */
432 #if ELF_CLASS == ELFCLASS32
434 extern Elf32_Dyn _DYNAMIC
[];
435 #define elfhdr elf32_hdr
436 #define elf_phdr elf32_phdr
437 #define elf_note elf32_note
441 extern Elf64_Dyn _DYNAMIC
[];
442 #define elfhdr elf64_hdr
443 #define elf_phdr elf64_phdr
444 #define elf_note elf64_note
449 #endif /* _LINUX_ELF_H */