In memory of Chuck...
[nasm.git] / output / elfcommon.h
blob5769980ab3e3f557b5959e3eebf3658fb9188dbd
1 #ifndef OUTPUT_ELFCOMMON_H
2 #define OUTPUT_ELFCOMMON_H
4 #include "compiler.h"
5 #include <inttypes.h>
7 /* Segment types */
8 #define PT_NULL 0
9 #define PT_LOAD 1
10 #define PT_DYNAMIC 2
11 #define PT_INTERP 3
12 #define PT_NOTE 4
13 #define PT_SHLIB 5
14 #define PT_PHDR 6
15 #define PT_LOOS 0x60000000
16 #define PT_HIOS 0x6fffffff
17 #define PT_LOPROC 0x70000000
18 #define PT_HIPROC 0x7fffffff
19 #define PT_GNU_EH_FRAME 0x6474e550 /* Extension, eh? */
21 /* ELF file types */
22 #define ET_NONE 0
23 #define ET_REL 1
24 #define ET_EXEC 2
25 #define ET_DYN 3
26 #define ET_CORE 4
27 #define ET_LOPROC 0xff00
28 #define ET_HIPROC 0xffff
30 /* ELF machine types */
31 #define EM_NONE 0
32 #define EM_M32 1
33 #define EM_SPARC 2
34 #define EM_386 3
35 #define EM_68K 4
36 #define EM_88K 5
37 #define EM_486 6 /* Not used in Linux at least */
38 #define EM_860 7
39 #define EM_MIPS 8 /* R3k, bigendian(?) */
40 #define EM_MIPS_RS4_BE 10 /* R4k BE */
41 #define EM_PARISC 15
42 #define EM_SPARC32PLUS 18
43 #define EM_PPC 20
44 #define EM_PPC64 21
45 #define EM_S390 22
46 #define EM_SH 42
47 #define EM_SPARCV9 43 /* v9 = SPARC64 */
48 #define EM_H8_300H 47
49 #define EM_H8S 48
50 #define EM_IA_64 50
51 #define EM_X86_64 62
52 #define EM_CRIS 76
53 #define EM_V850 87
54 #define EM_ALPHA 0x9026 /* Interrim Alpha that stuck around */
55 #define EM_CYGNUS_V850 0x9080 /* Old v850 ID used by Cygnus */
56 #define EM_S390_OLD 0xA390 /* Obsolete interrim value for S/390 */
58 /* Dynamic type values */
59 #define DT_NULL 0
60 #define DT_NEEDED 1
61 #define DT_PLTRELSZ 2
62 #define DT_PLTGOT 3
63 #define DT_HASH 4
64 #define DT_STRTAB 5
65 #define DT_SYMTAB 6
66 #define DT_RELA 7
67 #define DT_RELASZ 8
68 #define DT_RELAENT 9
69 #define DT_STRSZ 10
70 #define DT_SYMENT 11
71 #define DT_INIT 12
72 #define DT_FINI 13
73 #define DT_SONAME 14
74 #define DT_RPATH 15
75 #define DT_SYMBOLIC 16
76 #define DT_REL 17
77 #define DT_RELSZ 18
78 #define DT_RELENT 19
79 #define DT_PLTREL 20
80 #define DT_DEBUG 21
81 #define DT_TEXTREL 22
82 #define DT_JMPREL 23
83 #define DT_LOPROC 0x70000000
84 #define DT_HIPROC 0x7fffffff
86 /* Auxilliary table entries */
87 #define AT_NULL 0 /* end of vector */
88 #define AT_IGNORE 1 /* entry should be ignored */
89 #define AT_EXECFD 2 /* file descriptor of program */
90 #define AT_PHDR 3 /* program headers for program */
91 #define AT_PHENT 4 /* size of program header entry */
92 #define AT_PHNUM 5 /* number of program headers */
93 #define AT_PAGESZ 6 /* system page size */
94 #define AT_BASE 7 /* base address of interpreter */
95 #define AT_FLAGS 8 /* flags */
96 #define AT_ENTRY 9 /* entry point of program */
97 #define AT_NOTELF 10 /* program is not ELF */
98 #define AT_UID 11 /* real uid */
99 #define AT_EUID 12 /* effective uid */
100 #define AT_GID 13 /* real gid */
101 #define AT_EGID 14 /* effective gid */
102 #define AT_PLATFORM 15 /* string identifying CPU for optimizations */
103 #define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */
104 #define AT_CLKTCK 17 /* frequency at which times() increments */
105 /* 18..22 = ? */
106 #define AT_SECURE 23 /* secure mode boolean */
108 /* Program header permission flags */
109 #define PF_X 0x1
110 #define PF_W 0x2
111 #define PF_R 0x4
113 /* Section header types */
114 #define SHT_NULL 0
115 #define SHT_PROGBITS 1
116 #define SHT_SYMTAB 2
117 #define SHT_STRTAB 3
118 #define SHT_RELA 4
119 #define SHT_HASH 5
120 #define SHT_DYNAMIC 6
121 #define SHT_NOTE 7
122 #define SHT_NOBITS 8
123 #define SHT_REL 9
124 #define SHT_SHLIB 10
125 #define SHT_DYNSYM 11
126 #define SHT_NUM 12
127 #define SHT_LOPROC 0x70000000
128 #define SHT_HIPROC 0x7fffffff
129 #define SHT_LOUSER 0x80000000
130 #define SHT_HIUSER 0xffffffff
132 /* Section header flags */
133 #define SHF_WRITE (1 << 0) /* Writable */
134 #define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
135 #define SHF_EXECINSTR (1 << 2) /* Executable */
136 #define SHF_MERGE (1 << 4) /* Might be merged */
137 #define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
138 #define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
139 #define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
140 #define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
141 required */
142 #define SHF_GROUP (1 << 9) /* Section is member of a group. */
143 #define SHF_TLS (1 << 10) /* Section hold thread-local data. */
145 /* Special section numbers */
146 #define SHN_UNDEF 0
147 #define SHN_LORESERVE 0xff00
148 #define SHN_LOPROC 0xff00
149 #define SHN_HIPROC 0xff1f
150 #define SHN_ABS 0xfff1
151 #define SHN_COMMON 0xfff2
152 #define SHN_HIRESERVE 0xffff
154 /* Lenght of magic at the start of a file */
155 #define EI_NIDENT 16
157 /* Magic number constants... */
158 #define EI_MAG0 0 /* e_ident[] indexes */
159 #define EI_MAG1 1
160 #define EI_MAG2 2
161 #define EI_MAG3 3
162 #define EI_CLASS 4
163 #define EI_DATA 5
164 #define EI_VERSION 6
165 #define EI_OSABI 7
166 #define EI_PAD 8
168 #define ELFMAG0 0x7f /* EI_MAG */
169 #define ELFMAG1 'E'
170 #define ELFMAG2 'L'
171 #define ELFMAG3 'F'
172 #define ELFMAG "\177ELF"
173 #define SELFMAG 4
175 #define ELFCLASSNONE 0 /* EI_CLASS */
176 #define ELFCLASS32 1
177 #define ELFCLASS64 2
178 #define ELFCLASSNUM 3
180 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
181 #define ELFDATA2LSB 1
182 #define ELFDATA2MSB 2
184 #define EV_NONE 0 /* e_version, EI_VERSION */
185 #define EV_CURRENT 1
186 #define EV_NUM 2
188 #define ELFOSABI_NONE 0
189 #define ELFOSABI_LINUX 3
191 /* Legal values for ST_BIND subfield of st_info (symbol binding). */
192 #define STB_LOCAL 0 /* Local symbol */
193 #define STB_GLOBAL 1 /* Global symbol */
194 #define STB_WEAK 2 /* Weak symbol */
195 #define STB_NUM 3 /* Number of defined types. */
196 #define STB_LOOS 10 /* Start of OS-specific */
197 #define STB_HIOS 12 /* End of OS-specific */
198 #define STB_LOPROC 13 /* Start of processor-specific */
199 #define STB_HIPROC 15 /* End of processor-specific */
201 /* Symbol types */
202 #define STT_NOTYPE 0 /* Symbol type is unspecified */
203 #define STT_OBJECT 1 /* Symbol is a data object */
204 #define STT_FUNC 2 /* Symbol is a code object */
205 #define STT_SECTION 3 /* Symbol associated with a section */
206 #define STT_FILE 4 /* Symbol's name is file name */
207 #define STT_COMMON 5 /* Symbol is a common data object */
208 #define STT_TLS 6 /* Symbol is thread-local data object*/
209 #define STT_NUM 7 /* Number of defined types. */
211 /* Symbol visibilities */
212 #define STV_DEFAULT 0 /* Default symbol visibility rules */
213 #define STV_INTERNAL 1 /* Processor specific hidden class */
214 #define STV_HIDDEN 2 /* Sym unavailable in other modules */
215 #define STV_PROTECTED 3 /* Not preemptible, not exported */
217 #endif /* OUTPUT_ELFCOMMON_H */