Merge branches 'acpica-fixes', 'acpi-pci-fixes' and 'acpi-debug-fixes'
[deliverable/linux.git] / include / uapi / linux / elf.h
CommitLineData
607ca46e
DH
1#ifndef _UAPI_LINUX_ELF_H
2#define _UAPI_LINUX_ELF_H
3
4#include <linux/types.h>
5#include <linux/elf-em.h>
6
7/* 32-bit ELF base types. */
8typedef __u32 Elf32_Addr;
9typedef __u16 Elf32_Half;
10typedef __u32 Elf32_Off;
11typedef __s32 Elf32_Sword;
12typedef __u32 Elf32_Word;
13
14/* 64-bit ELF base types. */
15typedef __u64 Elf64_Addr;
16typedef __u16 Elf64_Half;
17typedef __s16 Elf64_SHalf;
18typedef __u64 Elf64_Off;
19typedef __s32 Elf64_Sword;
20typedef __u32 Elf64_Word;
21typedef __u64 Elf64_Xword;
22typedef __s64 Elf64_Sxword;
23
24/* These constants are for the segment types stored in the image headers */
25#define PT_NULL 0
26#define PT_LOAD 1
27#define PT_DYNAMIC 2
28#define PT_INTERP 3
29#define PT_NOTE 4
30#define PT_SHLIB 5
31#define PT_PHDR 6
32#define PT_TLS 7 /* Thread local storage segment */
33#define PT_LOOS 0x60000000 /* OS-specific */
34#define PT_HIOS 0x6fffffff /* OS-specific */
35#define PT_LOPROC 0x70000000
36#define PT_HIPROC 0x7fffffff
37#define PT_GNU_EH_FRAME 0x6474e550
38
39#define PT_GNU_STACK (PT_LOOS + 0x474e551)
40
41/*
42 * Extended Numbering
43 *
44 * If the real number of program header table entries is larger than
45 * or equal to PN_XNUM(0xffff), it is set to sh_info field of the
46 * section header at index 0, and PN_XNUM is set to e_phnum
47 * field. Otherwise, the section header at index 0 is zero
48 * initialized, if it exists.
49 *
50 * Specifications are available in:
51 *
242260fb
CK
52 * - Oracle: Linker and Libraries.
53 * Part No: 817–1984–19, August 2011.
54 * http://docs.oracle.com/cd/E18752_01/pdf/817-1984.pdf
607ca46e
DH
55 *
56 * - System V ABI AMD64 Architecture Processor Supplement
242260fb
CK
57 * Draft Version 0.99.4,
58 * January 13, 2010.
59 * http://www.cs.washington.edu/education/courses/cse351/12wi/supp-docs/abi.pdf
607ca46e
DH
60 */
61#define PN_XNUM 0xffff
62
63/* These constants define the different elf file types */
64#define ET_NONE 0
65#define ET_REL 1
66#define ET_EXEC 2
67#define ET_DYN 3
68#define ET_CORE 4
69#define ET_LOPROC 0xff00
70#define ET_HIPROC 0xffff
71
72/* This is the info that is needed to parse the dynamic section of the file */
73#define DT_NULL 0
74#define DT_NEEDED 1
75#define DT_PLTRELSZ 2
76#define DT_PLTGOT 3
77#define DT_HASH 4
78#define DT_STRTAB 5
79#define DT_SYMTAB 6
80#define DT_RELA 7
81#define DT_RELASZ 8
82#define DT_RELAENT 9
83#define DT_STRSZ 10
84#define DT_SYMENT 11
85#define DT_INIT 12
86#define DT_FINI 13
87#define DT_SONAME 14
88#define DT_RPATH 15
89#define DT_SYMBOLIC 16
90#define DT_REL 17
91#define DT_RELSZ 18
92#define DT_RELENT 19
93#define DT_PLTREL 20
94#define DT_DEBUG 21
95#define DT_TEXTREL 22
96#define DT_JMPREL 23
97#define DT_ENCODING 32
98#define OLD_DT_LOOS 0x60000000
99#define DT_LOOS 0x6000000d
100#define DT_HIOS 0x6ffff000
101#define DT_VALRNGLO 0x6ffffd00
102#define DT_VALRNGHI 0x6ffffdff
103#define DT_ADDRRNGLO 0x6ffffe00
104#define DT_ADDRRNGHI 0x6ffffeff
105#define DT_VERSYM 0x6ffffff0
106#define DT_RELACOUNT 0x6ffffff9
107#define DT_RELCOUNT 0x6ffffffa
108#define DT_FLAGS_1 0x6ffffffb
109#define DT_VERDEF 0x6ffffffc
110#define DT_VERDEFNUM 0x6ffffffd
111#define DT_VERNEED 0x6ffffffe
112#define DT_VERNEEDNUM 0x6fffffff
113#define OLD_DT_HIOS 0x6fffffff
114#define DT_LOPROC 0x70000000
115#define DT_HIPROC 0x7fffffff
116
117/* This info is needed when parsing the symbol table */
118#define STB_LOCAL 0
119#define STB_GLOBAL 1
120#define STB_WEAK 2
121
122#define STT_NOTYPE 0
123#define STT_OBJECT 1
124#define STT_FUNC 2
125#define STT_SECTION 3
126#define STT_FILE 4
127#define STT_COMMON 5
128#define STT_TLS 6
129
130#define ELF_ST_BIND(x) ((x) >> 4)
131#define ELF_ST_TYPE(x) (((unsigned int) x) & 0xf)
132#define ELF32_ST_BIND(x) ELF_ST_BIND(x)
133#define ELF32_ST_TYPE(x) ELF_ST_TYPE(x)
134#define ELF64_ST_BIND(x) ELF_ST_BIND(x)
135#define ELF64_ST_TYPE(x) ELF_ST_TYPE(x)
136
137typedef struct dynamic{
138 Elf32_Sword d_tag;
139 union{
140 Elf32_Sword d_val;
141 Elf32_Addr d_ptr;
142 } d_un;
143} Elf32_Dyn;
144
145typedef struct {
146 Elf64_Sxword d_tag; /* entry tag value */
147 union {
148 Elf64_Xword d_val;
149 Elf64_Addr d_ptr;
150 } d_un;
151} Elf64_Dyn;
152
153/* The following are used with relocations */
154#define ELF32_R_SYM(x) ((x) >> 8)
155#define ELF32_R_TYPE(x) ((x) & 0xff)
156
157#define ELF64_R_SYM(i) ((i) >> 32)
158#define ELF64_R_TYPE(i) ((i) & 0xffffffff)
159
160typedef struct elf32_rel {
161 Elf32_Addr r_offset;
162 Elf32_Word r_info;
163} Elf32_Rel;
164
165typedef struct elf64_rel {
166 Elf64_Addr r_offset; /* Location at which to apply the action */
167 Elf64_Xword r_info; /* index and type of relocation */
168} Elf64_Rel;
169
170typedef struct elf32_rela{
171 Elf32_Addr r_offset;
172 Elf32_Word r_info;
173 Elf32_Sword r_addend;
174} Elf32_Rela;
175
176typedef struct elf64_rela {
177 Elf64_Addr r_offset; /* Location at which to apply the action */
178 Elf64_Xword r_info; /* index and type of relocation */
179 Elf64_Sxword r_addend; /* Constant addend used to compute value */
180} Elf64_Rela;
181
182typedef struct elf32_sym{
183 Elf32_Word st_name;
184 Elf32_Addr st_value;
185 Elf32_Word st_size;
186 unsigned char st_info;
187 unsigned char st_other;
188 Elf32_Half st_shndx;
189} Elf32_Sym;
190
191typedef struct elf64_sym {
192 Elf64_Word st_name; /* Symbol name, index in string tbl */
193 unsigned char st_info; /* Type and binding attributes */
194 unsigned char st_other; /* No defined meaning, 0 */
195 Elf64_Half st_shndx; /* Associated section index */
196 Elf64_Addr st_value; /* Value of the symbol */
197 Elf64_Xword st_size; /* Associated symbol size */
198} Elf64_Sym;
199
200
201#define EI_NIDENT 16
202
203typedef struct elf32_hdr{
204 unsigned char e_ident[EI_NIDENT];
205 Elf32_Half e_type;
206 Elf32_Half e_machine;
207 Elf32_Word e_version;
208 Elf32_Addr e_entry; /* Entry point */
209 Elf32_Off e_phoff;
210 Elf32_Off e_shoff;
211 Elf32_Word e_flags;
212 Elf32_Half e_ehsize;
213 Elf32_Half e_phentsize;
214 Elf32_Half e_phnum;
215 Elf32_Half e_shentsize;
216 Elf32_Half e_shnum;
217 Elf32_Half e_shstrndx;
218} Elf32_Ehdr;
219
220typedef struct elf64_hdr {
221 unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */
222 Elf64_Half e_type;
223 Elf64_Half e_machine;
224 Elf64_Word e_version;
225 Elf64_Addr e_entry; /* Entry point virtual address */
226 Elf64_Off e_phoff; /* Program header table file offset */
227 Elf64_Off e_shoff; /* Section header table file offset */
228 Elf64_Word e_flags;
229 Elf64_Half e_ehsize;
230 Elf64_Half e_phentsize;
231 Elf64_Half e_phnum;
232 Elf64_Half e_shentsize;
233 Elf64_Half e_shnum;
234 Elf64_Half e_shstrndx;
235} Elf64_Ehdr;
236
237/* These constants define the permissions on sections in the program
238 header, p_flags. */
239#define PF_R 0x4
240#define PF_W 0x2
241#define PF_X 0x1
242
243typedef struct elf32_phdr{
244 Elf32_Word p_type;
245 Elf32_Off p_offset;
246 Elf32_Addr p_vaddr;
247 Elf32_Addr p_paddr;
248 Elf32_Word p_filesz;
249 Elf32_Word p_memsz;
250 Elf32_Word p_flags;
251 Elf32_Word p_align;
252} Elf32_Phdr;
253
254typedef struct elf64_phdr {
255 Elf64_Word p_type;
256 Elf64_Word p_flags;
257 Elf64_Off p_offset; /* Segment file offset */
258 Elf64_Addr p_vaddr; /* Segment virtual address */
259 Elf64_Addr p_paddr; /* Segment physical address */
260 Elf64_Xword p_filesz; /* Segment size in file */
261 Elf64_Xword p_memsz; /* Segment size in memory */
262 Elf64_Xword p_align; /* Segment alignment, file & memory */
263} Elf64_Phdr;
264
265/* sh_type */
266#define SHT_NULL 0
267#define SHT_PROGBITS 1
268#define SHT_SYMTAB 2
269#define SHT_STRTAB 3
270#define SHT_RELA 4
271#define SHT_HASH 5
272#define SHT_DYNAMIC 6
273#define SHT_NOTE 7
274#define SHT_NOBITS 8
275#define SHT_REL 9
276#define SHT_SHLIB 10
277#define SHT_DYNSYM 11
278#define SHT_NUM 12
279#define SHT_LOPROC 0x70000000
280#define SHT_HIPROC 0x7fffffff
281#define SHT_LOUSER 0x80000000
282#define SHT_HIUSER 0xffffffff
283
284/* sh_flags */
8d98e96b
JY
285#define SHF_WRITE 0x1
286#define SHF_ALLOC 0x2
287#define SHF_EXECINSTR 0x4
288#define SHF_RELA_LIVEPATCH 0x00100000
289#define SHF_MASKPROC 0xf0000000
607ca46e
DH
290
291/* special section indexes */
292#define SHN_UNDEF 0
293#define SHN_LORESERVE 0xff00
294#define SHN_LOPROC 0xff00
295#define SHN_HIPROC 0xff1f
8d98e96b 296#define SHN_LIVEPATCH 0xff20
607ca46e
DH
297#define SHN_ABS 0xfff1
298#define SHN_COMMON 0xfff2
299#define SHN_HIRESERVE 0xffff
300
301typedef struct elf32_shdr {
302 Elf32_Word sh_name;
303 Elf32_Word sh_type;
304 Elf32_Word sh_flags;
305 Elf32_Addr sh_addr;
306 Elf32_Off sh_offset;
307 Elf32_Word sh_size;
308 Elf32_Word sh_link;
309 Elf32_Word sh_info;
310 Elf32_Word sh_addralign;
311 Elf32_Word sh_entsize;
312} Elf32_Shdr;
313
314typedef struct elf64_shdr {
315 Elf64_Word sh_name; /* Section name, index in string tbl */
316 Elf64_Word sh_type; /* Type of section */
317 Elf64_Xword sh_flags; /* Miscellaneous section attributes */
318 Elf64_Addr sh_addr; /* Section virtual addr at execution */
319 Elf64_Off sh_offset; /* Section file offset */
320 Elf64_Xword sh_size; /* Size of section in bytes */
321 Elf64_Word sh_link; /* Index of another section */
322 Elf64_Word sh_info; /* Additional section information */
323 Elf64_Xword sh_addralign; /* Section alignment */
324 Elf64_Xword sh_entsize; /* Entry size if section holds table */
325} Elf64_Shdr;
326
327#define EI_MAG0 0 /* e_ident[] indexes */
328#define EI_MAG1 1
329#define EI_MAG2 2
330#define EI_MAG3 3
331#define EI_CLASS 4
332#define EI_DATA 5
333#define EI_VERSION 6
334#define EI_OSABI 7
335#define EI_PAD 8
336
337#define ELFMAG0 0x7f /* EI_MAG */
338#define ELFMAG1 'E'
339#define ELFMAG2 'L'
340#define ELFMAG3 'F'
341#define ELFMAG "\177ELF"
342#define SELFMAG 4
343
344#define ELFCLASSNONE 0 /* EI_CLASS */
345#define ELFCLASS32 1
346#define ELFCLASS64 2
347#define ELFCLASSNUM 3
348
349#define ELFDATANONE 0 /* e_ident[EI_DATA] */
350#define ELFDATA2LSB 1
351#define ELFDATA2MSB 2
352
353#define EV_NONE 0 /* e_version, EI_VERSION */
354#define EV_CURRENT 1
355#define EV_NUM 2
356
357#define ELFOSABI_NONE 0
358#define ELFOSABI_LINUX 3
359
360#ifndef ELF_OSABI
361#define ELF_OSABI ELFOSABI_NONE
362#endif
363
364/*
365 * Notes used in ET_CORE. Architectures export some of the arch register sets
366 * using the corresponding note types via the PTRACE_GETREGSET and
367 * PTRACE_SETREGSET requests.
368 */
369#define NT_PRSTATUS 1
370#define NT_PRFPREG 2
371#define NT_PRPSINFO 3
372#define NT_TASKSTRUCT 4
373#define NT_AUXV 6
374/*
375 * Note to userspace developers: size of NT_SIGINFO note may increase
376 * in the future to accomodate more fields, don't assume it is fixed!
377 */
378#define NT_SIGINFO 0x53494749
379#define NT_FILE 0x46494c45
380#define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */
381#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
382#define NT_PPC_SPE 0x101 /* PowerPC SPE/EVR registers */
383#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
384#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
385#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
386#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
387#define NT_S390_HIGH_GPRS 0x300 /* s390 upper register halves */
388#define NT_S390_TIMER 0x301 /* s390 timer register */
389#define NT_S390_TODCMP 0x302 /* s390 TOD clock comparator register */
390#define NT_S390_TODPREG 0x303 /* s390 TOD programmable register */
391#define NT_S390_CTRS 0x304 /* s390 control registers */
392#define NT_S390_PREFIX 0x305 /* s390 prefix register */
393#define NT_S390_LAST_BREAK 0x306 /* s390 breaking event address */
394#define NT_S390_SYSTEM_CALL 0x307 /* s390 system call restart data */
395#define NT_S390_TDB 0x308 /* s390 transaction diagnostic block */
80703617
MS
396#define NT_S390_VXRS_LOW 0x309 /* s390 vector registers 0-15 upper half */
397#define NT_S390_VXRS_HIGH 0x30a /* s390 vector registers 16-31 */
607ca46e
DH
398#define NT_ARM_VFP 0x400 /* ARM VFP/NEON registers */
399#define NT_ARM_TLS 0x401 /* ARM TLS register */
400#define NT_ARM_HW_BREAK 0x402 /* ARM hardware breakpoint registers */
401#define NT_ARM_HW_WATCH 0x403 /* ARM hardware watchpoint registers */
766a85d7 402#define NT_ARM_SYSTEM_CALL 0x404 /* ARM system call number */
bc3966bf
JH
403#define NT_METAG_CBUF 0x500 /* Metag catch buffer registers */
404#define NT_METAG_RPIPE 0x501 /* Metag read pipeline state */
876d6dcd 405#define NT_METAG_TLS 0x502 /* Metag TLS pointer */
607ca46e
DH
406
407
408/* Note header in a PT_NOTE section */
409typedef struct elf32_note {
410 Elf32_Word n_namesz; /* Name size */
411 Elf32_Word n_descsz; /* Content size */
412 Elf32_Word n_type; /* Content type */
413} Elf32_Nhdr;
414
415/* Note header in a PT_NOTE section */
416typedef struct elf64_note {
417 Elf64_Word n_namesz; /* Name size */
418 Elf64_Word n_descsz; /* Content size */
419 Elf64_Word n_type; /* Content type */
420} Elf64_Nhdr;
421
422#endif /* _UAPI_LINUX_ELF_H */
This page took 0.186422 seconds and 5 git commands to generate.