NASM 2.08rc2
[nasm/nasm.git] / output / elfcommon.h
blob78434a7eef3480731dbd8a8791dbb463eae425cd
1 /* ----------------------------------------------------------------------- *
3 * Copyright 1996-2009 The NASM Authors - All Rights Reserved
4 * See the file AUTHORS included with the NASM distribution for
5 * the specific copyright holders.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following
9 * conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 * ----------------------------------------------------------------------- */
34 #ifndef OUTPUT_ELFCOMMON_H
35 #define OUTPUT_ELFCOMMON_H
37 #include "compiler.h"
38 #include <inttypes.h>
40 /* Segment types */
41 #define PT_NULL 0
42 #define PT_LOAD 1
43 #define PT_DYNAMIC 2
44 #define PT_INTERP 3
45 #define PT_NOTE 4
46 #define PT_SHLIB 5
47 #define PT_PHDR 6
48 #define PT_LOOS 0x60000000
49 #define PT_HIOS 0x6fffffff
50 #define PT_LOPROC 0x70000000
51 #define PT_HIPROC 0x7fffffff
52 #define PT_GNU_EH_FRAME 0x6474e550 /* Extension, eh? */
54 /* ELF file types */
55 #define ET_NONE 0
56 #define ET_REL 1
57 #define ET_EXEC 2
58 #define ET_DYN 3
59 #define ET_CORE 4
60 #define ET_LOPROC 0xff00
61 #define ET_HIPROC 0xffff
63 /* ELF machine types */
64 #define EM_NONE 0
65 #define EM_M32 1
66 #define EM_SPARC 2
67 #define EM_386 3
68 #define EM_68K 4
69 #define EM_88K 5
70 #define EM_486 6 /* Not used in Linux at least */
71 #define EM_860 7
72 #define EM_MIPS 8 /* R3k, bigendian(?) */
73 #define EM_MIPS_RS4_BE 10 /* R4k BE */
74 #define EM_PARISC 15
75 #define EM_SPARC32PLUS 18
76 #define EM_PPC 20
77 #define EM_PPC64 21
78 #define EM_S390 22
79 #define EM_SH 42
80 #define EM_SPARCV9 43 /* v9 = SPARC64 */
81 #define EM_H8_300H 47
82 #define EM_H8S 48
83 #define EM_IA_64 50
84 #define EM_X86_64 62
85 #define EM_CRIS 76
86 #define EM_V850 87
87 #define EM_ALPHA 0x9026 /* Interrim Alpha that stuck around */
88 #define EM_CYGNUS_V850 0x9080 /* Old v850 ID used by Cygnus */
89 #define EM_S390_OLD 0xA390 /* Obsolete interrim value for S/390 */
91 /* Dynamic type values */
92 #define DT_NULL 0
93 #define DT_NEEDED 1
94 #define DT_PLTRELSZ 2
95 #define DT_PLTGOT 3
96 #define DT_HASH 4
97 #define DT_STRTAB 5
98 #define DT_SYMTAB 6
99 #define DT_RELA 7
100 #define DT_RELASZ 8
101 #define DT_RELAENT 9
102 #define DT_STRSZ 10
103 #define DT_SYMENT 11
104 #define DT_INIT 12
105 #define DT_FINI 13
106 #define DT_SONAME 14
107 #define DT_RPATH 15
108 #define DT_SYMBOLIC 16
109 #define DT_REL 17
110 #define DT_RELSZ 18
111 #define DT_RELENT 19
112 #define DT_PLTREL 20
113 #define DT_DEBUG 21
114 #define DT_TEXTREL 22
115 #define DT_JMPREL 23
116 #define DT_LOPROC 0x70000000
117 #define DT_HIPROC 0x7fffffff
119 /* Auxilliary table entries */
120 #define AT_NULL 0 /* end of vector */
121 #define AT_IGNORE 1 /* entry should be ignored */
122 #define AT_EXECFD 2 /* file descriptor of program */
123 #define AT_PHDR 3 /* program headers for program */
124 #define AT_PHENT 4 /* size of program header entry */
125 #define AT_PHNUM 5 /* number of program headers */
126 #define AT_PAGESZ 6 /* system page size */
127 #define AT_BASE 7 /* base address of interpreter */
128 #define AT_FLAGS 8 /* flags */
129 #define AT_ENTRY 9 /* entry point of program */
130 #define AT_NOTELF 10 /* program is not ELF */
131 #define AT_UID 11 /* real uid */
132 #define AT_EUID 12 /* effective uid */
133 #define AT_GID 13 /* real gid */
134 #define AT_EGID 14 /* effective gid */
135 #define AT_PLATFORM 15 /* string identifying CPU for optimizations */
136 #define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */
137 #define AT_CLKTCK 17 /* frequency at which times() increments */
138 /* 18..22 = ? */
139 #define AT_SECURE 23 /* secure mode boolean */
141 /* Program header permission flags */
142 #define PF_X 0x1
143 #define PF_W 0x2
144 #define PF_R 0x4
146 /* Section header types */
147 #define SHT_NULL 0
148 #define SHT_PROGBITS 1
149 #define SHT_SYMTAB 2
150 #define SHT_STRTAB 3
151 #define SHT_RELA 4
152 #define SHT_HASH 5
153 #define SHT_DYNAMIC 6
154 #define SHT_NOTE 7
155 #define SHT_NOBITS 8
156 #define SHT_REL 9
157 #define SHT_SHLIB 10
158 #define SHT_DYNSYM 11
159 #define SHT_NUM 12
160 #define SHT_LOPROC 0x70000000
161 #define SHT_HIPROC 0x7fffffff
162 #define SHT_LOUSER 0x80000000
163 #define SHT_HIUSER 0xffffffff
165 /* Section header flags */
166 #define SHF_WRITE (1 << 0) /* Writable */
167 #define SHF_ALLOC (1 << 1) /* Occupies memory during execution */
168 #define SHF_EXECINSTR (1 << 2) /* Executable */
169 #define SHF_MERGE (1 << 4) /* Might be merged */
170 #define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */
171 #define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */
172 #define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */
173 #define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling
174 required */
175 #define SHF_GROUP (1 << 9) /* Section is member of a group. */
176 #define SHF_TLS (1 << 10) /* Section hold thread-local data. */
178 /* Special section numbers */
179 #define SHN_UNDEF 0
180 #define SHN_LORESERVE 0xff00
181 #define SHN_LOPROC 0xff00
182 #define SHN_HIPROC 0xff1f
183 #define SHN_ABS 0xfff1
184 #define SHN_COMMON 0xfff2
185 #define SHN_HIRESERVE 0xffff
187 /* Lenght of magic at the start of a file */
188 #define EI_NIDENT 16
190 /* Magic number constants... */
191 #define EI_MAG0 0 /* e_ident[] indexes */
192 #define EI_MAG1 1
193 #define EI_MAG2 2
194 #define EI_MAG3 3
195 #define EI_CLASS 4
196 #define EI_DATA 5
197 #define EI_VERSION 6
198 #define EI_OSABI 7
199 #define EI_PAD 8
201 #define ELFMAG0 0x7f /* EI_MAG */
202 #define ELFMAG1 'E'
203 #define ELFMAG2 'L'
204 #define ELFMAG3 'F'
205 #define ELFMAG "\177ELF"
206 #define SELFMAG 4
208 #define ELFCLASSNONE 0 /* EI_CLASS */
209 #define ELFCLASS32 1
210 #define ELFCLASS64 2
211 #define ELFCLASSNUM 3
213 #define ELFDATANONE 0 /* e_ident[EI_DATA] */
214 #define ELFDATA2LSB 1
215 #define ELFDATA2MSB 2
217 #define EV_NONE 0 /* e_version, EI_VERSION */
218 #define EV_CURRENT 1
219 #define EV_NUM 2
221 #define ELFOSABI_NONE 0
222 #define ELFOSABI_LINUX 3
224 /* Legal values for ST_BIND subfield of st_info (symbol binding). */
225 #define STB_LOCAL 0 /* Local symbol */
226 #define STB_GLOBAL 1 /* Global symbol */
227 #define STB_WEAK 2 /* Weak symbol */
228 #define STB_NUM 3 /* Number of defined types. */
229 #define STB_LOOS 10 /* Start of OS-specific */
230 #define STB_HIOS 12 /* End of OS-specific */
231 #define STB_LOPROC 13 /* Start of processor-specific */
232 #define STB_HIPROC 15 /* End of processor-specific */
234 /* Symbol types */
235 #define STT_NOTYPE 0 /* Symbol type is unspecified */
236 #define STT_OBJECT 1 /* Symbol is a data object */
237 #define STT_FUNC 2 /* Symbol is a code object */
238 #define STT_SECTION 3 /* Symbol associated with a section */
239 #define STT_FILE 4 /* Symbol's name is file name */
240 #define STT_COMMON 5 /* Symbol is a common data object */
241 #define STT_TLS 6 /* Symbol is thread-local data object*/
242 #define STT_NUM 7 /* Number of defined types. */
244 /* Symbol visibilities */
245 #define STV_DEFAULT 0 /* Default symbol visibility rules */
246 #define STV_INTERNAL 1 /* Processor specific hidden class */
247 #define STV_HIDDEN 2 /* Sym unavailable in other modules */
248 #define STV_PROTECTED 3 /* Not preemptible, not exported */
250 #endif /* OUTPUT_ELFCOMMON_H */