File indexing completed on 2025-05-11 08:24:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #ifndef _SYS_EXEC_ELF_H_
0033 #define _SYS_EXEC_ELF_H_
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 #if defined(_KERNEL) || defined(_STANDALONE)
0044 #include <sys/types.h>
0045 #else
0046 #include <inttypes.h>
0047 #include <stddef.h>
0048 #endif
0049
0050 #if defined(ELFSIZE)
0051 #define CONCAT(x,y) __CONCAT(x,y)
0052 #define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
0053 #define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
0054 #define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
0055 #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
0056 #endif
0057
0058 #if HAVE_NBTOOL_CONFIG_H
0059 #include <nbinclude/machine/elf_machdep.h>
0060 #else
0061 #include <machine/elf_machdep.h>
0062 #endif
0063
0064 typedef uint8_t Elf_Byte;
0065
0066 typedef uint32_t Elf32_Addr;
0067 #define ELF32_FSZ_ADDR 4
0068 typedef uint32_t Elf32_Off;
0069 typedef int32_t Elf32_SOff;
0070 #define ELF32_FSZ_OFF 4
0071 typedef int32_t Elf32_Sword;
0072 #define ELF32_FSZ_SWORD 4
0073 typedef uint32_t Elf32_Word;
0074 #define ELF32_FSZ_WORD 4
0075 typedef uint16_t Elf32_Half;
0076 #define ELF32_FSZ_HALF 2
0077 typedef uint64_t Elf32_Lword;
0078 #define ELF32_FSZ_LWORD 8
0079
0080 typedef uint64_t Elf64_Addr;
0081 #define ELF64_FSZ_ADDR 8
0082 typedef uint64_t Elf64_Off;
0083 typedef int64_t Elf64_SOff;
0084 #define ELF64_FSZ_OFF 8
0085
0086 typedef int32_t Elf64_Sword;
0087 #define ELF64_FSZ_SWORD 4
0088 typedef uint32_t Elf64_Word;
0089 #define ELF64_FSZ_WORD 4
0090
0091 typedef int64_t Elf64_Sxword;
0092 #define ELF64_FSZ_SXWORD 8
0093 typedef uint64_t Elf64_Xword;
0094 #define ELF64_FSZ_XWORD 8
0095 typedef uint64_t Elf64_Lword;
0096 #define ELF64_FSZ_LWORD 8
0097 typedef uint16_t Elf64_Half;
0098 #define ELF64_FSZ_HALF 2
0099
0100
0101
0102
0103 #define ELF_NIDENT 16
0104
0105 typedef struct {
0106 unsigned char e_ident[ELF_NIDENT];
0107 Elf32_Half e_type;
0108 Elf32_Half e_machine;
0109 Elf32_Word e_version;
0110 Elf32_Addr e_entry;
0111 Elf32_Off e_phoff;
0112 Elf32_Off e_shoff;
0113 Elf32_Word e_flags;
0114 Elf32_Half e_ehsize;
0115 Elf32_Half e_phentsize;
0116 Elf32_Half e_phnum;
0117 Elf32_Half e_shentsize;
0118 Elf32_Half e_shnum;
0119 Elf32_Half e_shstrndx;
0120 } Elf32_Ehdr;
0121
0122 typedef struct {
0123 unsigned char e_ident[ELF_NIDENT];
0124 Elf64_Half e_type;
0125 Elf64_Half e_machine;
0126 Elf64_Word e_version;
0127 Elf64_Addr e_entry;
0128 Elf64_Off e_phoff;
0129 Elf64_Off e_shoff;
0130 Elf64_Word e_flags;
0131 Elf64_Half e_ehsize;
0132 Elf64_Half e_phentsize;
0133 Elf64_Half e_phnum;
0134 Elf64_Half e_shentsize;
0135 Elf64_Half e_shnum;
0136 Elf64_Half e_shstrndx;
0137 } Elf64_Ehdr;
0138
0139
0140 #define EI_MAG0 0
0141 #define EI_MAG1 1
0142 #define EI_MAG2 2
0143 #define EI_MAG3 3
0144 #define EI_CLASS 4
0145 #define EI_DATA 5
0146 #define EI_VERSION 6
0147 #define EI_OSABI 7
0148 #define EI_ABIVERSION 8
0149 #define EI_PAD 9
0150 #define EI_NIDENT 16
0151
0152
0153 #define ELFMAG0 0x7f
0154 #define ELFMAG1 'E'
0155 #define ELFMAG2 'L'
0156 #define ELFMAG3 'F'
0157 #define ELFMAG "\177ELF"
0158 #define SELFMAG 4
0159
0160
0161 #define ELFCLASSNONE 0
0162 #define ELFCLASS32 1
0163 #define ELFCLASS64 2
0164 #define ELFCLASSNUM 3
0165
0166
0167 #define ELFDATANONE 0
0168 #define ELFDATA2LSB 1
0169 #define ELFDATA2MSB 2
0170
0171
0172 #define EV_NONE 0
0173 #define EV_CURRENT 1
0174 #define EV_NUM 2
0175
0176
0177 #define ELFOSABI_SYSV 0
0178 #define ELFOSABI_HPUX 1
0179 #define ELFOSABI_NETBSD 2
0180 #define ELFOSABI_GNU 3
0181 #define ELFOSABI_HURD 4
0182 #define ELFOSABI_86OPEN 5
0183 #define ELFOSABI_SOLARIS 6
0184 #define ELFOSABI_AIX 7
0185 #define ELFOSABI_IRIX 8
0186 #define ELFOSABI_FREEBSD 9
0187 #define ELFOSABI_TRU64 10
0188 #define ELFOSABI_MODESTO 11
0189 #define ELFOSABI_OPENBSD 12
0190 #define ELFOSABI_OPENVMS 13
0191 #define ELFOSABI_NSK 14
0192 #define ELFOSABI_AROS 15
0193 #define ELFOSABI_FENIXOS 16
0194 #define ELFOSABI_CLOUDABI 17
0195 #define ELFOSABI_OPENVOS 18
0196
0197 #define ELFOSABI_ARM 97
0198 #define ELFOSABI_STANDALONE 255
0199
0200 #define ELFOSABI_NONE ELFOSABI_SYSV
0201
0202
0203 #define ELFOSABI_LINUX ELFOSABI_GNU
0204 #define ELFOSABI_MONTEREY ELFOSABI_AIX
0205
0206
0207 #define ET_NONE 0
0208 #define ET_REL 1
0209 #define ET_EXEC 2
0210 #define ET_DYN 3
0211 #define ET_CORE 4
0212 #define ET_NUM 5
0213
0214 #define ET_LOOS 0xfe00
0215 #define ET_HIOS 0xfeff
0216 #define ET_LOPROC 0xff00
0217 #define ET_HIPROC 0xffff
0218
0219
0220 #define EM_NONE 0
0221 #define EM_M32 1
0222 #define EM_SPARC 2
0223 #define EM_386 3
0224 #define EM_68K 4
0225 #define EM_88K 5
0226 #define EM_486 6
0227 #define EM_IAMCU 6
0228 #define EM_860 7
0229 #define EM_MIPS 8
0230 #define EM_S370 9
0231 #define EM_MIPS_RS3_LE 10
0232
0233 #define EM_RS6000 11
0234 #define EM_PARISC 15
0235 #define EM_NCUBE 16
0236 #define EM_VPP500 17
0237 #define EM_SPARC32PLUS 18
0238 #define EM_960 19
0239 #define EM_PPC 20
0240 #define EM_PPC64 21
0241 #define EM_S390 22
0242 #define EM_SPU 23
0243
0244 #define EM_V800 36
0245 #define EM_FR20 37
0246 #define EM_RH32 38
0247 #define EM_RCE 39
0248 #define EM_ARM 40
0249 #define EM_OLD_ALPHA 41
0250 #define EM_SH 42
0251 #define EM_SPARCV9 43
0252 #define EM_TRICORE 44
0253 #define EM_ARC 45
0254 #define EM_H8_300 46
0255 #define EM_H8_300H 47
0256 #define EM_H8S 48
0257 #define EM_H8_500 49
0258 #define EM_IA_64 50
0259 #define EM_MIPS_X 51
0260 #define EM_COLDFIRE 52
0261 #define EM_68HC12 53
0262 #define EM_MMA 54
0263 #define EM_PCP 55
0264 #define EM_NCPU 56
0265 #define EM_NDR1 57
0266 #define EM_STARCORE 58
0267 #define EM_ME16 59
0268 #define EM_ST100 60
0269 #define EM_TINYJ 61
0270 #define EM_X86_64 62
0271 #define EM_PDSP 63
0272 #define EM_PDP10 64
0273 #define EM_PDP11 65
0274 #define EM_FX66 66
0275 #define EM_ST9PLUS 67
0276 #define EM_ST7 68
0277 #define EM_68HC16 69
0278 #define EM_68HC11 70
0279 #define EM_68HC08 71
0280 #define EM_68HC05 72
0281 #define EM_SVX 73
0282 #define EM_ST19 74
0283 #define EM_VAX 75
0284 #define EM_CRIS 76
0285 #define EM_JAVELIN 77
0286 #define EM_FIREPATH 78
0287 #define EM_ZSP 79
0288 #define EM_MMIX 80
0289 #define EM_HUANY 81
0290 #define EM_PRISM 82
0291 #define EM_AVR 83
0292 #define EM_FR30 84
0293 #define EM_D10V 85
0294 #define EM_D30V 86
0295 #define EM_V850 87
0296 #define EM_M32R 88
0297 #define EM_MN10300 89
0298 #define EM_MN10200 90
0299 #define EM_PJ 91
0300 #define EM_OR1K 92
0301 #define EM_OPENRISC EM_OR1K
0302 #define EM_ARC_A5 93
0303 #define EM_XTENSA 94
0304 #define EM_VIDEOCORE 95
0305 #define EM_TMM_GPP 96
0306 #define EM_NS32K 97
0307 #define EM_TPC 98
0308 #define EM_SNP1K 99
0309 #define EM_ST200 100
0310 #define EM_IP2K 101
0311 #define EM_MAX 102
0312 #define EM_CR 103
0313 #define EM_F2MC16 104
0314 #define EM_MSP430 105
0315 #define EM_BLACKFIN 106
0316 #define EM_SE_C33 107
0317 #define EM_SEP 108
0318 #define EM_ARCA 109
0319 #define EM_UNICORE 110
0320 #define EM_EXCESS 111
0321 #define EM_DXP 112
0322 #define EM_ALTERA_NIOS2 113
0323 #define EM_CRX 114
0324 #define EM_XGATE 115
0325 #define EM_C166 116
0326 #define EM_M16C 117
0327 #define EM_DSPIC30F 118
0328 #define EM_CE 119
0329 #define EM_M32C 120
0330
0331 #define EM_TSK3000 131
0332 #define EM_RS08 132
0333 #define EM_SHARC 133
0334 #define EM_ECOG2 134
0335 #define EM_SCORE7 135
0336 #define EM_DSP24 136
0337 #define EM_VIDEOCORE3 137
0338 #define EM_LATTICEMICO32 138
0339 #define EM_SE_C17 139
0340 #define EM_TI_C6000 140
0341 #define EM_TI_C2000 141
0342 #define EM_TI_C5500 142
0343 #define EM_TI_ARP32 143
0344 #define EM_TI_PRU 144
0345
0346 #define EM_MMDSP_PLUS 160
0347 #define EM_CYPRESS_M8C 161
0348 #define EM_R32C 162
0349 #define EM_TRIMEDIA 163
0350 #define EM_QDSP6 164
0351 #define EM_8051 165
0352 #define EM_STXP7X 166
0353 #define EM_NDS32 167
0354 #define EM_ECOG1 168
0355 #define EM_ECOG1X 168
0356 #define EM_MAXQ30 169
0357 #define EM_XIMO16 170
0358 #define EM_MANIK 171
0359 #define EM_CRAYNV2 172
0360 #define EM_RX 173
0361 #define EM_METAG 174
0362 #define EM_MCST_ELBRUS 175
0363 #define EM_ECOG16 176
0364 #define EM_CR16 177
0365 #define EM_ETPU 178
0366 #define EM_SLE9X 179
0367 #define EM_L10M 180
0368 #define EM_K10M 181
0369
0370 #define EM_AARCH64 183
0371
0372
0373 #define EM_TILE64 187
0374 #define EM_TILEPRO 188
0375 #define EM_MICROBLAZE 189
0376 #define EM_CUDA 190
0377 #define EM_TILEGX 191
0378 #define EM_CLOUDSHIELD 192
0379 #define EM_COREA_1ST 193
0380 #define EM_COREA_2ND 194
0381 #define EM_ARC_COMPACT2 195
0382 #define EM_OPEN8 196
0383 #define EM_RL78 197
0384 #define EM_VIDEOCORE5 198
0385 #define EM_78KOR 199
0386 #define EM_56800EX 200
0387 #define EM_BA1 201
0388 #define EM_BA2 202
0389 #define EM_XCORE 203
0390 #define EM_MCHP_PIC 204
0391 #define EM_INTEL205 205
0392 #define EM_INTEL206 206
0393 #define EM_INTEL207 207
0394 #define EM_INTEL208 208
0395 #define EM_INTEL209 209
0396 #define EM_KM32 210
0397 #define EM_KMX32 211
0398 #define EM_KMX16 212
0399 #define EM_KMX8 213
0400 #define EM_KVARC 214
0401 #define EM_CDP 215
0402 #define EM_COGE 216
0403 #define EM_COOL 217
0404 #define EM_NORC 218
0405 #define EM_CSR_KALIMBA 219
0406 #define EM_Z80 220
0407 #define EM_VISIUM 221
0408 #define EM_FT32 222
0409 #define EM_MOXIE 223
0410 #define EM_AMDGPU 224
0411
0412 #define EM_RISCV 243
0413
0414
0415 #define EM_AVR32 6317
0416 #define EM_ALPHA_EXP 36902
0417 #define EM_NUM 36903
0418
0419
0420
0421
0422 typedef struct {
0423 Elf32_Word p_type;
0424 Elf32_Off p_offset;
0425 Elf32_Addr p_vaddr;
0426 Elf32_Addr p_paddr;
0427 Elf32_Word p_filesz;
0428 Elf32_Word p_memsz;
0429 Elf32_Word p_flags;
0430 Elf32_Word p_align;
0431 } Elf32_Phdr;
0432
0433 typedef struct {
0434 Elf64_Word p_type;
0435 Elf64_Word p_flags;
0436 Elf64_Off p_offset;
0437 Elf64_Addr p_vaddr;
0438 Elf64_Addr p_paddr;
0439 Elf64_Xword p_filesz;
0440 Elf64_Xword p_memsz;
0441 Elf64_Xword p_align;
0442 } Elf64_Phdr;
0443
0444
0445 #define PT_NULL 0
0446 #define PT_LOAD 1
0447 #define PT_DYNAMIC 2
0448 #define PT_INTERP 3
0449 #define PT_NOTE 4
0450 #define PT_SHLIB 5
0451 #define PT_PHDR 6
0452 #define PT_TLS 7
0453 #define PT_NUM 8
0454
0455 #define PT_LOOS 0x60000000
0456
0457
0458 #define PT_GNU_EH_FRAME 0x6474e550
0459 #define PT_GNU_STACK 0x6474e551
0460 #define PT_GNU_RELRO 0x6474e552
0461
0462 #define PT_HIOS 0x6fffffff
0463 #define PT_LOPROC 0x70000000
0464 #define PT_HIPROC 0x7fffffff
0465
0466 #define PT_MIPS_REGINFO 0x70000000
0467 #define PT_MIPS_ABIFLAGS 0x70000003
0468
0469
0470 #define PF_R 0x4
0471 #define PF_W 0x2
0472 #define PF_X 0x1
0473
0474 #define PF_MASKOS 0x0ff00000
0475 #define PF_MASKPROC 0xf0000000
0476
0477
0478 #define PN_XNUM 0xffff
0479
0480
0481
0482
0483 typedef struct {
0484 Elf32_Word sh_name;
0485 Elf32_Word sh_type;
0486 Elf32_Word sh_flags;
0487 Elf32_Addr sh_addr;
0488 Elf32_Off sh_offset;
0489 Elf32_Word sh_size;
0490 Elf32_Word sh_link;
0491 Elf32_Word sh_info;
0492 Elf32_Word sh_addralign;
0493 Elf32_Word sh_entsize;
0494 } Elf32_Shdr;
0495
0496 typedef struct {
0497 Elf64_Word sh_name;
0498 Elf64_Word sh_type;
0499 Elf64_Xword sh_flags;
0500 Elf64_Addr sh_addr;
0501 Elf64_Off sh_offset;
0502 Elf64_Xword sh_size;
0503 Elf64_Word sh_link;
0504 Elf64_Word sh_info;
0505 Elf64_Xword sh_addralign;
0506 Elf64_Xword sh_entsize;
0507 } Elf64_Shdr;
0508
0509
0510 #define SHT_NULL 0
0511 #define SHT_PROGBITS 1
0512 #define SHT_SYMTAB 2
0513 #define SHT_STRTAB 3
0514 #define SHT_RELA 4
0515 #define SHT_HASH 5
0516 #define SHT_DYNAMIC 6
0517 #define SHT_NOTE 7
0518 #define SHT_NOBITS 8
0519 #define SHT_REL 9
0520 #define SHT_SHLIB 10
0521 #define SHT_DYNSYM 11
0522 #define SHT_INIT_ARRAY 14
0523 #define SHT_FINI_ARRAY 15
0524 #define SHT_PREINIT_ARRAY 16
0525 #define SHT_GROUP 17
0526 #define SHT_SYMTAB_SHNDX 18
0527 #define SHT_NUM 19
0528
0529 #define SHT_LOOS 0x60000000
0530 #define SHT_GNU_INCREMENTAL_INPUTS 0x6fff4700
0531 #define SHT_LOSUNW 0x6ffffff4
0532 #define SHT_SUNW_dof 0x6ffffff4
0533 #define SHT_GNU_ATTRIBUTES 0x6ffffff5
0534 #define SHT_SUNW_cap 0x6ffffff5
0535 #define SHT_SUNW_SIGNATURE 0x6ffffff6
0536 #define SHT_GNU_HASH 0x6ffffff6
0537 #define SHT_GNU_LIBLIST 0x6ffffff7
0538 #define SHT_SUNW_move 0x6ffffffa
0539 #define SHT_SUNW_COMDAT 0x6ffffffb
0540 #define SHT_SUNW_syminfo 0x6ffffffc
0541 #define SHT_SUNW_verdef 0x6ffffffd
0542 #define SHT_GNU_verdef SHT_SUNW_verdef
0543 #define SHT_SUNW_verneed 0x6ffffffe
0544 #define SHT_GNU_verneed SHT_SUNW_verneed
0545 #define SHT_SUNW_versym 0x6fffffff
0546 #define SHT_GNU_versym SHT_SUNW_versym
0547 #define SHT_HISUNW 0x6fffffff
0548 #define SHT_HIOS 0x6fffffff
0549 #define SHT_LOPROC 0x70000000
0550 #define SHT_AMD64_UNWIND 0x70000001
0551 #define SHT_ARM_EXIDX 0x70000001
0552 #define SHT_ARM_PREEMPTMAP 0x70000002
0553
0554 #define SHT_ARM_ATTRIBUTES 0x70000003
0555
0556 #define SHT_ARM_DEBUGOVERLAY 0x70000004
0557 #define SHT_ARM_OVERLAYSECTION 0x70000005
0558 #define SHT_MIPS_REGINFO 0x70000006
0559 #define SHT_MIPS_OPTIONS 0x7000000d
0560 #define SHT_MIPS_DWARF 0x7000001e
0561 #define SHT_MIPS_XHASH 0x7000002b
0562 #define SHT_HIPROC 0x7fffffff
0563 #define SHT_LOUSER 0x80000000
0564 #define SHT_HIUSER 0xffffffff
0565
0566
0567 #define SHF_WRITE 0x00000001
0568 #define SHF_ALLOC 0x00000002
0569 #define SHF_EXECINSTR 0x00000004
0570 #define SHF_MERGE 0x00000010
0571 #define SHF_STRINGS 0x00000020
0572 #define SHF_INFO_LINK 0x00000040
0573 #define SHF_LINK_ORDER 0x00000080
0574 #define SHF_OS_NONCONFORMING 0x00000100
0575 #define SHF_GROUP 0x00000200
0576 #define SHF_TLS 0x00000400
0577 #define SHF_MASKOS 0x0ff00000
0578 #define SHF_MASKPROC 0xf0000000
0579 #define SHF_ORDERED 0x40000000
0580 #define SHF_EXCLUDE 0x80000000
0581
0582
0583
0584
0585 typedef struct {
0586 Elf32_Word st_name;
0587 Elf32_Word st_value;
0588 Elf32_Word st_size;
0589 Elf_Byte st_info;
0590 Elf_Byte st_other;
0591 Elf32_Half st_shndx;
0592 } Elf32_Sym;
0593
0594 typedef struct {
0595 Elf64_Word st_name;
0596 Elf_Byte st_info;
0597 Elf_Byte st_other;
0598 Elf64_Half st_shndx;
0599 Elf64_Addr st_value;
0600 Elf64_Xword st_size;
0601 } Elf64_Sym;
0602
0603
0604 #define ELF_SYM_UNDEFINED 0
0605
0606 #define STN_UNDEF 0
0607
0608
0609 #define STB_LOCAL 0
0610 #define STB_GLOBAL 1
0611 #define STB_WEAK 2
0612 #define STB_NUM 3
0613
0614 #define STB_LOOS 10
0615 #define STB_HIOS 12
0616 #define STB_LOPROC 13
0617 #define STB_HIPROC 15
0618
0619
0620 #define STT_NOTYPE 0
0621 #define STT_OBJECT 1
0622 #define STT_FUNC 2
0623 #define STT_SECTION 3
0624 #define STT_FILE 4
0625 #define STT_COMMON 5
0626 #define STT_TLS 6
0627 #define STT_NUM 7
0628
0629 #define STT_LOOS 10
0630 #define STT_GNU_IFUNC 10
0631 #define STT_HIOS 12
0632 #define STT_LOPROC 13
0633 #define STT_HIPROC 15
0634
0635
0636 #define STV_DEFAULT 0
0637 #define STV_INTERNAL 1
0638 #define STV_HIDDEN 2
0639 #define STV_PROTECTED 3
0640 #define STV_EXPORTED 4
0641 #define STV_SINGLETON 5
0642 #define STV_ELIMINATE 6
0643
0644
0645 #define ELF_ST_BIND(info) ((uint32_t)(info) >> 4)
0646 #define ELF_ST_TYPE(info) ((uint32_t)(info) & 0xf)
0647 #define ELF_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | \
0648 ((type) & 0xf)))
0649 #define ELF_ST_VISIBILITY(other) ((uint32_t)(other) & 3)
0650
0651
0652
0653
0654 #define SHN_UNDEF 0
0655
0656 #define SHN_LORESERVE 0xff00
0657 #define SHN_ABS 0xfff1
0658 #define SHN_COMMON 0xfff2
0659 #define SHN_XINDEX 0xffff
0660 #define SHN_HIRESERVE 0xffff
0661
0662 #define SHN_LOPROC 0xff00
0663 #define SHN_HIPROC 0xff1f
0664 #define SHN_LOOS 0xff20
0665 #define SHN_HIOS 0xff3f
0666
0667 #define SHN_MIPS_ACOMMON 0xff00
0668 #define SHN_MIPS_TEXT 0xff01
0669 #define SHN_MIPS_DATA 0xff02
0670 #define SHN_MIPS_SCOMMON 0xff03
0671
0672
0673
0674
0675 typedef struct {
0676 Elf32_Word r_offset;
0677 Elf32_Word r_info;
0678 } Elf32_Rel;
0679
0680 typedef struct {
0681 Elf32_Word r_offset;
0682 Elf32_Word r_info;
0683 Elf32_Sword r_addend;
0684 } Elf32_Rela;
0685
0686
0687 #define ELF32_R_SYM(info) ((info) >> 8)
0688 #define ELF32_R_TYPE(info) ((info) & 0xff)
0689 #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
0690
0691 typedef struct {
0692 Elf64_Addr r_offset;
0693 Elf64_Xword r_info;
0694 } Elf64_Rel;
0695
0696 typedef struct {
0697 Elf64_Addr r_offset;
0698 Elf64_Xword r_info;
0699 Elf64_Sxword r_addend;
0700 } Elf64_Rela;
0701
0702
0703 #define ELF64_R_SYM(info) ((info) >> 32)
0704 #define ELF64_R_TYPE(info) ((info) & 0xffffffff)
0705 #define ELF64_R_INFO(sym,type) (((sym) << 32) + (type))
0706
0707
0708
0709
0710 typedef struct {
0711 Elf32_Lword m_value;
0712 Elf32_Word m_info;
0713 Elf32_Word m_poffset;
0714 Elf32_Half m_repeat;
0715 Elf32_Half m_stride;
0716 } Elf32_Move;
0717
0718 #define ELF32_M_SYM(info) ((info) >> 8)
0719 #define ELF32_M_SIZE(info) (info) & 0xff)
0720 #define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size))
0721
0722 typedef struct {
0723 Elf64_Lword m_value;
0724 Elf64_Xword m_info;
0725 Elf64_Xword m_poffset;
0726 Elf64_Word m_repeat;
0727 Elf64_Word m_stride;
0728 } Elf64_Move;
0729
0730 #define ELF64_M_SYM(info) ((info) >> 8)
0731 #define ELF64_M_SIZE(info) (info) & 0xff)
0732 #define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size))
0733
0734
0735
0736
0737 typedef struct {
0738 Elf32_Word c_tag;
0739 union {
0740 Elf32_Addr c_ptr;
0741 Elf32_Word c_val;
0742 } c_un;
0743 } Elf32_Cap;
0744
0745 typedef struct {
0746 Elf64_Xword c_tag;
0747 union {
0748 Elf64_Addr c_ptr;
0749 Elf64_Xword c_val;
0750 } c_un;
0751 } Elf64_Cap;
0752
0753
0754
0755
0756 typedef struct {
0757 Elf32_Word d_tag;
0758 union {
0759 Elf32_Addr d_ptr;
0760 Elf32_Word d_val;
0761 } d_un;
0762 } Elf32_Dyn;
0763
0764 typedef struct {
0765 Elf64_Xword d_tag;
0766 union {
0767 Elf64_Addr d_ptr;
0768 Elf64_Xword d_val;
0769 } d_un;
0770 } Elf64_Dyn;
0771
0772
0773 #define DT_NULL 0
0774 #define DT_NEEDED 1
0775 #define DT_PLTRELSZ 2
0776 #define DT_PLTGOT 3
0777 #define DT_HASH 4
0778 #define DT_STRTAB 5
0779 #define DT_SYMTAB 6
0780 #define DT_RELA 7
0781 #define DT_RELASZ 8
0782 #define DT_RELAENT 9
0783 #define DT_STRSZ 10
0784 #define DT_SYMENT 11
0785 #define DT_INIT 12
0786 #define DT_FINI 13
0787 #define DT_SONAME 14
0788 #define DT_RPATH 15
0789 #define DT_SYMBOLIC 16
0790 #define DT_REL 17
0791 #define DT_RELSZ 18
0792 #define DT_RELENT 19
0793 #define DT_PLTREL 20
0794 #define DT_DEBUG 21
0795 #define DT_TEXTREL 22
0796 #define DT_JMPREL 23
0797 #define DT_BIND_NOW 24
0798 #define DT_INIT_ARRAY 25
0799 #define DT_FINI_ARRAY 26
0800 #define DT_INIT_ARRAYSZ 27
0801 #define DT_FINI_ARRAYSZ 28
0802 #define DT_RUNPATH 29
0803 #define DT_FLAGS 30
0804 #define DT_ENCODING 31
0805 #define DT_PREINIT_ARRAY 32
0806 #define DT_PREINIT_ARRAYSZ 33
0807 #define DT_NUM 34
0808
0809 #define DT_LOOS 0x60000000
0810 #define DT_GNU_HASH 0x6ffffef5
0811 #define DT_VERSYM 0x6ffffff0
0812 #define DT_FLAGS_1 0x6ffffffb
0813 #define DT_VERDEF 0x6ffffffc
0814 #define DT_VERDEFNUM 0x6ffffffd
0815 #define DT_VERNEED 0x6ffffffe
0816 #define DT_VERNEEDNUM 0x6fffffff
0817 #define DT_HIOS 0x6fffffff
0818 #define DT_LOPROC 0x70000000
0819 #define DT_MIPS_XHASH 0x70000036
0820 #define DT_HIPROC 0x7fffffff
0821
0822
0823 #define DF_ORIGIN 0x00000001
0824 #define DF_SYMBOLIC 0x00000002
0825 #define DF_TEXTREL 0x00000004
0826 #define DF_BIND_NOW 0x00000008
0827 #define DF_STATIC_TLS 0x00000010
0828
0829
0830 #define DF_1_NOW 0x00000001
0831 #define DF_1_GLOBAL 0x00000002
0832 #define DF_1_GROUP 0x00000004
0833 #define DF_1_NODELETE 0x00000008
0834 #define DF_1_LOADFLTR 0x00000010
0835 #define DF_1_INITFIRST 0x00000020
0836 #define DF_1_NOOPEN 0x00000040
0837 #define DF_1_ORIGIN 0x00000080
0838 #define DF_1_DIRECT 0x00000100
0839 #define DF_1_INTERPOSE 0x00000400
0840 #define DF_1_NODEFLIB 0x00000800
0841 #define DF_1_NODUMP 0x00001000
0842 #define DF_1_CONFALT 0x00002000
0843 #define DF_1_ENDFILTEE 0x00004000
0844 #define DF_1_DISPRELDNE 0x00008000
0845 #define DF_1_DISPRELPND 0x00010000
0846 #define DF_1_NODIRECT 0x00020000
0847 #define DF_1_IGNMULDEF 0x00040000
0848 #define DF_1_NOKSYMS 0x00080000
0849 #define DF_1_NOHDR 0x00100000
0850 #define DF_1_EDITED 0x00200000
0851 #define DF_1_NORELOC 0x00400000
0852 #define DF_1_SYMINTPOSE 0x00800000
0853 #define DF_1_GLOBAUDIT 0x01000000
0854 #define DF_1_SINGLETON 0x02000000
0855 #define DF_1_STUB 0x04000000
0856 #define DF_1_PIE 0x08000000
0857
0858
0859
0860
0861 typedef struct {
0862 Elf32_Word a_type;
0863 Elf32_Word a_v;
0864 } Aux32Info;
0865
0866 typedef struct {
0867 Elf64_Word a_type;
0868 Elf64_Xword a_v;
0869 } Aux64Info;
0870
0871
0872 #define AT_NULL 0
0873 #define AT_IGNORE 1
0874 #define AT_EXECFD 2
0875 #define AT_PHDR 3
0876 #define AT_PHENT 4
0877 #define AT_PHNUM 5
0878 #define AT_PAGESZ 6
0879 #define AT_BASE 7
0880 #define AT_FLAGS 8
0881 #define AT_ENTRY 9
0882 #define AT_DCACHEBSIZE 10
0883 #define AT_ICACHEBSIZE 11
0884 #define AT_UCACHEBSIZE 12
0885 #define AT_STACKBASE 13
0886
0887
0888 #define AT_MIPS_NOTELF 10
0889
0890 #define AT_EUID 2000
0891 #define AT_RUID 2001
0892 #define AT_EGID 2002
0893 #define AT_RGID 2003
0894
0895
0896 #define AT_SUN_LDELF 2004
0897 #define AT_SUN_LDSHDR 2005
0898 #define AT_SUN_LDNAME 2006
0899 #define AT_SUN_LPGSIZE 2007
0900
0901
0902 #define AT_SUN_PLATFORM 2008
0903 #define AT_SUN_HWCAP 2009
0904 #define AT_SUN_IFLUSH 2010
0905 #define AT_SUN_CPU 2011
0906
0907 #define AT_SUN_EMUL_ENTRY 2012
0908 #define AT_SUN_EMUL_EXECFD 2013
0909
0910 #define AT_SUN_EXECNAME 2014
0911
0912
0913
0914
0915 typedef struct {
0916 uint32_t gh_nbuckets;
0917 uint32_t gh_symndx;
0918 uint32_t gh_maskwords;
0919 uint32_t gh_shift2;
0920 } Elf_GNU_Hash_Header;
0921
0922
0923
0924
0925 typedef struct {
0926 Elf32_Word n_namesz;
0927 Elf32_Word n_descsz;
0928 Elf32_Word n_type;
0929 } Elf32_Nhdr;
0930
0931 typedef struct {
0932 Elf64_Word n_namesz;
0933 Elf64_Word n_descsz;
0934 Elf64_Word n_type;
0935 } Elf64_Nhdr;
0936
0937 #define ELF_NOTE_GNU_NAMESZ 4
0938 #define ELF_NOTE_GNU_NAME "GNU\0"
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952 #define ELF_NOTE_TYPE_ABI_TAG 1
0953 #define ELF_NOTE_ABI_NAME ELF_NOTE_GNU_NAME
0954 #define ELF_NOTE_ABI_NAMESZ ELF_NOTE_GNU_NAMESZ
0955 #define ELF_NOTE_ABI_DESCSZ 16
0956
0957 #define ELF_NOTE_ABI_OS_LINUX 0
0958 #define ELF_NOTE_ABI_OS_HURD 1
0959 #define ELF_NOTE_ABI_OS_SOLARIS 2
0960 #define ELF_NOTE_ABI_OS_KFREEBSD 3
0961 #define ELF_NOTE_ABI_OS_KNETBSD 4
0962
0963
0964 #define ELF_NOTE_OGCC_NAMESZ 8
0965 #define ELF_NOTE_OGCC_NAME "01.01\0\0\0\0"
0966 #define ELF_NOTE_OGCC_DESCSZ 0
0967
0968
0969
0970
0971
0972
0973
0974
0975
0976
0977
0978 #define ELF_NOTE_TYPE_GNU_HWCAP 2
0979
0980
0981
0982
0983
0984
0985
0986
0987
0988
0989 #define ELF_NOTE_TYPE_GNU_BUILD_ID 3
0990
0991
0992
0993
0994
0995
0996
0997
0998
0999
1000
1001 #define ELF_NOTE_TYPE_SUSE_TAG 1
1002
1003 #define ELF_NOTE_SUSE_NAMESZ 5
1004 #define ELF_NOTE_SUSE_DESCSZ 2
1005
1006 #define ELF_NOTE_SUSE_NAME "SuSE\0"
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020 #define ELF_NOTE_TYPE_SUSE_VERSION_TAG 0x45537553
1021
1022 #define ELF_NOTE_SUSE_VERSION_NAMESZ 8
1023 #define ELF_NOTE_SUSE_VERSION_DESCSZ 8
1024
1025 #define ELF_NOTE_SUSE_VERSION_NAME "SuSE\0\0\0\0"
1026
1027
1028
1029
1030
1031
1032
1033
1034 #define ELF_NOTE_TYPE_GO_BUILDID_TAG 4
1035 #define ELF_NOTE_GO_BUILDID_NAMESZ 4
1036 #define ELF_NOTE_GO_BUILDID_DESCSZ 40
1037 #define ELF_NOTE_GO_BUILDID_NAME "Go\0\0"
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051 #define ELF_NOTE_TYPE_NETBSD_TAG 1
1052
1053 #define ELF_NOTE_NETBSD_NAMESZ 7
1054 #define ELF_NOTE_NETBSD_DESCSZ 4
1055
1056 #define ELF_NOTE_NETBSD_NAME "NetBSD\0\0"
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066 #define ELF_NOTE_TYPE_NETBSD_EMUL_TAG 2
1067 #define ELF_NOTE_NETBSD_EMUL_NAMESZ 7
1068 #define ELF_NOTE_NETBSD_EMUL_DESCSZ 7
1069
1070 #define ELF_NOTE_NETBSD_EMUL_NAME "NetBSD\0\0"
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081 #define ELF_NOTE_TYPE_PAX_TAG 3
1082 #define ELF_NOTE_PAX_MPROTECT 0x01
1083 #define ELF_NOTE_PAX_NOMPROTECT 0x02
1084 #define ELF_NOTE_PAX_GUARD 0x04
1085 #define ELF_NOTE_PAX_NOGUARD 0x08
1086 #define ELF_NOTE_PAX_ASLR 0x10
1087 #define ELF_NOTE_PAX_NOASLR 0x20
1088 #define ELF_NOTE_PAX_NAMESZ 4
1089 #define ELF_NOTE_PAX_NAME "PaX\0"
1090 #define ELF_NOTE_PAX_DESCSZ 4
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117 #define ELF_NOTE_NETBSD_CORE_NAME "NetBSD-CORE"
1118
1119 #define ELF_NOTE_NETBSD_CORE_PROCINFO 1
1120 #define ELF_NOTE_NETBSD_CORE_AUXV 2
1121
1122 #define NETBSD_ELFCORE_PROCINFO_VERSION 1
1123
1124 struct netbsd_elfcore_procinfo {
1125
1126 uint32_t cpi_version;
1127 uint32_t cpi_cpisize;
1128 uint32_t cpi_signo;
1129 uint32_t cpi_sigcode;
1130 uint32_t cpi_sigpend[4];
1131 uint32_t cpi_sigmask[4];
1132 uint32_t cpi_sigignore[4];
1133 uint32_t cpi_sigcatch[4];
1134 int32_t cpi_pid;
1135 int32_t cpi_ppid;
1136 int32_t cpi_pgrp;
1137 int32_t cpi_sid;
1138 uint32_t cpi_ruid;
1139 uint32_t cpi_euid;
1140 uint32_t cpi_svuid;
1141 uint32_t cpi_rgid;
1142 uint32_t cpi_egid;
1143 uint32_t cpi_svgid;
1144 uint32_t cpi_nlwps;
1145 int8_t cpi_name[32];
1146
1147 int32_t cpi_siglwp;
1148 };
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158 #define ELF_NOTE_TYPE_MARCH_TAG 5
1159
1160 #define ELF_NOTE_MARCH_NAMESZ ELF_NOTE_NETBSD_NAMESZ
1161
1162 #define ELF_NOTE_MARCH_NAME ELF_NOTE_NETBSD_NAME
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172 #define ELF_NOTE_TYPE_MCMODEL_TAG 6
1173
1174 #define ELF_NOTE_MCMODEL_NAMESZ ELF_NOTE_NETBSD_NAMESZ
1175
1176 #define ELF_NOTE_MCMODEL_NAME ELF_NOTE_NETBSD_NAME
1177
1178
1179 #if !defined(ELFSIZE)
1180 # if defined(_RUMPKERNEL) || !defined(_KERNEL)
1181 # define ELFSIZE ARCH_ELFSIZE
1182 # else
1183 # define ELFSIZE KERN_ELFSIZE
1184 # endif
1185 #endif
1186
1187 #if defined(ELFSIZE)
1188 #define CONCAT(x,y) __CONCAT(x,y)
1189 #define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
1190 #define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
1191 #define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
1192 #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
1193 #define ElfW(x) CONCAT(Elf,CONCAT(ELFSIZE,CONCAT(_,x)))
1194 #endif
1195
1196 #if defined(ELFSIZE) && (ELFSIZE == 32)
1197 #define Elf_Ehdr Elf32_Ehdr
1198 #define Elf_Phdr Elf32_Phdr
1199 #define Elf_Shdr Elf32_Shdr
1200 #define Elf_Sym Elf32_Sym
1201 #define Elf_Rel Elf32_Rel
1202 #define Elf_Rela Elf32_Rela
1203 #define Elf_Dyn Elf32_Dyn
1204 #define Elf_Word Elf32_Word
1205 #define Elf_Sword Elf32_Sword
1206 #define Elf_Half Elf32_Half
1207 #define Elf_Addr Elf32_Addr
1208 #define Elf_Off Elf32_Off
1209 #define Elf_SOff Elf32_SOff
1210 #define Elf_Nhdr Elf32_Nhdr
1211 #define Elf_Verdef Elf32_Verdef
1212 #define Elf_Verdaux Elf32_Verdaux
1213 #define Elf_Verneed Elf32_Verneed
1214 #define Elf_Vernaux Elf32_Vernaux
1215 #define Elf_Versym Elf32_Versym
1216
1217 #define ELF_R_SYM ELF32_R_SYM
1218 #define ELF_R_TYPE ELF32_R_TYPE
1219 #define ELFCLASS ELFCLASS32
1220
1221 #define AuxInfo Aux32Info
1222 #elif defined(ELFSIZE) && (ELFSIZE == 64)
1223 #define Elf_Ehdr Elf64_Ehdr
1224 #define Elf_Phdr Elf64_Phdr
1225 #define Elf_Shdr Elf64_Shdr
1226 #define Elf_Sym Elf64_Sym
1227 #define Elf_Rel Elf64_Rel
1228 #define Elf_Rela Elf64_Rela
1229 #define Elf_Dyn Elf64_Dyn
1230 #define Elf_Word Elf64_Word
1231 #define Elf_Sword Elf64_Sword
1232 #define Elf_Half Elf64_Half
1233 #define Elf_Addr Elf64_Addr
1234 #define Elf_Off Elf64_Off
1235 #define Elf_SOff Elf64_SOff
1236 #define Elf_Nhdr Elf64_Nhdr
1237 #define Elf_Verdef Elf64_Verdef
1238 #define Elf_Verdaux Elf64_Verdaux
1239 #define Elf_Verneed Elf64_Verneed
1240 #define Elf_Vernaux Elf64_Vernaux
1241 #define Elf_Versym Elf64_Versym
1242
1243 #define ELF_R_SYM ELF64_R_SYM
1244 #define ELF_R_TYPE ELF64_R_TYPE
1245 #define ELFCLASS ELFCLASS64
1246
1247 #define AuxInfo Aux64Info
1248 #endif
1249
1250 #ifndef Elf_Symindx
1251 #define Elf_Symindx uint32_t
1252 #endif
1253
1254 #define ELF32_ST_BIND(info) ELF_ST_BIND(info)
1255 #define ELF32_ST_TYPE(info) ELF_ST_TYPE(info)
1256 #define ELF32_ST_INFO(bind,type) ELF_ST_INFO(bind,type)
1257 #define ELF32_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other)
1258
1259 #define ELF64_ST_BIND(info) ELF_ST_BIND(info)
1260 #define ELF64_ST_TYPE(info) ELF_ST_TYPE(info)
1261 #define ELF64_ST_INFO(bind,type) ELF_ST_INFO(bind,type)
1262 #define ELF64_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other)
1263
1264 typedef struct {
1265 Elf32_Half si_boundto;
1266 Elf32_Half si_flags;
1267 } Elf32_Syminfo;
1268
1269 typedef struct {
1270 Elf64_Word si_boundto;
1271 Elf64_Word si_flags;
1272 } Elf64_Syminfo;
1273
1274 #define SYMINFO_FLG_DIRECT 0x0001
1275
1276 #define SYMINFO_FLG_PASSTHRU 0x0002
1277 #define SYMINFO_FLG_COPY 0x0004
1278 #define SYMINFO_FLG_LAZYLOAD 0x0008
1279
1280 #define SYMINFO_FLG_DIRECTBIND 0x0010
1281
1282 #define SYMINFO_FLG_NOEXTDIRECT 0x0020
1283
1284 #define SYMINFO_FLG_FILTER 0x0002
1285 #define SYMINFO_FLG_AUXILIARY 0x0040
1286
1287 #define SYMINFO_BT_SELF 0xffff
1288 #define SYMINFO_BT_PARENT 0xfffe
1289 #define SYMINFO_BT_NONE 0xfffd
1290 #define SYMINFO_BT_EXTERN 0xfffc
1291 #define SYMINFO_BT_LOWRESERVE 0xff00
1292
1293 #define SYMINFO_NONE 0
1294 #define SYMINFO_CURRENT 1
1295 #define SYMINFO_NUM 2
1296
1297
1298
1299
1300 #define VER_DEF_NONE 0
1301 #define VER_DEF_CURRENT 1
1302
1303
1304
1305
1306 #define VER_DEF_IDX(x) VER_NDX(x)
1307
1308
1309
1310
1311 #define VER_FLG_BASE 0x1
1312 #define VER_FLG_WEAK 0x2
1313
1314
1315
1316
1317 #define VER_NDX_LOCAL 0
1318 #define VER_NDX_GLOBAL 1
1319 #define VER_NDX_GIVEN 2
1320
1321
1322
1323
1324 #define VER_NEED_NONE 0
1325 #define VER_NEED_CURRENT 1
1326
1327
1328
1329
1330 #define VER_NEED_HIDDEN VER_NDX_HIDDEN
1331 #define VER_NEED_IDX(x) VER_NDX(x)
1332
1333
1334 #define VER_NDX_HIDDEN 0x8000
1335 #define VER_NDX(x) ((x) & ~VER_NDX_HIDDEN)
1336
1337
1338
1339
1340 #define VERSYM_HIDDEN 0x8000
1341 #define VERSYM_VERSION 0x7fff
1342
1343 #define ELF_VER_CHR '@'
1344
1345
1346
1347
1348
1349 typedef struct {
1350 Elf32_Half vd_version;
1351 Elf32_Half vd_flags;
1352 Elf32_Half vd_ndx;
1353 Elf32_Half vd_cnt;
1354 Elf32_Word vd_hash;
1355 Elf32_Word vd_aux;
1356 Elf32_Word vd_next;
1357 } Elf32_Verdef;
1358 typedef Elf32_Verdef Elf64_Verdef;
1359
1360 typedef struct {
1361 Elf32_Word vda_name;
1362 Elf32_Word vda_next;
1363 } Elf32_Verdaux;
1364 typedef Elf32_Verdaux Elf64_Verdaux;
1365
1366 typedef struct {
1367 Elf32_Half vn_version;
1368 Elf32_Half vn_cnt;
1369 Elf32_Word vn_file;
1370 Elf32_Word vn_aux;
1371 Elf32_Word vn_next;
1372 } Elf32_Verneed;
1373 typedef Elf32_Verneed Elf64_Verneed;
1374
1375 typedef struct {
1376 Elf32_Word vna_hash;
1377 Elf32_Half vna_flags;
1378 Elf32_Half vna_other;
1379 Elf32_Word vna_name;
1380 Elf32_Word vna_next;
1381 } Elf32_Vernaux;
1382 typedef Elf32_Vernaux Elf64_Vernaux;
1383
1384 typedef struct {
1385 Elf32_Half vs_vers;
1386 } Elf32_Versym;
1387 typedef Elf32_Versym Elf64_Versym;
1388
1389 #ifdef _KERNEL
1390
1391
1392
1393
1394 #define ELF_MAXPHNUM 128
1395 #define ELF_MAXSHNUM 32768
1396 #define ELF_MAXNOTESIZE 1024
1397
1398 #define ELF_AUX_ENTRIES 15
1399 #define ELF32_NO_ADDR (~(Elf32_Addr)0)
1400 #define ELF32_LINK_ADDR ((Elf32_Addr)-2)
1401 #define ELF64_NO_ADDR (~(Elf64_Addr)0)
1402 #define ELF64_LINK_ADDR ((Elf64_Addr)-2)
1403
1404 #if defined(ELFSIZE) && (ELFSIZE == 64)
1405 #define ELF_NO_ADDR ELF64_NO_ADDR
1406 #define ELF_LINK_ADDR ELF64_LINK_ADDR
1407 #elif defined(ELFSIZE) && (ELFSIZE == 32)
1408 #define ELF_NO_ADDR ELF32_NO_ADDR
1409 #define ELF_LINK_ADDR ELF32_LINK_ADDR
1410 #endif
1411
1412 #ifndef ELF32_EHDR_FLAGS_OK
1413 #define ELF32_EHDR_FLAGS_OK(eh) 1
1414 #endif
1415
1416 #ifndef ELF64_EHDR_FLAGS_OK
1417 #define ELF64_EHDR_FLAGS_OK(eh) 1
1418 #endif
1419
1420 #if defined(ELFSIZE) && (ELFSIZE == 64)
1421 #define ELF_EHDR_FLAGS_OK(eh) ELF64_EHDR_FLAGS_OK(eh)
1422 #else
1423 #define ELF_EHDR_FLAGS_OK(eh) ELF32_EHDR_FLAGS_OK(eh)
1424 #endif
1425
1426 #if defined(ELFSIZE)
1427 struct elf_args {
1428 Elf_Addr arg_entry;
1429 Elf_Addr arg_interp;
1430 Elf_Addr arg_phaddr;
1431 Elf_Addr arg_phentsize;
1432 Elf_Addr arg_phnum;
1433 };
1434 #endif
1435
1436 #ifdef _KERNEL_OPT
1437 #include "opt_execfmt.h"
1438 #endif
1439
1440 struct ps_strings;
1441 struct coredump_iostate;
1442 struct note_state;
1443 struct exec_package;
1444
1445 #ifdef EXEC_ELF32
1446 int exec_elf32_makecmds(struct lwp *, struct exec_package *);
1447 int elf32_populate_auxv(struct lwp *, struct exec_package *, char **);
1448 int elf32_copyargs(struct lwp *, struct exec_package *,
1449 struct ps_strings *, char **, void *);
1450
1451 int elf32_check_header(Elf32_Ehdr *);
1452 #endif
1453
1454 int real_coredump_elf32(struct lwp *, struct coredump_iostate *);
1455 int coredump_elf32(struct lwp *, struct coredump_iostate *);
1456 void coredump_savenote_elf32(struct note_state *, unsigned int,
1457 const char *, void *, size_t);
1458
1459
1460 #ifdef EXEC_ELF64
1461 int exec_elf64_makecmds(struct lwp *, struct exec_package *);
1462 int elf64_populate_auxv(struct lwp *, struct exec_package *, char **);
1463 int elf64_copyargs(struct lwp *, struct exec_package *,
1464 struct ps_strings *, char **, void *);
1465
1466 int elf64_check_header(Elf64_Ehdr *);
1467 #endif
1468
1469 int real_coredump_elf64(struct lwp *, struct coredump_iostate *);
1470 int coredump_elf64(struct lwp *, struct coredump_iostate *);
1471 void coredump_savenote_elf64(struct note_state *, unsigned int,
1472 const char *, void *, size_t);
1473
1474
1475 #endif
1476
1477 #endif