Merge branch 'vendor/OPENSSL'
[dragonfly.git] / sys / sys / elf_common.h
1 /*-
2  * Copyright (c) 1998 John D. Polstra.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26
27 #ifndef _SYS_ELF_COMMON_H_
28 #define _SYS_ELF_COMMON_H_
29
30 #ifndef _SYS_TYPES_H_
31 #include <sys/types.h>
32 #endif
33
34 /*
35  * ELF definitions that are independent of architecture or word size.
36  */
37
38 /*
39  * Note header.  The ".note" section contains an array of notes.  Each
40  * begins with this header, aligned to a word boundary.  Immediately
41  * following the note header is n_namesz bytes of name, padded to the
42  * next word boundary.  Then comes n_descsz bytes of descriptor, again
43  * padded to a word boundary.  The values of n_namesz and n_descsz do
44  * not include the padding.
45  */
46
47 typedef struct {
48         u_int32_t       n_namesz;       /* Length of name. */
49         u_int32_t       n_descsz;       /* Length of descriptor. */
50         u_int32_t       n_type;         /* Type of this note. */
51 } Elf_Note;
52
53 /* Indexes into the e_ident array.  Keep synced with
54    http://www.sco.com/developers/gabi/latest/ch4.eheader.html */
55 #define EI_MAG0         0       /* Magic number, byte 0. */
56 #define EI_MAG1         1       /* Magic number, byte 1. */
57 #define EI_MAG2         2       /* Magic number, byte 2. */
58 #define EI_MAG3         3       /* Magic number, byte 3. */
59 #define EI_CLASS        4       /* Class of machine. */
60 #define EI_DATA         5       /* Data format. */
61 #define EI_VERSION      6       /* ELF format version. */
62 #define EI_OSABI        7       /* Operating system / ABI identification */
63 #define EI_ABIVERSION   8       /* ABI version */
64 #define EI_PAD          9       /* Start of padding (per SVR4 ABI). */
65 #define EI_NIDENT       16      /* Size of e_ident array. */
66
67 /* Values for the magic number bytes. */
68 #define ELFMAG0         0x7f
69 #define ELFMAG1         'E'
70 #define ELFMAG2         'L'
71 #define ELFMAG3         'F'
72 #define ELFMAG          "\177ELF"       /* magic string */
73 #define SELFMAG         4               /* magic string size */
74
75 /* Values for e_ident[EI_VERSION] and e_version. */
76 #define EV_NONE         0
77 #define EV_CURRENT      1
78
79 /* Values for e_ident[EI_CLASS]. */
80 #define ELFCLASSNONE    0       /* Unknown class. */
81 #define ELFCLASS32      1       /* 32-bit architecture. */
82 #define ELFCLASS64      2       /* 64-bit architecture. */
83
84 /* Values for e_ident[EI_DATA]. */
85 #define ELFDATANONE     0       /* Unknown data format. */
86 #define ELFDATA2LSB     1       /* 2's complement little-endian. */
87 #define ELFDATA2MSB     2       /* 2's complement big-endian. */
88
89 /* Values for e_ident[EI_OSABI]. */
90 #define ELFOSABI_SYSV           0       /* symbol used in old spec */
91 #define ELFOSABI_NONE           0       /* UNIX System V ABI */
92 #define ELFOSABI_HPUX           1       /* HP-UX operating system */
93 #define ELFOSABI_NETBSD         2       /* NetBSD */
94 #define ELFOSABI_GNU            3       /* GNU */
95 #define ELFOSABI_LINUX          3       /* Alias for ELFOSABI_GNU */
96 #define ELFOSABI_SOLARIS        6       /* Solaris */
97 #define ELFOSABI_AIX            7       /* AIX */
98 #define ELFOSABI_IRIX           8       /* IRIX */
99 #define ELFOSABI_FREEBSD        9       /* FreeBSD */
100 #define ELFOSABI_TRU64          10      /* TRU64 UNIX */
101 #define ELFOSABI_MODESTO        11      /* Novell Modesto */
102 #define ELFOSABI_OPENBSD        12      /* OpenBSD */
103 #define ELFOSABI_OPENVMS        13      /* OpenVMS */
104 #define ELFOSABI_NSK            14      /* Hewlett-Packard Non-Stop Kernel */
105 #define ELFOSABI_AROS           15      /* AROS */
106 #define ELFOSABI_FENIXOS        16      /* FenixOS */
107 #define ELFOSABI_C6000_ELFABI   64      /* Bare-metal TMS320C6000 */
108 #define ELFOSABI_C6000_LINUX    65      /* Linux TMS320C6000 */
109 #define ELFOSABI_ARM            97      /* ARM */
110 #define ELFOSABI_STANDALONE     255     /* Standalone (embedded) application */
111
112 /* e_ident */
113 #define IS_ELF(ehdr)    ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
114                          (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
115                          (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
116                          (ehdr).e_ident[EI_MAG3] == ELFMAG3)
117
118 /* Values for e_type, which identifies the object file type.  */
119
120 #define ET_NONE         0       /* No file type */
121 #define ET_REL          1       /* Relocatable file */
122 #define ET_EXEC         2       /* Executable file */
123 #define ET_DYN          3       /* Shared object file */
124 #define ET_CORE         4       /* Core file */
125 #define ET_LOOS         0xFE00  /* Operating system-specific */
126 #define ET_HIOS         0xFEFF  /* Operating system-specific */
127 #define ET_LOPROC       0xFF00  /* Processor-specific */
128 #define ET_HIPROC       0xFFFF  /* Processor-specific */
129
130 /* Values for e_machine, which identifies the architecture.  These numbers
131    are officially assigned by registry@sco.com.  See below for a list of
132    ad-hoc numbers used during initial development.  */
133
134 #define EM_NONE           0     /* No machine */
135 #define EM_M32            1     /* AT&T WE 32100 */
136 #define EM_SPARC          2     /* SUN SPARC */
137 #define EM_386            3     /* Intel 80386 */
138 #define EM_68K            4     /* Motorola m68k family */
139 #define EM_88K            5     /* Motorola m88k family */
140 #define EM_486            6     /* Intel 80486 *//* Reserved for future use */
141 #define EM_860            7     /* Intel 80860 */
142 #define EM_MIPS           8     /* MIPS R3000 (officially, big-endian only) */
143 #define EM_S370           9     /* IBM System/370 */
144 #define EM_MIPS_RS3_LE   10     /* MIPS R3000 little-endian (Oct 4 1999 Draft) Deprecated */
145 #define EM_res011        11     /* Reserved */
146 #define EM_res012        12     /* Reserved */
147 #define EM_res013        13     /* Reserved */
148 #define EM_res014        14     /* Reserved */
149 #define EM_PARISC        15     /* HPPA */
150 #define EM_res016        16     /* Reserved */
151 #define EM_VPP550        17     /* Fujitsu VPP500 */
152 #define EM_SPARC32PLUS   18     /* Sun's "v8plus" */
153 #define EM_960           19     /* Intel 80960 */
154 #define EM_PPC           20     /* PowerPC */
155 #define EM_PPC64         21     /* 64-bit PowerPC */
156 #define EM_S390          22     /* IBM S/390 */
157 #define EM_SPU           23     /* Sony/Toshiba/IBM SPU */
158 #define EM_res024        24     /* Reserved */
159 #define EM_res025        25     /* Reserved */
160 #define EM_res026        26     /* Reserved */
161 #define EM_res027        27     /* Reserved */
162 #define EM_res028        28     /* Reserved */
163 #define EM_res029        29     /* Reserved */
164 #define EM_res030        30     /* Reserved */
165 #define EM_res031        31     /* Reserved */
166 #define EM_res032        32     /* Reserved */
167 #define EM_res033        33     /* Reserved */
168 #define EM_res034        34     /* Reserved */
169 #define EM_res035        35     /* Reserved */
170 #define EM_V800          36     /* NEC V800 series */
171 #define EM_FR20          37     /* Fujitsu FR20 */
172 #define EM_RH32          38     /* TRW RH32 */
173 #define EM_MCORE         39     /* Motorola M*Core */ /* May also be taken by Fujitsu MMA */
174 #define EM_RCE           39     /* Old name for MCore */
175 #define EM_ARM           40     /* ARM */
176 #define EM_OLD_ALPHA     41     /* Digital Alpha */
177 #define EM_SH            42     /* Renesas (formerly Hitachi) / SuperH SH */
178 #define EM_SPARCV9       43     /* SPARC v9 64-bit */
179 #define EM_TRICORE       44     /* Siemens Tricore embedded processor */
180 #define EM_ARC           45     /* ARC Cores */
181 #define EM_H8_300        46     /* Renesas (formerly Hitachi) H8/300 */
182 #define EM_H8_300H       47     /* Renesas (formerly Hitachi) H8/300H */
183 #define EM_H8S           48     /* Renesas (formerly Hitachi) H8S */
184 #define EM_H8_500        49     /* Renesas (formerly Hitachi) H8/500 */
185 #define EM_IA_64         50     /* Intel IA-64 Processor */
186 #define EM_MIPS_X        51     /* Stanford MIPS-X */
187 #define EM_COLDFIRE      52     /* Motorola Coldfire */
188 #define EM_68HC12        53     /* Motorola M68HC12 */
189 #define EM_MMA           54     /* Fujitsu Multimedia Accelerator */
190 #define EM_PCP           55     /* Siemens PCP */
191 #define EM_NCPU          56     /* Sony nCPU embedded RISC processor */
192 #define EM_NDR1          57     /* Denso NDR1 microprocessor */
193 #define EM_STARCORE      58     /* Motorola Star*Core processor */
194 #define EM_ME16          59     /* Toyota ME16 processor */
195 #define EM_ST100         60     /* STMicroelectronics ST100 processor */
196 #define EM_TINYJ         61     /* Advanced Logic Corp. TinyJ embedded processor */
197 #define EM_X86_64        62     /* Advanced Micro Devices X86-64 processor */
198 #define EM_PDSP          63     /* Sony DSP Processor */
199 #define EM_PDP10         64     /* Digital Equipment Corp. PDP-10 */
200 #define EM_PDP11         65     /* Digital Equipment Corp. PDP-11 */
201 #define EM_FX66          66     /* Siemens FX66 microcontroller */
202 #define EM_ST9PLUS       67     /* STMicroelectronics ST9+ 8/16 bit microcontroller */
203 #define EM_ST7           68     /* STMicroelectronics ST7 8-bit microcontroller */
204 #define EM_68HC16        69     /* Motorola MC68HC16 Microcontroller */
205 #define EM_68HC11        70     /* Motorola MC68HC11 Microcontroller */
206 #define EM_68HC08        71     /* Motorola MC68HC08 Microcontroller */
207 #define EM_68HC05        72     /* Motorola MC68HC05 Microcontroller */
208 #define EM_SVX           73     /* Silicon Graphics SVx */
209 #define EM_ST19          74     /* STMicroelectronics ST19 8-bit cpu */
210 #define EM_VAX           75     /* Digital VAX */
211 #define EM_CRIS          76     /* Axis Communications 32-bit embedded processor */
212 #define EM_JAVELIN       77     /* Infineon Technologies 32-bit embedded cpu */
213 #define EM_FIREPATH      78     /* Element 14 64-bit DSP processor */
214 #define EM_ZSP           79     /* LSI Logic's 16-bit DSP processor */
215 #define EM_MMIX          80     /* Donald Knuth's educational 64-bit processor */
216 #define EM_HUANY         81     /* Harvard's machine-independent format */
217 #define EM_PRISM         82     /* SiTera Prism */
218 #define EM_AVR           83     /* Atmel AVR 8-bit microcontroller */
219 #define EM_FR30          84     /* Fujitsu FR30 */
220 #define EM_D10V          85     /* Mitsubishi D10V */
221 #define EM_D30V          86     /* Mitsubishi D30V */
222 #define EM_V850          87     /* Renesas V850 (formerly NEC V850) */
223 #define EM_M32R          88     /* Renesas M32R (formerly Mitsubishi M32R) */
224 #define EM_MN10300       89     /* Matsushita MN10300 */
225 #define EM_MN10200       90     /* Matsushita MN10200 */
226 #define EM_PJ            91     /* picoJava */
227 #define EM_OPENRISC      92     /* OpenRISC 32-bit embedded processor */
228 #define EM_ARC_A5        93     /* ARC Cores Tangent-A5 */
229 #define EM_XTENSA        94     /* Tensilica Xtensa Architecture */
230 #define EM_VIDEOCORE     95     /* Alphamosaic VideoCore processor */
231 #define EM_TMM_GPP       96     /* Thompson Multimedia General Purpose Processor */
232 #define EM_NS32K         97     /* National Semiconductor 32000 series */
233 #define EM_TPC           98     /* Tenor Network TPC processor */
234 #define EM_SNP1K         99     /* Trebia SNP 1000 processor */
235 #define EM_ST200        100     /* STMicroelectronics ST200 microcontroller */
236 #define EM_IP2K         101     /* Ubicom IP2022 micro controller */
237 #define EM_MAX          102     /* MAX Processor */
238 #define EM_CR           103     /* National Semiconductor CompactRISC */
239 #define EM_F2MC16       104     /* Fujitsu F2MC16 */
240 #define EM_MSP430       105     /* TI msp430 micro controller */
241 #define EM_BLACKFIN     106     /* ADI Blackfin */
242 #define EM_SE_C33       107     /* S1C33 Family of Seiko Epson processors */
243 #define EM_SEP          108     /* Sharp embedded microprocessor */
244 #define EM_ARCA         109     /* Arca RISC Microprocessor */
245 #define EM_UNICORE      110     /* Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */
246 #define EM_EXCESS       111     /* eXcess: 16/32/64-bit configurable embedded CPU */
247 #define EM_DXP          112     /* Icera Semiconductor Inc. Deep Execution Processor */
248 #define EM_ALTERA_NIOS2 113     /* Altera Nios II soft-core processor */
249 #define EM_CRX          114     /* National Semiconductor CRX */
250 #define EM_XGATE        115     /* Motorola XGATE embedded processor */
251 #define EM_C166         116     /* Infineon C16x/XC16x processor */
252 #define EM_M16C         117     /* Renesas M16C series microprocessors */
253 #define EM_DSPIC30F     118     /* Microchip Technology dsPIC30F Digital Signal Controller */
254 #define EM_CE           119     /* Freescale Communication Engine RISC core */
255 #define EM_M32C         120     /* Renesas M32C series microprocessors */
256 #define EM_res121       121     /* Reserved */
257 #define EM_res122       122     /* Reserved */
258 #define EM_res123       123     /* Reserved */
259 #define EM_res124       124     /* Reserved */
260 #define EM_res125       125     /* Reserved */
261 #define EM_res126       126     /* Reserved */
262 #define EM_res127       127     /* Reserved */
263 #define EM_res128       128     /* Reserved */
264 #define EM_res129       129     /* Reserved */
265 #define EM_res130       130     /* Reserved */
266 #define EM_TSK3000      131     /* Altium TSK3000 core */
267 #define EM_RS08         132     /* Freescale RS08 embedded processor */
268 #define EM_res133       133     /* Reserved */
269 #define EM_ECOG2        134     /* Cyan Technology eCOG2 microprocessor */
270 #define EM_SCORE        135     /* Sunplus Score */
271 #define EM_SCORE7       135     /* Sunplus S+core7 RISC processor */
272 #define EM_DSP24        136     /* New Japan Radio (NJR) 24-bit DSP Processor */
273 #define EM_VIDEOCORE3   137     /* Broadcom VideoCore III processor */
274 #define EM_LATTICEMICO32 138    /* RISC processor for Lattice FPGA architecture */
275 #define EM_SE_C17       139     /* Seiko Epson C17 family */
276 #define EM_TI_C6000     140     /* Texas Instruments TMS320C6000 DSP family */
277 #define EM_TI_C2000     141     /* Texas Instruments TMS320C2000 DSP family */
278 #define EM_TI_C5500     142     /* Texas Instruments TMS320C55x DSP family */
279 #define EM_res143       143     /* Reserved */
280 #define EM_res144       144     /* Reserved */
281 #define EM_res145       145     /* Reserved */
282 #define EM_res146       146     /* Reserved */
283 #define EM_res147       147     /* Reserved */
284 #define EM_res148       148     /* Reserved */
285 #define EM_res149       149     /* Reserved */
286 #define EM_res150       150     /* Reserved */
287 #define EM_res151       151     /* Reserved */
288 #define EM_res152       152     /* Reserved */
289 #define EM_res153       153     /* Reserved */
290 #define EM_res154       154     /* Reserved */
291 #define EM_res155       155     /* Reserved */
292 #define EM_res156       156     /* Reserved */
293 #define EM_res157       157     /* Reserved */
294 #define EM_res158       158     /* Reserved */
295 #define EM_res159       159     /* Reserved */
296 #define EM_MMDSP_PLUS   160     /* STMicroelectronics 64bit VLIW Data Signal Processor */
297 #define EM_CYPRESS_M8C  161     /* Cypress M8C microprocessor */
298 #define EM_R32C         162     /* Renesas R32C series microprocessors */
299 #define EM_TRIMEDIA     163     /* NXP Semiconductors TriMedia architecture family */
300 #define EM_QDSP6        164     /* QUALCOMM DSP6 Processor */
301 #define EM_8051         165     /* Intel 8051 and variants */
302 #define EM_STXP7X       166     /* STMicroelectronics STxP7x family */
303 #define EM_NDS32        167     /* Andes Technology compact code size embedded RISC processor family */
304 #define EM_ECOG1        168     /* Cyan Technology eCOG1X family */
305 #define EM_ECOG1X       168     /* Cyan Technology eCOG1X family */
306 #define EM_MAXQ30       169     /* Dallas Semiconductor MAXQ30 Core Micro-controllers */
307 #define EM_XIMO16       170     /* New Japan Radio (NJR) 16-bit DSP Processor */
308 #define EM_MANIK        171     /* M2000 Reconfigurable RISC Microprocessor */
309 #define EM_CRAYNV2      172     /* Cray Inc. NV2 vector architecture */
310 #define EM_RX           173     /* Renesas RX family */
311 #define EM_METAG        174     /* Imagination Technologies META processor architecture */
312 #define EM_MCST_ELBRUS  175     /* MCST Elbrus general purpose hardware architecture */
313 #define EM_ECOG16       176     /* Cyan Technology eCOG16 family */
314 #define EM_CR16         177     /* National Semiconductor CompactRISC 16-bit processor */
315 #define EM_ETPU         178     /* Freescale Extended Time Processing Unit */
316 #define EM_SLE9X        179     /* Infineon Technologies SLE9X core */
317 #define EM_L1OM         180     /* Intel L1OM */
318 #define EM_K1OM         181     /* Intel K1OM */
319 #define EM_INTEL182     182     /* Reserved by Intel */
320 #define EM_res183       183     /* Reserved by ARM */
321 #define EM_res184       184     /* Reserved by ARM */
322 #define EM_AVR32        185     /* Atmel Corporation 32-bit microprocessor family */
323 #define EM_STM8         186     /* STMicroeletronics STM8 8-bit microcontroller */
324 #define EM_TILE64       187     /* Tilera TILE64 multicore architecture family */
325 #define EM_TILEPRO      188     /* Tilera TILEPro multicore architecture family */
326 #define EM_MICROBLAZE   189     /* Xilinx MicroBlaze 32-bit RISC soft processor core */
327 #define EM_CUDA         190     /* NVIDIA CUDA architecture */
328 #define EM_TILEGX       191     /* Tilera TILE-Gx multicore architecture family */
329
330 /* Special section indexes. */
331
332 #define SHN_UNDEF            0          /* Undefined, missing, irrelevant. */
333 #define SHN_LORESERVE   0xff00          /* First of reserved range. */
334 #define SHN_LOPROC      0xff00          /* First processor-specific. */
335 #define SHN_HIPROC      0xff1f          /* Last processor-specific. */
336 #define SHN_LOOS        0xff20          /* First operating system-specific. */
337 #define SHN_HIOS        0xff3f          /* Last operating system-specific. */
338 #define SHN_ABS         0xfff1          /* Absolute values. */
339 #define SHN_COMMON      0xfff2          /* Common data. */
340 #define SHN_XINDEX      0xffff          /* Escape -- index stored elsewhere. */
341 #define SHN_HIRESERVE   0xffff          /* Last of reserved range. */
342
343 /* Values for program header, p_type field. */
344
345 #define PT_NULL         0               /* Program header table entry unused */
346 #define PT_LOAD         1               /* Loadable program segment */
347 #define PT_DYNAMIC      2               /* Dynamic linking information */
348 #define PT_INTERP       3               /* Program interpreter */
349 #define PT_NOTE         4               /* Auxiliary information */
350 #define PT_SHLIB        5               /* Reserved, unspecified semantics */
351 #define PT_PHDR         6               /* Entry for header table itself */
352 #define PT_TLS          7               /* Thread local storage segment */
353 #define PT_LOOS         0x60000000      /* OS-specific */
354 #define PT_HIOS         0x6fffffff      /* OS-specific */
355 #define PT_LOPROC       0x70000000      /* Processor-specific */
356 #define PT_HIPROC       0x7FFFFFFF      /* Processor-specific */
357
358 #define PT_GNU_EH_FRAME (PT_LOOS + 0x474e550) /* Frame unwind information */
359 #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME      /* Solaris uses the same value */
360 #define PT_GNU_STACK    (PT_LOOS + 0x474e551) /* Stack flags */
361 #define PT_GNU_RELRO    (PT_LOOS + 0x474e552) /* Read-only after relocation */
362
363 /* Program segment permissions, in program header p_flags field.  */
364
365 #define PF_X            0x1             /* Segment is executable */
366 #define PF_W            0x2             /* Segment is writable */
367 #define PF_R            0x4             /* Segment is readable */
368 #define PF_MASKOS       0x0FF00000      /* New value, Oct 4, 1999 Draft */
369 #define PF_MASKPROC     0xF0000000      /* Processor-specific reserved bits */
370
371 /* Values for section header, sh_type field.  */
372
373 #define SHT_NULL                 0      /* Section header table entry unused */
374 #define SHT_PROGBITS             1      /* Program specific (private) data */
375 #define SHT_SYMTAB               2      /* Link editing symbol table */
376 #define SHT_STRTAB               3      /* A string table */
377 #define SHT_RELA                 4      /* Relocation entries with addends */
378 #define SHT_HASH                 5      /* A symbol hash table */
379 #define SHT_DYNAMIC              6      /* Information for dynamic linking */
380 #define SHT_NOTE                 7      /* Information that marks file */
381 #define SHT_NOBITS               8      /* Section occupies no space in file */
382 #define SHT_REL                  9      /* Relocation entries, no addends */
383 #define SHT_SHLIB               10      /* Reserved, unspecified semantics */
384 #define SHT_DYNSYM              11      /* Dynamic linking symbol table */
385
386 #define SHT_INIT_ARRAY          14      /* Array of ptrs to init functions */
387 #define SHT_FINI_ARRAY          15      /* Array of ptrs to finish functions */
388 #define SHT_PREINIT_ARRAY       16      /* Array of ptrs to pre-init funcs */
389 #define SHT_GROUP               17      /* Section contains a section group */
390 #define SHT_SYMTAB_SHNDX        18      /* Indicies for SHN_XINDEX entries */
391
392 #define SHT_LOOS                0x60000000      /* First of OS specific semantics */
393 #define SHT_HIOS                0x6fffffff      /* Last of OS specific semantics */
394
395 #define SHT_GNU_INCREMENTAL_INPUTS 0x6fff4700   /* incremental build data */
396 #define SHT_GNU_ATTRIBUTES      0x6ffffff5      /* Object attributes */
397 #define SHT_GNU_HASH            0x6ffffff6      /* GNU style symbol hash table */
398 #define SHT_GNU_LIBLIST         0x6ffffff7      /* List of prelink dependencies */
399
400 /* The next three section types are defined by Solaris, and are named
401    SHT_SUNW*.  We use them in GNU code, so we also define SHT_GNU*
402    versions.  */
403 #define SHT_SUNW_verdef         0x6ffffffd      /* Versions defined by file */
404 #define SHT_SUNW_verneed        0x6ffffffe      /* Versions needed by file */
405 #define SHT_SUNW_versym         0x6fffffff      /* Symbol versions */
406
407 #define SHT_GNU_verdef          SHT_SUNW_verdef
408 #define SHT_GNU_verneed         SHT_SUNW_verneed
409 #define SHT_GNU_versym          SHT_SUNW_versym
410
411 #define SHT_LOPROC      0x70000000      /* Processor-specific semantics, lo */
412 #define SHT_HIPROC      0x7FFFFFFF      /* Processor-specific semantics, hi */
413 #define SHT_LOUSER      0x80000000      /* Application-specific semantics */
414 #define SHT_HIUSER      0xFFFFFFFF      /* New value, defined in Oct 4, 1999 Draft */
415
416 /* Values for section header, sh_flags field.  */
417
418 #define SHF_WRITE               0x1     /* Writable data during execution */
419 #define SHF_ALLOC               0x2     /* Occupies memory during execution */
420 #define SHF_EXECINSTR           0x4     /* Executable machine instructions */
421 #define SHF_MERGE               0x10    /* Data in this section can be merged */
422 #define SHF_STRINGS             0x20    /* Contains null terminated character strings */
423 #define SHF_INFO_LINK           0x40    /* sh_info holds section header table index */
424 #define SHF_LINK_ORDER          0x80    /* Preserve section ordering when linking */
425 #define SHF_OS_NONCONFORMING    0x100   /* OS specific processing required */
426 #define SHF_GROUP               0x200   /* Member of a section group */
427 #define SHF_TLS                 0x400   /* Thread local storage section */
428
429 #define SHF_MASKOS      0x0FF00000      /* New value, Oct 4, 1999 Draft */
430 #define SHF_MASKPROC    0xF0000000      /* Processor-specific semantics */
431
432 /* Values of note segment descriptor types for core files. */
433
434 #define NT_PRSTATUS     1               /* Contains copy of prstatus struct */
435 #define NT_FPREGSET     2               /* Contains copy of fpregset struct */
436 #define NT_PRPSINFO     3               /* Contains copy of prpsinfo struct */
437 #define NT_TASKSTRUCT   4               /* Contains copy of task struct */
438 #define NT_AUXV         6               /* Contains copy of Elfxx_auxv_t */
439
440 #define STN_UNDEF       0               /* Undefined symbol index */
441
442 #define STB_LOCAL       0               /* Symbol not visible outside obj */
443 #define STB_GLOBAL      1               /* Symbol visible outside obj */
444 #define STB_WEAK        2               /* Like globals, lower precedence */
445 #define STB_LOOS        10              /* OS-specific semantics */
446 #define STB_GNU_UNIQUE  10              /* Symbol is unique in namespace */
447 #define STB_HIOS        12              /* OS-specific semantics */
448 #define STB_LOPROC      13              /* Processor-specific semantics */
449 #define STB_HIPROC      15              /* Processor-specific semantics */
450
451 #define STT_NOTYPE      0               /* Symbol type is unspecified */
452 #define STT_OBJECT      1               /* Symbol is a data object */
453 #define STT_FUNC        2               /* Symbol is a code object */
454 #define STT_SECTION     3               /* Symbol associated with a section */
455 #define STT_FILE        4               /* Symbol gives a file name */
456 #define STT_COMMON      5               /* An uninitialised common block */
457 #define STT_TLS         6               /* Thread local data object */
458 #define STT_RELC        8               /* Complex relocation expression */
459 #define STT_SRELC       9               /* Signed Complex relocation expression */
460 #define STT_LOOS        10              /* OS-specific semantics */
461 #define STT_GNU_IFUNC   10              /* Symbol is an indirect code object */
462 #define STT_HIOS        12              /* OS-specific semantics */
463 #define STT_LOPROC      13              /* Processor-specific semantics */
464 #define STT_HIPROC      15              /* Processor-specific semantics */
465
466 /* The following constants control how a symbol may be accessed once it has
467    become part of an executable or shared library.  */
468
469 #define STV_DEFAULT     0               /* Visibility is specified by binding type */
470 #define STV_INTERNAL    1               /* OS specific version of STV_HIDDEN */
471 #define STV_HIDDEN      2               /* Can only be seen inside currect component */
472 #define STV_PROTECTED   3               /* Treat as STB_LOCAL inside current component */
473
474 /* Dynamic section tags.  */
475
476 #define DT_NULL         0       /* Terminating entry. */
477 #define DT_NEEDED       1       /* String table offset of a needed shared
478                                    library. */
479 #define DT_PLTRELSZ     2       /* Total size in bytes of PLT relocations. */
480 #define DT_PLTGOT       3       /* Processor-dependent address. */
481 #define DT_HASH         4       /* Address of symbol hash table. */
482 #define DT_STRTAB       5       /* Address of string table. */
483 #define DT_SYMTAB       6       /* Address of symbol table. */
484 #define DT_RELA         7       /* Address of ElfNN_Rela relocations. */
485 #define DT_RELASZ       8       /* Total size of ElfNN_Rela relocations. */
486 #define DT_RELAENT      9       /* Size of each ElfNN_Rela relocation entry. */
487 #define DT_STRSZ        10      /* Size of string table. */
488 #define DT_SYMENT       11      /* Size of each symbol table entry. */
489 #define DT_INIT         12      /* Address of initialization function. */
490 #define DT_FINI         13      /* Address of finalization function. */
491 #define DT_SONAME       14      /* String table offset of shared object
492                                    name. */
493 #define DT_RPATH        15      /* String table offset of library path. [sup] */
494 #define DT_SYMBOLIC     16      /* Indicates "symbolic" linking. [sup] */
495 #define DT_REL          17      /* Address of ElfNN_Rel relocations. */
496 #define DT_RELSZ        18      /* Total size of ElfNN_Rel relocations. */
497 #define DT_RELENT       19      /* Size of each ElfNN_Rel relocation. */
498 #define DT_PLTREL       20      /* Type of relocation used for PLT. */
499 #define DT_DEBUG        21      /* Reserved (not used). */
500 #define DT_TEXTREL      22      /* Indicates there may be relocations in
501                                    non-writable segments. [sup] */
502 #define DT_JMPREL       23      /* Address of PLT relocations. */
503 #define DT_BIND_NOW     24      /* [sup] */
504 #define DT_INIT_ARRAY   25      /* Address of the array of pointers to
505                                    initialization functions */
506 #define DT_FINI_ARRAY   26      /* Address of the array of pointers to
507                                    termination functions */
508 #define DT_INIT_ARRAYSZ 27      /* Size in bytes of the array of
509                                    initialization functions. */
510 #define DT_FINI_ARRAYSZ 28      /* Size in bytes of the array of
511                                    terminationfunctions. */
512 #define DT_RUNPATH      29      /* String table offset of a null-terminated
513                                    library search path string. */
514 #define DT_FLAGS        30      /* Object specific flag values. */
515 #define DT_ENCODING     32      /* Values greater than or equal to DT_ENCODING
516                                    and less than DT_LOOS follow the rules for
517                                    the interpretation of the d_un union
518                                    as follows: even == 'd_ptr', odd == 'd_val'
519                                    or none */
520 #define DT_PREINIT_ARRAY 32     /* Address of the array of pointers to
521                                    pre-initialization functions. */
522 #define DT_PREINIT_ARRAYSZ 33   /* Size in bytes of the array of
523                                    pre-initialization functions. */
524
525 #define DT_LOOS         0x6000000d      /* First OS-specific */
526 #define DT_HIOS         0x6fff0000      /* Last OS-specific */
527
528 /* The next 2 dynamic tag ranges, integer value range (DT_VALRNGLO to
529    DT_VALRNGHI) and virtual address range (DT_ADDRRNGLO to DT_ADDRRNGHI),
530    are used on Solaris.  We support them everywhere.  Note these values
531    lie outside of the (new) range for OS specific values.  This is a
532    deliberate special case and we maintain it for backwards compatability.
533  */
534 #define DT_VALRNGLO             0x6ffffd00
535 #define DT_GNU_PRELINKED        0x6ffffdf5
536 #define DT_GNU_CONFLICTSZ       0x6ffffdf6
537 #define DT_GNU_LIBLISTSZ        0x6ffffdf7
538 #define DT_CHECKSUM     0x6ffffdf8      /* elf checksum */
539 #define DT_PLTPADSZ     0x6ffffdf9      /* pltpadding size */
540 #define DT_MOVEENT      0x6ffffdfa      /* move table entry size */
541 #define DT_MOVESZ       0x6ffffdfb      /* move table size */
542 #define DT_FEATURE      0x6ffffdfc      /* feature holder */
543 #define DT_POSFLAG_1    0x6ffffdfd      /* flags for DT_* entries, effecting */
544                                         /*   the following DT_* entry. */
545                                         /*   See DF_P1_* definitions */
546 #define DT_SYMINSZ      0x6ffffdfe      /* syminfo table size (in bytes) */
547 #define DT_SYMINENT     0x6ffffdff      /* syminfo entry size (in bytes) */
548 #define DT_VALRNGHI     0x6ffffdff
549
550 #define DT_ADDRRNGLO    0x6ffffe00
551 #define DT_GNU_HASH     0x6ffffef5      /* GNU-style hash table */
552 #define DT_TLSDESC_PLT  0x6ffffef6
553 #define DT_TLSDESC_GOT  0x6ffffef7
554 #define DT_GNU_CONFLICT 0x6ffffef8
555 #define DT_GNU_LIBLIST  0x6ffffef9
556 #define DT_CONFIG       0x6ffffefa      /* configuration information */
557 #define DT_DEPAUDIT     0x6ffffefb      /* dependency auditing */
558 #define DT_AUDIT        0x6ffffefc      /* object auditing */
559 #define DT_PLTPAD       0x6ffffefd      /* pltpadding (sparcv9) */
560 #define DT_MOVETAB      0x6ffffefe      /* move table */
561 #define DT_SYMINFO      0x6ffffeff      /* syminfo table */
562 #define DT_ADDRRNGHI    0x6ffffeff
563
564 #define DT_RELACOUNT    0x6ffffff9      /* number of RELATIVE relocations */
565 #define DT_RELCOUNT     0x6ffffffa      /* number of RELATIVE relocations */
566 #define DT_FLAGS_1      0x6ffffffb      /* state flags - see DF_1_* defs */
567 #define DT_VERDEF       0x6ffffffc      /* Address of verdef section. */
568 #define DT_VERDEFNUM    0x6ffffffd      /* Number of elems in verdef section */
569 #define DT_VERNEED      0x6ffffffe      /* Address of verneed section. */
570 #define DT_VERNEEDNUM   0x6fffffff      /* Number of elems in verneed section */
571
572 /* This tag is a GNU extension to the Solaris version scheme.  */
573 #define DT_VERSYM       0x6ffffff0
574
575 #define DT_LOPROC       0x70000000      /* First processor-specific type. */
576 #define DT_HIPROC       0x7fffffff      /* Last processor-specific type. */
577
578 /* These section tags are used on Solaris.  We support them
579    everywhere, and hope they do not conflict.  */
580
581 #define DT_AUXILIARY    0x7ffffffd      /* shared library auxiliary name */
582 #define DT_USED         0x7ffffffe      /* ignored - same as needed */
583 #define DT_FILTER       0x7fffffff      /* shared library filter name */
584
585
586 /* Values used in DT_FEATURE .dynamic entry.  */
587 #define DTF_1_PARINIT   0x00000001
588 /* From
589
590    http://docs.sun.com:80/ab2/coll.45.13/LLM/@Ab2PageView/21165?Ab2Lang=C&Ab2Enc=iso-8859-1
591
592    DTF_1_CONFEXP is the same as DTF_1_PARINIT. It is a typo. The value
593    defined here is the same as the one in <sys/link.h> on Solaris 8.  */
594 #define DTF_1_CONFEXP   0x00000002
595
596 /* Flag values used in the DT_POSFLAG_1 .dynamic entry.  */
597 #define DF_P1_LAZYLOAD  0x00000001
598 #define DF_P1_GROUPPERM 0x00000002
599
600 /* Flag value in in the DT_FLAGS_1 .dynamic entry.  */
601 #define DF_1_NOW        0x00000001
602 #define DF_1_BIND_NOW   0x00000001      /* Same as DF_BIND_NOW */
603 #define DF_1_GLOBAL     0x00000002      /* Set the RTLD_GLOBAL for object */
604 #define DF_1_GROUP      0x00000004
605 #define DF_1_NODELETE   0x00000008      /* Set the RTLD_NODELETE for object */
606 #define DF_1_LOADFLTR   0x00000010      /* Immediate loading of filtees */
607 #define DF_1_INITFIRST  0x00000020
608 #define DF_1_NOOPEN     0x00000040      /* Do not allow loading on dlopen() */
609 #define DF_1_ORIGIN     0x00000080      /* Process $ORIGIN */
610 #define DF_1_DIRECT     0x00000100
611 #define DF_1_TRANS      0x00000200
612 #define DF_1_INTERPOSE  0x00000400
613 #define DF_1_NODEFLIB   0x00000800
614 #define DF_1_NODUMP     0x00001000
615 #define DF_1_CONLFAT    0x00002000
616
617 /* Flag values for the DT_FLAGS entry. */
618 #define DF_ORIGIN       0x1     /* Indicates that the object being loaded may
619                                    make reference to the $ORIGIN substitution
620                                    string */
621 #define DF_SYMBOLIC     0x2     /* Indicates "symbolic" linking. */
622 #define DF_TEXTREL      0x4     /* Indicates there may be relocations in
623                                    non-writable segments. */
624 #define DF_BIND_NOW     0x8     /* Indicates that the dynamic linker should
625                                    process all relocations for the object
626                                    containing this entry before transferring
627                                    control to the program. */
628 #define DF_STATIC_TLS   0x10    /* Indicates that the shared object or
629                                    executable contains code using a static
630                                    thread-local storage scheme. */
631
632 /* These constants are used for the version number of a Elf32_Verdef
633    structure.  */
634
635 #define VER_DEF_NONE            0
636 #define VER_DEF_CURRENT         1
637 #define VER_DEF_IDX(x)          VER_NDX(x)
638
639 /* These constants appear in the vd_flags field of a Elf32_Verdef
640    structure.
641
642    Cf. the Solaris Linker and Libraries Guide, Ch. 7, Object File Format,
643    Versioning Sections, for a description:
644
645    http://docs.sun.com/app/docs/doc/819-0690/chapter6-93046?l=en&a=view  */
646
647 #define VER_FLG_BASE            0x1
648 #define VER_FLG_WEAK            0x2
649 #define VER_FLG_INFO            0x4
650
651 /* These special constants can be found in an Elf32_Versym field.  */
652
653 #define VER_NDX_LOCAL           0
654 #define VER_NDX_GLOBAL          1
655 #define VER_NDX_GIVEN           2
656 #define VER_NDX_HIDDEN          (1u << 15)
657 #define VER_NDX(x)              ((x) & ~(1u << 15))
658 /* These constants are used for the version number of a Elf32_Verneed
659    structure.  */
660
661 #define VER_NEED_NONE           0
662 #define VER_NEED_CURRENT        1
663 #define VER_NEED_WEAK           (1u << 15)
664 #define VER_NEED_HIDDEN         VER_NDX_HIDDEN
665 #define VER_NEED_IDX(x)         VER_NDX(x)
666
667 /* This flag appears in a Versym structure.  It means that the symbol
668    is hidden, and is only visible with an explicit version number.
669    This is a GNU extension.  */
670
671 #define VERSYM_HIDDEN           0x8000
672
673 /* This is the mask for the rest of the Versym information.  */
674
675 #define VERSYM_VERSION          0x7fff
676
677 /* This is a special token which appears as part of a symbol name.  It
678    indictes that the rest of the name is actually the name of a
679    version node, and is not part of the actual name.  This is a GNU
680    extension.  For example, the symbol name `stat@ver2' is taken to
681    mean the symbol `stat' in version `ver2'.  */
682
683 #define ELF_VER_CHR             '@'
684
685 /* Possible values for si_boundto.  */
686
687 #define SYMINFO_BT_SELF         0xffff  /* Symbol bound to self */
688 #define SYMINFO_BT_PARENT       0xfffe  /* Symbol bound to parent */
689 #define SYMINFO_BT_LOWRESERVE   0xff00  /* Beginning of reserved entries */
690
691 /* Possible bitmasks for si_flags.  */
692
693 #define SYMINFO_FLG_DIRECT      0x0001  /* Direct bound symbol */
694 #define SYMINFO_FLG_PASSTHRU    0x0002  /* Pass-thru symbol for translator */
695 #define SYMINFO_FLG_COPY        0x0004  /* Symbol is a copy-reloc */
696 #define SYMINFO_FLG_LAZYLOAD    0x0008  /* Symbol bound to object to be lazy loaded */
697
698 /* Syminfo version values.  */
699
700 #define SYMINFO_NONE            0
701 #define SYMINFO_CURRENT         1
702 #define SYMINFO_NUM             2
703
704 /* Section Group Flags.  */
705
706 #define GRP_COMDAT              0x1     /* A COMDAT group */
707
708 #endif /* !_SYS_ELF_COMMON_H_ */