Print this page
7029 want per-process exploit mitigation features (secflags)
7030 want basic address space layout randomization (aslr)
7031 noexec_user_stack should be a secflag
7032 want a means to forbid mappings around NULL.
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/elf.h
+++ new/usr/src/uts/common/sys/elf.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
23 23 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
24 24 */
25 25 /*
26 26 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
27 27 * Use is subject to license terms.
28 28 */
29 29
30 30 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
31 31 /* All Rights Reserved */
32 32
33 33
34 34 #ifndef _SYS_ELF_H
35 35 #define _SYS_ELF_H
36 36
37 37 #include <sys/elftypes.h>
38 38
39 39 #ifdef __cplusplus
40 40 extern "C" {
41 41 #endif
42 42
43 43 #define ELF32_FSZ_ADDR 4
44 44 #define ELF32_FSZ_HALF 2
45 45 #define ELF32_FSZ_OFF 4
46 46 #define ELF32_FSZ_SWORD 4
47 47 #define ELF32_FSZ_WORD 4
48 48
49 49 #define ELF64_FSZ_ADDR 8
50 50 #define ELF64_FSZ_HALF 2
51 51 #define ELF64_FSZ_OFF 8
52 52 #define ELF64_FSZ_SWORD 4
53 53 #define ELF64_FSZ_WORD 4
54 54 #define ELF64_FSZ_SXWORD 8
55 55 #define ELF64_FSZ_XWORD 8
56 56
57 57 /*
58 58 * "Enumerations" below use ...NUM as the number of
59 59 * values in the list. It should be 1 greater than the
60 60 * highest "real" value.
61 61 */
62 62
63 63 /*
64 64 * ELF header
65 65 */
66 66
67 67 #define EI_NIDENT 16
68 68
69 69 typedef struct {
70 70 unsigned char e_ident[EI_NIDENT]; /* ident bytes */
71 71 Elf32_Half e_type; /* file type */
72 72 Elf32_Half e_machine; /* target machine */
73 73 Elf32_Word e_version; /* file version */
74 74 Elf32_Addr e_entry; /* start address */
75 75 Elf32_Off e_phoff; /* phdr file offset */
76 76 Elf32_Off e_shoff; /* shdr file offset */
77 77 Elf32_Word e_flags; /* file flags */
78 78 Elf32_Half e_ehsize; /* sizeof ehdr */
79 79 Elf32_Half e_phentsize; /* sizeof phdr */
80 80 Elf32_Half e_phnum; /* number phdrs */
81 81 Elf32_Half e_shentsize; /* sizeof shdr */
82 82 Elf32_Half e_shnum; /* number shdrs */
83 83 Elf32_Half e_shstrndx; /* shdr string index */
84 84 } Elf32_Ehdr;
85 85
86 86 #if defined(_LP64) || defined(_LONGLONG_TYPE)
87 87 typedef struct {
88 88 unsigned char e_ident[EI_NIDENT]; /* ident bytes */
89 89 Elf64_Half e_type; /* file type */
90 90 Elf64_Half e_machine; /* target machine */
91 91 Elf64_Word e_version; /* file version */
92 92 Elf64_Addr e_entry; /* start address */
93 93 Elf64_Off e_phoff; /* phdr file offset */
94 94 Elf64_Off e_shoff; /* shdr file offset */
95 95 Elf64_Word e_flags; /* file flags */
96 96 Elf64_Half e_ehsize; /* sizeof ehdr */
97 97 Elf64_Half e_phentsize; /* sizeof phdr */
98 98 Elf64_Half e_phnum; /* number phdrs */
99 99 Elf64_Half e_shentsize; /* sizeof shdr */
100 100 Elf64_Half e_shnum; /* number shdrs */
101 101 Elf64_Half e_shstrndx; /* shdr string index */
102 102 } Elf64_Ehdr;
103 103 #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */
104 104
105 105
106 106 #define EI_MAG0 0 /* e_ident[] indexes */
107 107 #define EI_MAG1 1
108 108 #define EI_MAG2 2
109 109 #define EI_MAG3 3
110 110 #define EI_CLASS 4 /* File class */
111 111 #define EI_DATA 5 /* Data encoding */
112 112 #define EI_VERSION 6 /* File version */
113 113 #define EI_OSABI 7 /* Operating system/ABI identification */
114 114 #define EI_ABIVERSION 8 /* ABI version */
115 115 #define EI_PAD 9 /* Start of padding bytes */
116 116
117 117 #define ELFMAG0 0x7f /* EI_MAG */
118 118 #define ELFMAG1 'E'
119 119 #define ELFMAG2 'L'
120 120 #define ELFMAG3 'F'
121 121 #define ELFMAG "\177ELF"
122 122 #define SELFMAG 4
123 123
124 124 #define ELFCLASSNONE 0 /* EI_CLASS */
125 125 #define ELFCLASS32 1
126 126 #define ELFCLASS64 2
127 127 #define ELFCLASSNUM 3
128 128
129 129 #define ELFDATANONE 0 /* EI_DATA */
130 130 #define ELFDATA2LSB 1
131 131 #define ELFDATA2MSB 2
132 132 #define ELFDATANUM 3
133 133
134 134 #define ET_NONE 0 /* e_type */
135 135 #define ET_REL 1
136 136 #define ET_EXEC 2
137 137 #define ET_DYN 3
138 138 #define ET_CORE 4
139 139 #define ET_NUM 5
140 140 #define ET_LOOS 0xfe00 /* OS specific range */
141 141 #define ET_LOSUNW 0xfeff
142 142 #define ET_SUNWPSEUDO 0xfeff
143 143 #define ET_HISUNW 0xfeff
144 144 #define ET_HIOS 0xfeff
145 145 #define ET_LOPROC 0xff00 /* processor specific range */
146 146 #define ET_HIPROC 0xffff
147 147
148 148 #define ET_LOPROC 0xff00 /* processor specific range */
149 149 #define ET_HIPROC 0xffff
150 150
151 151 #define EM_NONE 0 /* e_machine */
152 152 #define EM_M32 1 /* AT&T WE 32100 */
153 153 #define EM_SPARC 2 /* Sun SPARC */
154 154 #define EM_386 3 /* Intel 80386 */
155 155 #define EM_68K 4 /* Motorola 68000 */
156 156 #define EM_88K 5 /* Motorola 88000 */
157 157 #define EM_486 6 /* Intel 80486 */
158 158 #define EM_860 7 /* Intel i860 */
159 159 #define EM_MIPS 8 /* MIPS RS3000 Big-Endian */
160 160 #define EM_S370 9 /* IBM System/370 Processor */
161 161 #define EM_MIPS_RS3_LE 10 /* MIPS RS3000 Little-Endian */
162 162 #define EM_RS6000 11 /* RS6000 */
163 163 #define EM_UNKNOWN12 12
164 164 #define EM_UNKNOWN13 13
165 165 #define EM_UNKNOWN14 14
166 166 #define EM_PA_RISC 15 /* PA-RISC */
167 167 #define EM_PARISC EM_PA_RISC /* Alias: GNU compatibility */
168 168 #define EM_nCUBE 16 /* nCUBE */
169 169 #define EM_VPP500 17 /* Fujitsu VPP500 */
170 170 #define EM_SPARC32PLUS 18 /* Sun SPARC 32+ */
171 171 #define EM_960 19 /* Intel 80960 */
172 172 #define EM_PPC 20 /* PowerPC */
173 173 #define EM_PPC64 21 /* 64-bit PowerPC */
174 174 #define EM_S390 22 /* IBM System/390 Processor */
175 175 #define EM_UNKNOWN22 EM_S390 /* Alias: Older published name */
176 176 #define EM_UNKNOWN23 23
177 177 #define EM_UNKNOWN24 24
178 178 #define EM_UNKNOWN25 25
179 179 #define EM_UNKNOWN26 26
180 180 #define EM_UNKNOWN27 27
181 181 #define EM_UNKNOWN28 28
182 182 #define EM_UNKNOWN29 29
183 183 #define EM_UNKNOWN30 30
184 184 #define EM_UNKNOWN31 31
185 185 #define EM_UNKNOWN32 32
186 186 #define EM_UNKNOWN33 33
187 187 #define EM_UNKNOWN34 34
188 188 #define EM_UNKNOWN35 35
189 189 #define EM_V800 36 /* NEX V800 */
190 190 #define EM_FR20 37 /* Fujitsu FR20 */
191 191 #define EM_RH32 38 /* TRW RH-32 */
192 192 #define EM_RCE 39 /* Motorola RCE */
193 193 #define EM_ARM 40 /* Advanced RISC Marchines ARM */
194 194 #define EM_ALPHA 41 /* Digital Alpha */
195 195 #define EM_SH 42 /* Hitachi SH */
196 196 #define EM_SPARCV9 43 /* Sun SPARC V9 (64-bit) */
197 197 #define EM_TRICORE 44 /* Siemens Tricore embedded processor */
198 198 #define EM_ARC 45 /* Argonaut RISC Core, */
199 199 /* Argonaut Technologies Inc. */
200 200 #define EM_H8_300 46 /* Hitachi H8/300 */
201 201 #define EM_H8_300H 47 /* Hitachi H8/300H */
202 202 #define EM_H8S 48 /* Hitachi H8S */
203 203 #define EM_H8_500 49 /* Hitachi H8/500 */
204 204 #define EM_IA_64 50 /* Intel IA64 */
205 205 #define EM_MIPS_X 51 /* Stanford MIPS-X */
206 206 #define EM_COLDFIRE 52 /* Motorola ColdFire */
207 207 #define EM_68HC12 53 /* Motorola M68HC12 */
208 208 #define EM_MMA 54 /* Fujitsu MMA Mulimedia Accelerator */
209 209 #define EM_PCP 55 /* Siemens PCP */
210 210 #define EM_NCPU 56 /* Sony nCPU embedded RISC processor */
211 211 #define EM_NDR1 57 /* Denso NDR1 microprocessor */
212 212 #define EM_STARCORE 58 /* Motorola Star*Core processor */
213 213 #define EM_ME16 59 /* Toyota ME16 processor */
214 214 #define EM_ST100 60 /* STMicroelectronics ST100 processor */
215 215 #define EM_TINYJ 61 /* Advanced Logic Corp. TinyJ */
216 216 /* embedded processor family */
217 217 #define EM_AMD64 62 /* AMDs x86-64 architecture */
218 218 #define EM_X86_64 EM_AMD64 /* (compatibility) */
219 219
220 220 #define EM_PDSP 63 /* Sony DSP Processor */
221 221 #define EM_UNKNOWN64 64
222 222 #define EM_UNKNOWN65 65
223 223 #define EM_FX66 66 /* Siemens FX66 microcontroller */
224 224 #define EM_ST9PLUS 67 /* STMicroelectronics ST9+8/16 bit */
225 225 /* microcontroller */
226 226 #define EM_ST7 68 /* STMicroelectronics ST7 8-bit */
227 227 /* microcontroller */
228 228 #define EM_68HC16 69 /* Motorola MC68HC16 Microcontroller */
229 229 #define EM_68HC11 70 /* Motorola MC68HC11 Microcontroller */
230 230 #define EM_68HC08 71 /* Motorola MC68HC08 Microcontroller */
231 231 #define EM_68HC05 72 /* Motorola MC68HC05 Microcontroller */
232 232 #define EM_SVX 73 /* Silicon Graphics SVx */
233 233 #define EM_ST19 74 /* STMicroelectronics ST19 8-bit */
234 234 /* microcontroller */
235 235 #define EM_VAX 75 /* Digital VAX */
236 236 #define EM_CRIS 76 /* Axis Communications 32-bit */
237 237 /* embedded processor */
238 238 #define EM_JAVELIN 77 /* Infineon Technologies 32-bit */
239 239 /* embedded processor */
240 240 #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */
241 241 #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */
242 242 #define EM_MMIX 80 /* Donald Knuth's educational */
243 243 /* 64-bit processor */
244 244 #define EM_HUANY 81 /* Harvard University */
245 245 /* machine-independent */
246 246 /* object files */
247 247 #define EM_PRISM 82 /* SiTera Prism */
248 248 #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */
249 249 #define EM_FR30 84 /* Fujitsu FR30 */
250 250 #define EM_D10V 85 /* Mitsubishi D10V */
251 251 #define EM_D30V 86 /* Mitsubishi D30V */
252 252 #define EM_V850 87 /* NEC v850 */
253 253 #define EM_M32R 88 /* Mitsubishi M32R */
254 254 #define EM_MN10300 89 /* Matsushita MN10300 */
255 255 #define EM_MN10200 90 /* Matsushita MN10200 */
256 256 #define EM_PJ 91 /* picoJava */
257 257 #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */
258 258 #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */
259 259 #define EM_XTENSA 94 /* Tensilica Xtensa architecture */
260 260 #define EM_NUM 95
261 261
262 262 #define EV_NONE 0 /* e_version, EI_VERSION */
263 263 #define EV_CURRENT 1
264 264 #define EV_NUM 2
265 265
266 266
267 267 #define ELFOSABI_NONE 0 /* No extensions or unspecified */
268 268 #define ELFOSABI_SYSV ELFOSABI_NONE
269 269 #define ELFOSABI_HPUX 1 /* Hewlett-Packard HP-UX */
270 270 #define ELFOSABI_NETBSD 2 /* NetBSD */
271 271 #define ELFOSABI_LINUX 3 /* Linux */
272 272 #define ELFOSABI_UNKNOWN4 4
273 273 #define ELFOSABI_UNKNOWN5 5
274 274 #define ELFOSABI_SOLARIS 6 /* Sun Solaris */
275 275 #define ELFOSABI_AIX 7 /* AIX */
276 276 #define ELFOSABI_IRIX 8 /* IRIX */
277 277 #define ELFOSABI_FREEBSD 9 /* FreeBSD */
278 278 #define ELFOSABI_TRU64 10 /* Compaq TRU64 UNIX */
279 279 #define ELFOSABI_MODESTO 11 /* Novell Modesto */
280 280 #define ELFOSABI_OPENBSD 12 /* Open BSD */
281 281 #define ELFOSABI_OPENVMS 13 /* Open VMS */
282 282 #define ELFOSABI_NSK 14 /* Hewlett-Packard Non-Stop Kernel */
283 283 #define ELFOSABI_AROS 15 /* Amiga Research OS */
284 284 #define ELFOSABI_ARM 97 /* ARM */
285 285 #define ELFOSABI_STANDALONE 255 /* standalone (embedded) application */
286 286
287 287 #define EAV_SUNW_NONE 0 /* EI_ABIVERSION */
288 288 #define EAV_SUNW_CURRENT 1
289 289 #define EAV_SUNW_NUM 2
290 290
291 291
292 292 /*
293 293 * Program header
294 294 */
295 295
296 296 typedef struct {
297 297 Elf32_Word p_type; /* entry type */
298 298 Elf32_Off p_offset; /* file offset */
299 299 Elf32_Addr p_vaddr; /* virtual address */
300 300 Elf32_Addr p_paddr; /* physical address */
301 301 Elf32_Word p_filesz; /* file size */
302 302 Elf32_Word p_memsz; /* memory size */
303 303 Elf32_Word p_flags; /* entry flags */
304 304 Elf32_Word p_align; /* memory/file alignment */
305 305 } Elf32_Phdr;
306 306
307 307 #if defined(_LP64) || defined(_LONGLONG_TYPE)
308 308 typedef struct {
309 309 Elf64_Word p_type; /* entry type */
310 310 Elf64_Word p_flags; /* entry flags */
311 311 Elf64_Off p_offset; /* file offset */
312 312 Elf64_Addr p_vaddr; /* virtual address */
313 313 Elf64_Addr p_paddr; /* physical address */
314 314 Elf64_Xword p_filesz; /* file size */
315 315 Elf64_Xword p_memsz; /* memory size */
316 316 Elf64_Xword p_align; /* memory/file alignment */
317 317 } Elf64_Phdr;
318 318 #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */
319 319
320 320
321 321 #define PT_NULL 0 /* p_type */
322 322 #define PT_LOAD 1
323 323 #define PT_DYNAMIC 2
324 324 #define PT_INTERP 3
325 325 #define PT_NOTE 4
326 326 #define PT_SHLIB 5
327 327 #define PT_PHDR 6
328 328 #define PT_TLS 7
329 329 #define PT_NUM 8
330 330
331 331 #define PT_LOOS 0x60000000 /* OS specific range */
332 332
333 333 /*
334 334 * PT_SUNW_UNWIND and PT_SUNW_EH_FRAME perform the same function,
335 335 * providing access to the .eh_frame_hdr section of the object.
336 336 * PT_SUNW_UNWIND is the original value, while PT_SUNW_EH_FRAME is
337 337 * required by the amd64 psABI. The Solaris link-editor (ld) tags output
338 338 * objects with PT_SUNW_UNWIND, but the Solaris runtime linker (ld.so.1)
339 339 * will accept and use either value.
340 340 */
341 341 #define PT_SUNW_UNWIND 0x6464e550
342 342 #define PT_SUNW_EH_FRAME 0x6474e550
343 343 #define PT_GNU_EH_FRAME PT_SUNW_EH_FRAME
344 344
345 345 /*
346 346 * Linux specific program headers not currently used by Solaris
347 347 */
348 348 #define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
349 349 #define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
350 350
351 351 #define PT_LOSUNW 0x6ffffffa
352 352 #define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment (unused) */
353 353 #define PT_SUNWSTACK 0x6ffffffb /* describes the stack segment */
354 354 #define PT_SUNWDTRACE 0x6ffffffc /* private */
355 355 #define PT_SUNWCAP 0x6ffffffd /* hard/soft capabilities segment */
356 356 #define PT_HISUNW 0x6fffffff
357 357 #define PT_HIOS 0x6fffffff
358 358
359 359 #define PT_LOPROC 0x70000000 /* processor specific range */
360 360 #define PT_HIPROC 0x7fffffff
361 361
362 362 #define PF_R 0x4 /* p_flags */
363 363 #define PF_W 0x2
364 364 #define PF_X 0x1
365 365
366 366 #define PF_MASKOS 0x0ff00000 /* OS specific values */
367 367 #define PF_MASKPROC 0xf0000000 /* processor specific values */
368 368
369 369 #define PF_SUNW_FAILURE 0x00100000 /* mapping absent due to failure */
370 370 #define PF_SUNW_KILLED 0x00200000 /* signal received during dump */
371 371 #define PF_SUNW_SIGINFO 0x00400000 /* segment has killing sig's siginfo */
372 372
373 373 #define PN_XNUM 0xffff /* extended program header index */
374 374
375 375 /*
376 376 * Section header
377 377 */
378 378
379 379 typedef struct {
380 380 Elf32_Word sh_name; /* section name */
381 381 Elf32_Word sh_type; /* SHT_... */
382 382 Elf32_Word sh_flags; /* SHF_... */
383 383 Elf32_Addr sh_addr; /* virtual address */
384 384 Elf32_Off sh_offset; /* file offset */
385 385 Elf32_Word sh_size; /* section size */
386 386 Elf32_Word sh_link; /* misc info */
387 387 Elf32_Word sh_info; /* misc info */
388 388 Elf32_Word sh_addralign; /* memory alignment */
389 389 Elf32_Word sh_entsize; /* entry size if table */
390 390 } Elf32_Shdr;
391 391
392 392 #if defined(_LP64) || defined(_LONGLONG_TYPE)
393 393 typedef struct {
394 394 Elf64_Word sh_name; /* section name */
395 395 Elf64_Word sh_type; /* SHT_... */
396 396 Elf64_Xword sh_flags; /* SHF_... */
397 397 Elf64_Addr sh_addr; /* virtual address */
398 398 Elf64_Off sh_offset; /* file offset */
399 399 Elf64_Xword sh_size; /* section size */
400 400 Elf64_Word sh_link; /* misc info */
401 401 Elf64_Word sh_info; /* misc info */
402 402 Elf64_Xword sh_addralign; /* memory alignment */
403 403 Elf64_Xword sh_entsize; /* entry size if table */
404 404 } Elf64_Shdr;
405 405 #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */
406 406
407 407 #define SHT_NULL 0 /* sh_type */
408 408 #define SHT_PROGBITS 1
409 409 #define SHT_SYMTAB 2
410 410 #define SHT_STRTAB 3
411 411 #define SHT_RELA 4
412 412 #define SHT_HASH 5
413 413 #define SHT_DYNAMIC 6
414 414 #define SHT_NOTE 7
415 415 #define SHT_NOBITS 8
416 416 #define SHT_REL 9
417 417 #define SHT_SHLIB 10
418 418 #define SHT_DYNSYM 11
419 419 #define SHT_UNKNOWN12 12
420 420 #define SHT_UNKNOWN13 13
421 421 #define SHT_INIT_ARRAY 14
422 422 #define SHT_FINI_ARRAY 15
423 423 #define SHT_PREINIT_ARRAY 16
424 424 #define SHT_GROUP 17
425 425 #define SHT_SYMTAB_SHNDX 18
426 426 #define SHT_NUM 19
427 427
428 428 /* Solaris ABI specific values */
429 429 #define SHT_LOOS 0x60000000 /* OS specific range */
430 430 #define SHT_LOSUNW 0x6fffffef
431 431 #define SHT_SUNW_capchain 0x6fffffef
432 432 #define SHT_SUNW_capinfo 0x6ffffff0
433 433 #define SHT_SUNW_symsort 0x6ffffff1
434 434 #define SHT_SUNW_tlssort 0x6ffffff2
435 435 #define SHT_SUNW_LDYNSYM 0x6ffffff3
436 436 #define SHT_SUNW_dof 0x6ffffff4
437 437 #define SHT_SUNW_cap 0x6ffffff5
438 438 #define SHT_SUNW_SIGNATURE 0x6ffffff6
439 439 #define SHT_SUNW_ANNOTATE 0x6ffffff7
440 440 #define SHT_SUNW_DEBUGSTR 0x6ffffff8
441 441 #define SHT_SUNW_DEBUG 0x6ffffff9
442 442 #define SHT_SUNW_move 0x6ffffffa
443 443 #define SHT_SUNW_COMDAT 0x6ffffffb
444 444 #define SHT_SUNW_syminfo 0x6ffffffc
445 445 #define SHT_SUNW_verdef 0x6ffffffd
446 446 #define SHT_GNU_verdef SHT_SUNW_verdef
447 447 #define SHT_SUNW_verneed 0x6ffffffe
448 448 #define SHT_GNU_verneed SHT_SUNW_verneed
449 449 #define SHT_SUNW_versym 0x6fffffff
450 450 #define SHT_GNU_versym SHT_SUNW_versym
451 451 #define SHT_HISUNW 0x6fffffff
452 452 #define SHT_HIOS 0x6fffffff
453 453
454 454 /*
455 455 * GNU/Linux OSABI specific values with different meanings than under Solaris.
456 456 * Due to the overlap in assigned values with the Solaris OSABI, correct
457 457 * interpretation of these values requires knowledge of the OSABI used by
458 458 * the object.
459 459 */
460 460 #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes */
461 461 #define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table */
462 462 #define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */
463 463 #define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content */
464 464
465 465 #define SHT_LOPROC 0x70000000 /* processor specific range */
466 466 #define SHT_HIPROC 0x7fffffff
467 467
468 468 #define SHT_LOUSER 0x80000000
469 469 #define SHT_HIUSER 0xffffffff
470 470
471 471 #define SHF_WRITE 0x01 /* sh_flags */
472 472 #define SHF_ALLOC 0x02
473 473 #define SHF_EXECINSTR 0x04
474 474 #define SHF_MERGE 0x10
475 475 #define SHF_STRINGS 0x20
476 476 #define SHF_INFO_LINK 0x40
477 477 #define SHF_LINK_ORDER 0x80
478 478 #define SHF_OS_NONCONFORMING 0x100
479 479 #define SHF_GROUP 0x200
480 480 #define SHF_TLS 0x400
481 481
482 482 #define SHF_MASKOS 0x0ff00000 /* OS specific values */
483 483
484 484
485 485 #define SHF_MASKPROC 0xf0000000 /* processor specific values */
486 486
487 487 #define SHN_UNDEF 0 /* special section numbers */
488 488 #define SHN_LORESERVE 0xff00
489 489 #define SHN_LOPROC 0xff00 /* processor specific range */
490 490 #define SHN_HIPROC 0xff1f
491 491 #define SHN_LOOS 0xff20 /* OS specific range */
492 492 #define SHN_LOSUNW 0xff3f
493 493 #define SHN_SUNW_IGNORE 0xff3f
494 494 #define SHN_HISUNW 0xff3f
495 495 #define SHN_HIOS 0xff3f
496 496 #define SHN_ABS 0xfff1
497 497 #define SHN_COMMON 0xfff2
498 498 #define SHN_XINDEX 0xffff /* extended sect index */
499 499 #define SHN_HIRESERVE 0xffff
500 500
501 501
502 502
503 503 /*
504 504 * Symbol table
505 505 */
506 506
507 507 typedef struct {
508 508 Elf32_Word st_name;
509 509 Elf32_Addr st_value;
510 510 Elf32_Word st_size;
511 511 unsigned char st_info; /* bind, type: ELF_32_ST_... */
512 512 unsigned char st_other;
513 513 Elf32_Half st_shndx; /* SHN_... */
514 514 } Elf32_Sym;
515 515
516 516 #if defined(_LP64) || defined(_LONGLONG_TYPE)
517 517 typedef struct {
518 518 Elf64_Word st_name;
519 519 unsigned char st_info; /* bind, type: ELF_64_ST_... */
520 520 unsigned char st_other;
521 521 Elf64_Half st_shndx; /* SHN_... */
522 522 Elf64_Addr st_value;
523 523 Elf64_Xword st_size;
524 524 } Elf64_Sym;
525 525 #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */
526 526
527 527 #define STN_UNDEF 0
528 528
529 529 /*
530 530 * Macros to compose and decompose values for S.st_info
531 531 *
532 532 * bind = ELF32_ST_BIND(S.st_info)
533 533 * type = ELF32_ST_TYPE(S.st_info)
534 534 * S.st_info = ELF32_ST_INFO(bind, type)
535 535 */
536 536
537 537 #define ELF32_ST_BIND(info) ((info) >> 4)
538 538 #define ELF32_ST_TYPE(info) ((info) & 0xf)
539 539 #define ELF32_ST_INFO(bind, type) (((bind)<<4)+((type)&0xf))
540 540
541 541 #define ELF64_ST_BIND(info) ((info) >> 4)
542 542 #define ELF64_ST_TYPE(info) ((info) & 0xf)
543 543 #define ELF64_ST_INFO(bind, type) (((bind)<<4)+((type)&0xf))
544 544
545 545
546 546 #define STB_LOCAL 0 /* BIND */
547 547 #define STB_GLOBAL 1
548 548 #define STB_WEAK 2
549 549 #define STB_NUM 3
550 550
551 551 #define STB_LOPROC 13 /* processor specific range */
552 552 #define STB_HIPROC 15
553 553
554 554 #define STT_NOTYPE 0 /* symbol type is unspecified */
555 555 #define STT_OBJECT 1 /* data object */
556 556 #define STT_FUNC 2 /* code object */
557 557 #define STT_SECTION 3 /* symbol identifies an ELF section */
558 558 #define STT_FILE 4 /* symbol's name is file name */
559 559 #define STT_COMMON 5 /* common data object */
560 560 #define STT_TLS 6 /* thread-local data object */
561 561 #define STT_NUM 7 /* # defined types in generic range */
562 562 #define STT_LOOS 10 /* OS specific range */
563 563 #define STT_HIOS 12
564 564 #define STT_LOPROC 13 /* processor specific range */
565 565 #define STT_HIPROC 15
566 566
567 567 /*
568 568 * Macros to decompose values for S.st_other
569 569 *
570 570 * visibility = ELF32_ST_VISIBILITY(S.st_other)
571 571 */
572 572 #define ELF32_ST_VISIBILITY(other) ((other)&0x7)
573 573 #define ELF64_ST_VISIBILITY(other) ((other)&0x7)
574 574
575 575 #define STV_DEFAULT 0
576 576 #define STV_INTERNAL 1
577 577 #define STV_HIDDEN 2
578 578 #define STV_PROTECTED 3
579 579 #define STV_EXPORTED 4
580 580 #define STV_SINGLETON 5
581 581 #define STV_ELIMINATE 6
582 582
583 583 #define STV_NUM 7
584 584
585 585 /*
586 586 * Relocation
587 587 */
588 588
589 589 typedef struct {
590 590 Elf32_Addr r_offset;
591 591 Elf32_Word r_info; /* sym, type: ELF32_R_... */
592 592 } Elf32_Rel;
593 593
594 594 typedef struct {
595 595 Elf32_Addr r_offset;
596 596 Elf32_Word r_info; /* sym, type: ELF32_R_... */
597 597 Elf32_Sword r_addend;
598 598 } Elf32_Rela;
599 599
600 600 #if defined(_LP64) || defined(_LONGLONG_TYPE)
601 601 typedef struct {
602 602 Elf64_Addr r_offset;
603 603 Elf64_Xword r_info; /* sym, type: ELF64_R_... */
604 604 } Elf64_Rel;
605 605
606 606 typedef struct {
607 607 Elf64_Addr r_offset;
608 608 Elf64_Xword r_info; /* sym, type: ELF64_R_... */
609 609 Elf64_Sxword r_addend;
610 610 } Elf64_Rela;
611 611 #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */
612 612
613 613
614 614 /*
615 615 * Macros to compose and decompose values for Rel.r_info, Rela.f_info
616 616 *
617 617 * sym = ELF32_R_SYM(R.r_info)
618 618 * type = ELF32_R_TYPE(R.r_info)
619 619 * R.r_info = ELF32_R_INFO(sym, type)
620 620 */
621 621
622 622 #define ELF32_R_SYM(info) ((info)>>8)
623 623 #define ELF32_R_TYPE(info) ((unsigned char)(info))
624 624 #define ELF32_R_INFO(sym, type) (((sym)<<8)+(unsigned char)(type))
625 625
626 626 #define ELF64_R_SYM(info) ((info)>>32)
627 627 #define ELF64_R_TYPE(info) ((Elf64_Word)(info))
628 628 #define ELF64_R_INFO(sym, type) (((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(type))
629 629
630 630
631 631 /*
632 632 * The r_info field is composed of two 32-bit components: the symbol
633 633 * table index and the relocation type. The relocation type for SPARC V9
634 634 * is further decomposed into an 8-bit type identifier and a 24-bit type
635 635 * dependent data field. For the existing Elf32 relocation types,
636 636 * that data field is zero.
637 637 */
638 638 #define ELF64_R_TYPE_DATA(info) (((Elf64_Xword)(info)<<32)>>40)
639 639 #define ELF64_R_TYPE_ID(info) (((Elf64_Xword)(info)<<56)>>56)
640 640 #define ELF64_R_TYPE_INFO(data, type) \
641 641 (((Elf64_Xword)(data)<<8)+(Elf64_Xword)(type))
642 642
643 643
644 644 /*
645 645 * Section Group Flags (SHT_GROUP)
646 646 */
647 647 #define GRP_COMDAT 0x01
648 648
649 649
650 650 /*
651 651 * Note entry header
652 652 */
653 653
654 654 typedef struct {
655 655 Elf32_Word n_namesz; /* length of note's name */
656 656 Elf32_Word n_descsz; /* length of note's "desc" */
657 657 Elf32_Word n_type; /* type of note */
658 658 } Elf32_Nhdr;
659 659
660 660 #if defined(_LP64) || defined(_LONGLONG_TYPE)
661 661 typedef struct {
662 662 Elf64_Word n_namesz; /* length of note's name */
663 663 Elf64_Word n_descsz; /* length of note's "desc" */
664 664 Elf64_Word n_type; /* type of note */
665 665 } Elf64_Nhdr;
666 666 #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */
667 667
668 668 /*
669 669 * Move entry
670 670 */
671 671 #if defined(_LP64) || defined(_LONGLONG_TYPE)
672 672 typedef struct {
673 673 Elf32_Lword m_value; /* symbol value */
674 674 Elf32_Word m_info; /* size + index */
675 675 Elf32_Word m_poffset; /* symbol offset */
676 676 Elf32_Half m_repeat; /* repeat count */
677 677 Elf32_Half m_stride; /* stride info */
678 678 } Elf32_Move;
679 679
680 680 /*
681 681 * Macros to compose and decompose values for Move.r_info
682 682 *
683 683 * sym = ELF32_M_SYM(M.m_info)
684 684 * size = ELF32_M_SIZE(M.m_info)
685 685 * M.m_info = ELF32_M_INFO(sym, size)
686 686 */
687 687 #define ELF32_M_SYM(info) ((info)>>8)
688 688 #define ELF32_M_SIZE(info) ((unsigned char)(info))
689 689 #define ELF32_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))
690 690
691 691 typedef struct {
692 692 Elf64_Lword m_value; /* symbol value */
693 693 Elf64_Xword m_info; /* size + index */
694 694 Elf64_Xword m_poffset; /* symbol offset */
695 695 Elf64_Half m_repeat; /* repeat count */
696 696 Elf64_Half m_stride; /* stride info */
697 697 } Elf64_Move;
698 698 #define ELF64_M_SYM(info) ((info)>>8)
699 699 #define ELF64_M_SIZE(info) ((unsigned char)(info))
700 700 #define ELF64_M_INFO(sym, size) (((sym)<<8)+(unsigned char)(size))
701 701
702 702 #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */
703 703
704 704
705 705 /*
706 706 * Capabilities entry, Capabilities info and Capabilities chain.
707 707 */
708 708 #ifndef _ASM
709 709 typedef struct {
710 710 Elf32_Word c_tag; /* how to interpret value */
711 711 union {
712 712 Elf32_Word c_val;
713 713 Elf32_Addr c_ptr;
714 714 } c_un;
715 715 } Elf32_Cap;
716 716
717 717 typedef Elf32_Word Elf32_Capinfo;
718 718 typedef Elf32_Word Elf32_Capchain;
719 719
720 720 /*
721 721 * Macros to compose and decompose values for capabilities info.
722 722 *
723 723 * sym = ELF32_C_SYM(info)
724 724 * grp = ELF32_C_GROUP(info)
725 725 * info = ELF32_C_INFO(sym, grp)
726 726 */
727 727 #define ELF32_C_SYM(info) ((info)>>8)
728 728 #define ELF32_C_GROUP(info) ((unsigned char)(info))
729 729 #define ELF32_C_INFO(sym, grp) (((sym)<<8)+(unsigned char)(grp))
730 730
731 731
732 732 #if defined(_LP64) || defined(_LONGLONG_TYPE)
733 733 typedef struct {
734 734 Elf64_Xword c_tag; /* how to interpret value */
735 735 union {
736 736 Elf64_Xword c_val;
737 737 Elf64_Addr c_ptr;
738 738 } c_un;
739 739 } Elf64_Cap;
740 740
741 741 typedef Elf64_Xword Elf64_Capinfo;
742 742 typedef Elf64_Word Elf64_Capchain;
743 743
744 744 /*
745 745 * Macros to compose and decompose values for capabilities info.
746 746 *
747 747 * sym = ELF64_C_SYM(info)
748 748 * grp = ELF64_C_GROUP(info)
749 749 * info = ELF64_C_INFO(sym, grp)
750 750 */
751 751 #define ELF64_C_SYM(info) ((info)>>32)
752 752 #define ELF64_C_GROUP(info) ((Elf64_Word)(info))
753 753 #define ELF64_C_INFO(sym, grp) (((Elf64_Xword)(sym)<<32)+(Elf64_Xword)(grp))
754 754
755 755 #endif /* defined(_LP64) || defined(_LONGLONG_TYPE) */
756 756 #endif
757 757
758 758 /*
759 759 * Version numbers for SHT_SUNW_capinfo and SHT_SUNW_capchain.
760 760 */
761 761 #define CAPINFO_NONE 0
762 762 #define CAPINFO_CURRENT 1
763 763 #define CAPINFO_NUM 2
764 764
765 765 #define CAPCHAIN_NONE 0
766 766 #define CAPCHAIN_CURRENT 1
767 767 #define CAPCHAIN_NUM 2
768 768
769 769 /*
770 770 * A SHT_SUNW_capinfo table mirrors a symbol table. A capabilities symbol has
771 771 * a SHT_SUNW_capinfo table entry that provides an index into the associated
772 772 * SHT_SUNW_cap capabilities group, and the symbol index of the associated lead
773 773 * symbol. A capabilities symbol is a local symbol. A global lead capabilities
774 774 * symbol is tagged with a group CAPINFO_SUNW_GLOB.
775 775 */
776 776 #define CAPINFO_SUNW_GLOB 0xff
777 777
778 778 /*
779 779 * Capabilities values.
780 780 */
781 781 #define CA_SUNW_NULL 0
782 782 #define CA_SUNW_HW_1 1 /* first hardware capabilities entry */
783 783 #define CA_SUNW_SF_1 2 /* first software capabilities entry */
784 784 #define CA_SUNW_HW_2 3 /* second hardware capabilities entry */
785 785 #define CA_SUNW_PLAT 4 /* platform capability entry */
786 786 #define CA_SUNW_MACH 5 /* machine capability entry */
787 787 #define CA_SUNW_ID 6 /* capability identifier */
788 788 #define CA_SUNW_NUM 7
789 789
790 790 /*
791 791 * Define software capabilities (CA_SUNW_SF_1 values). Note, hardware
792 792 * capabilities (CA_SUNW_HW_1 values) are taken directly from sys/auxv_$MACH.h.
793 793 */
794 794 #define SF1_SUNW_FPKNWN 0x001 /* frame pointer usage is known */
795 795 #define SF1_SUNW_FPUSED 0x002 /* frame pointer is in use */
796 796 #define SF1_SUNW_ADDR32 0x004 /* 32-bit address space requirement */
797 797 #define SF1_SUNW_MASK 0x007 /* known software capabilities mask */
798 798
799 799 /*
800 800 * Known values for note entry types (e_type == ET_CORE)
801 801 */
802 802 #define NT_PRSTATUS 1 /* prstatus_t <sys/old_procfs.h> */
803 803 #define NT_PRFPREG 2 /* prfpregset_t <sys/old_procfs.h> */
804 804 #define NT_PRPSINFO 3 /* prpsinfo_t <sys/old_procfs.h> */
805 805 #define NT_PRXREG 4 /* prxregset_t <sys/procfs.h> */
806 806 #define NT_PLATFORM 5 /* string from sysinfo(SI_PLATFORM) */
807 807 #define NT_AUXV 6 /* auxv_t array <sys/auxv.h> */
808 808 #define NT_GWINDOWS 7 /* gwindows_t SPARC only */
809 809 #define NT_ASRS 8 /* asrset_t SPARC V9 only */
810 810 #define NT_LDT 9 /* ssd array <sys/sysi86.h> IA32 only */
811 811 #define NT_PSTATUS 10 /* pstatus_t <sys/procfs.h> */
812 812 #define NT_PSINFO 13 /* psinfo_t <sys/procfs.h> */
↓ open down ↓ |
812 lines elided |
↑ open up ↑ |
813 813 #define NT_PRCRED 14 /* prcred_t <sys/procfs.h> */
814 814 #define NT_UTSNAME 15 /* struct utsname <sys/utsname.h> */
815 815 #define NT_LWPSTATUS 16 /* lwpstatus_t <sys/procfs.h> */
816 816 #define NT_LWPSINFO 17 /* lwpsinfo_t <sys/procfs.h> */
817 817 #define NT_PRPRIV 18 /* prpriv_t <sys/procfs.h> */
818 818 #define NT_PRPRIVINFO 19 /* priv_impl_info_t <sys/priv.h> */
819 819 #define NT_CONTENT 20 /* core_content_t <sys/corectl.h> */
820 820 #define NT_ZONENAME 21 /* string from getzonenamebyid(3C) */
821 821 #define NT_FDINFO 22 /* open fd info */
822 822 #define NT_SPYMASTER 23 /* psinfo_t for agent LWP spymaster */
823 -#define NT_NUM 23
823 +#define NT_SECFLAGS 24 /* process security-flags */
824 +#define NT_NUM 24
824 825
825 826
826 827 #ifdef _KERNEL
827 828 /*
828 829 * The following routine checks the processor-specific
829 830 * fields of an ELF header.
830 831 */
831 832 int elfheadcheck(unsigned char, Elf32_Half, Elf32_Word);
832 833 #endif
833 834
834 835 #ifdef __cplusplus
835 836 }
836 837 #endif
837 838
838 839 #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_SPARC)
839 840 #include <sys/elf_SPARC.h>
840 841 #endif
841 842
842 843 #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_386)
843 844 #include <sys/elf_386.h>
844 845 #endif
845 846
846 847 #if defined(ELF_TARGET_ALL) || defined(ELF_TARGET_AMD64)
847 848 #include <sys/elf_amd64.h>
848 849 #endif
849 850
850 851 #endif /* _SYS_ELF_H */
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX