32 #ifndef _SYS_EXEC_ELF_H_ 33 #define _SYS_EXEC_ELF_H_ 43 #if defined(_KERNEL) || defined(_STANDALONE) 44 #include <sys/types.h> 50 #define CONCAT(x,y) __CONCAT(x,y) 51 #define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x))) 52 #define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y)))) 53 #define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE)) 54 #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x))) 57 #if HAVE_NBTOOL_CONFIG_H 58 #include <nbinclude/machine/elf_machdep.h> 60 #include <machine/elf_machdep.h> 63 typedef uint8_t Elf_Byte;
65 typedef uint32_t Elf32_Addr;
66 #define ELF32_FSZ_ADDR 4 67 typedef uint32_t Elf32_Off;
68 typedef int32_t Elf32_SOff;
69 #define ELF32_FSZ_OFF 4 70 typedef int32_t Elf32_Sword;
71 #define ELF32_FSZ_SWORD 4 72 typedef uint32_t Elf32_Word;
73 #define ELF32_FSZ_WORD 4 74 typedef uint16_t Elf32_Half;
75 #define ELF32_FSZ_HALF 2 76 typedef uint64_t Elf32_Lword;
77 #define ELF32_FSZ_LWORD 8 79 typedef uint64_t Elf64_Addr;
80 #define ELF64_FSZ_ADDR 8 81 typedef uint64_t Elf64_Off;
82 typedef int64_t Elf64_SOff;
83 #define ELF64_FSZ_OFF 8 84 typedef int32_t Elf64_Shalf;
85 #define ELF64_FSZ_SHALF 4 87 #ifndef ELF64_FSZ_SWORD 88 typedef int32_t Elf64_Sword;
89 #define ELF64_FSZ_SWORD 4 91 #ifndef ELF64_FSZ_WORD 92 typedef uint32_t Elf64_Word;
93 #define ELF64_FSZ_WORD 4 96 typedef int64_t Elf64_Sxword;
97 #define ELF64_FSZ_SXWORD 8 98 typedef uint64_t Elf64_Xword;
99 #define ELF64_FSZ_XWORD 8 100 typedef uint64_t Elf64_Lword;
101 #define ELF64_FSZ_LWORD 8 102 typedef uint32_t Elf64_Half;
103 #define ELF64_FSZ_HALF 4 104 typedef uint16_t Elf64_Quarter;
105 #define ELF64_FSZ_QUARTER 2 110 #define ELF_NIDENT 16 113 unsigned char e_ident[ELF_NIDENT];
115 Elf32_Half e_machine;
116 Elf32_Word e_version;
122 Elf32_Half e_phentsize;
124 Elf32_Half e_shentsize;
126 Elf32_Half e_shstrndx;
130 unsigned char e_ident[ELF_NIDENT];
131 Elf64_Quarter e_type;
132 Elf64_Quarter e_machine;
133 Elf64_Half e_version;
138 Elf64_Quarter e_ehsize;
139 Elf64_Quarter e_phentsize;
140 Elf64_Quarter e_phnum;
141 Elf64_Quarter e_shentsize;
142 Elf64_Quarter e_shnum;
143 Elf64_Quarter e_shstrndx;
155 #define EI_ABIVERSION 8 164 #define ELFMAG "\177ELF" 168 #define ELFCLASSNONE 0 171 #define ELFCLASSNUM 3 174 #define ELFDATANONE 0 175 #define ELFDATA2LSB 1 176 #define ELFDATA2MSB 2 184 #define ELFOSABI_SYSV 0 185 #define ELFOSABI_HPUX 1 186 #define ELFOSABI_NETBSD 2 187 #define ELFOSABI_LINUX 3 188 #define ELFOSABI_HURD 4 189 #define ELFOSABI_86OPEN 5 190 #define ELFOSABI_SOLARIS 6 191 #define ELFOSABI_MONTEREY 7 192 #define ELFOSABI_IRIX 8 193 #define ELFOSABI_FREEBSD 9 194 #define ELFOSABI_TRU64 10 195 #define ELFOSABI_MODESTO 11 196 #define ELFOSABI_OPENBSD 12 197 #define ELFOSABI_OPENVMS 13 198 #define ELFOSABI_NSK 14 199 #define ELFOSABI_AROS 15 201 #define ELFOSABI_ARM 97 202 #define ELFOSABI_STANDALONE 255 204 #define ELFOSABI_NONE ELFOSABI_SYSV 205 #define ELFOSABI_AIX ELFOSABI_MONTEREY 215 #define ET_LOOS 0xfe00 216 #define ET_HIOS 0xfeff 217 #define ET_LOPROC 0xff00 218 #define ET_HIPROC 0xffff 231 #define EM_MIPS_RS3_LE 10 237 #define EM_SPARC32PLUS 18 250 #define EM_SPARCV9 43 251 #define EM_TRICORE 44 254 #define EM_H8_300H 47 259 #define EM_COLDFIRE 52 265 #define EM_STARCORE 58 274 #define EM_ST9PLUS 67 284 #define EM_JAVELIN 77 285 #define EM_FIREPATH 78 296 #define EM_MN10300 89 297 #define EM_MN10200 90 299 #define EM_OPENRISC 92 302 #define EM_VIDEOCORE 95 303 #define EM_TMM_GPP 96 311 #define EM_F2MC16 104 312 #define EM_MSP430 105 313 #define EM_BLACKFIN 106 314 #define EM_SE_C33 107 317 #define EM_UNICORE 110 318 #define EM_EXCESS 111 320 #define EM_ALTERA_NIOS2 113 325 #define EM_DSPIC30F 118 329 #define EM_LATTICEMICO32 138 331 #define EM_MICROBLAZE 189 333 #define EM_MOXIE 0xFEED 336 #define EM_AVR32 6317 337 #define EM_ALPHA_EXP 36902 360 Elf64_Xword p_filesz;
375 #define PT_LOOS 0x60000000 376 #define PT_HIOS 0x6fffffff 377 #define PT_LOPROC 0x70000000 378 #define PT_HIPROC 0x7fffffff 380 #define PT_MIPS_REGINFO 0x70000000 387 #define PF_MASKOS 0x0ff00000 388 #define PF_MASKPROC 0xf0000000 391 #define PN_XNUM 0xffff 405 Elf32_Word sh_addralign;
406 Elf32_Word sh_entsize;
412 Elf64_Xword sh_flags;
418 Elf64_Xword sh_addralign;
419 Elf64_Xword sh_entsize;
424 #define SHT_PROGBITS 1 429 #define SHT_DYNAMIC 6 434 #define SHT_DYNSYM 11 435 #define SHT_INIT_ARRAY 14 436 #define SHT_FINI_ARRAY 15 437 #define SHT_PREINIT_ARRAY 16 439 #define SHT_SYMTAB_SHNDX 18 442 #define SHT_LOOS 0x60000000 443 #define SHT_SUNW_move 0x6ffffffa 444 #define SHT_SUNW_syminfo 0x6ffffffc 445 #define SHT_SUNW_verdef 0x6ffffffd 446 #define SHT_GNU_verdef SHT_SUNW_verdef 447 #define SHT_SUNW_verneed 0x6ffffffe 448 #define SHT_GNU_verneed SHT_SUNW_verneed 449 #define SHT_SUNW_versym 0x6fffffff 450 #define SHT_GNU_versym SHT_SUNW_versym 451 #define SHT_HIOS 0x6fffffff 452 #define SHT_LOPROC 0x70000000 453 #define SHT_AMD64_UNWIND 0x70000001 454 #define SHT_HIPROC 0x7fffffff 455 #define SHT_LOUSER 0x80000000 456 #define SHT_HIUSER 0xffffffff 459 #define SHF_WRITE 0x1 460 #define SHF_ALLOC 0x2 461 #define SHF_EXECINSTR 0x4 462 #define SHF_MERGE 0x10 463 #define SHF_STRINGS 0x20 464 #define SHF_INFO_LINK 0x40 465 #define SHF_LINK_ORDER 0x80 467 #define SHF_MASKOS 0x0f000000 468 #define SHF_MASKPROC 0xf0000000 486 Elf64_Quarter st_shndx;
492 #define ELF_SYM_UNDEFINED 0 504 #define STB_LOPROC 13 505 #define STB_HIPROC 15 511 #define STT_SECTION 3 519 #define STT_LOPROC 13 520 #define STT_HIPROC 15 523 #define STV_DEFAULT 0 524 #define STV_INTERNAL 1 526 #define STV_PROTECTED 3 527 #define STV_EXPORTED 4 528 #define STV_SINGLETON 5 529 #define STV_ELIMINATE 6 532 #define ELF_ST_BIND(info) ((uint32_t)(info) >> 4) 533 #define ELF_ST_TYPE(info) ((uint32_t)(info) & 0xf) 534 #define ELF_ST_INFO(bind,type) ((Elf_Byte)(((bind) << 4) | \ 536 #define ELF_ST_VISIBILITY(other) ((uint32_t)(other) & 3) 543 #define SHN_LORESERVE 0xff00 544 #define SHN_ABS 0xfff1 545 #define SHN_COMMON 0xfff2 546 #define SHN_XINDEX 0xffff 547 #define SHN_HIRESERVE 0xffff 549 #define SHN_LOPROC 0xff00 550 #define SHN_HIPROC 0xff1f 551 #define SHN_LOOS 0xff20 552 #define SHN_HIOS 0xff3f 554 #define SHN_MIPS_ACOMMON 0xff00 555 #define SHN_MIPS_TEXT 0xff01 556 #define SHN_MIPS_DATA 0xff02 557 #define SHN_MIPS_SCOMMON 0xff03 570 Elf32_Sword r_addend;
574 #define ELF32_R_SYM(info) ((info) >> 8) 575 #define ELF32_R_TYPE(info) ((info) & 0xff) 576 #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type)) 586 Elf64_Sxword r_addend;
590 #define ELF64_R_SYM(info) ((info) >> 32) 591 #define ELF64_R_TYPE(info) ((info) & 0xffffffff) 592 #define ELF64_R_INFO(sym,type) (((sym) << 32) + (type)) 600 Elf32_Word m_poffset;
605 #define ELF32_M_SYM(info) ((info) >> 8) 606 #define ELF32_M_SIZE(info) (info) & 0xff) 607 #define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) 612 Elf64_Xword m_poffset;
617 #define ELF64_M_SYM(info) ((info) >> 8) 618 #define ELF64_M_SIZE(info) (info) & 0xff) 619 #define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size)) 662 #define DT_PLTRELSZ 2 676 #define DT_SYMBOLIC 16 682 #define DT_TEXTREL 22 684 #define DT_BIND_NOW 24 685 #define DT_INIT_ARRAY 25 686 #define DT_FINI_ARRAY 26 687 #define DT_INIT_ARRAYSZ 27 688 #define DT_FINI_ARRAYSZ 28 691 #define DT_LOOS 0x60000000 692 #define DT_VERSYM 0x6ffffff0 693 #define DT_FLAGS_1 0x6ffffffb 694 #define DT_VERDEF 0x6ffffffc 695 #define DT_VERDEFNUM 0x6ffffffd 696 #define DT_VERNEED 0x6ffffffe 697 #define DT_VERNEEDNUM 0x6fffffff 698 #define DT_HIOS 0x6fffffff 699 #define DT_LOPROC 0x70000000 700 #define DT_HIPROC 0x7fffffff 703 #define DF_1_INITFIRST 0x00000020 729 #define AT_DCACHEBSIZE 10 730 #define AT_ICACHEBSIZE 11 731 #define AT_UCACHEBSIZE 12 734 #define AT_MIPS_NOTELF 10 742 #define AT_SUN_LDELF 2004 743 #define AT_SUN_LDSHDR 2005 744 #define AT_SUN_LDNAME 2006 745 #define AT_SUN_LPGSIZE 2007 748 #define AT_SUN_PLATFORM 2008 749 #define AT_SUN_HWCAP 2009 750 #define AT_SUN_IFLUSH 2010 751 #define AT_SUN_CPU 2011 753 #define AT_SUN_EMUL_ENTRY 2012 754 #define AT_SUN_EMUL_EXECFD 2013 756 #define AT_SUN_EXECNAME 2014 773 #define ELF_NOTE_TYPE_ABI_TAG 1 776 #define ELF_NOTE_ABI_NAMESZ 4 777 #define ELF_NOTE_ABI_DESCSZ 16 779 #define ELF_NOTE_ABI_NAME "GNU\0" 782 #define ELF_NOTE_ABI_OS_LINUX 0 783 #define ELF_NOTE_ABI_OS_HURD 1 784 #define ELF_NOTE_ABI_OS_SOLARIS 2 787 #define ELF_NOTE_TYPE_NETBSD_TAG 1 789 #define ELF_NOTE_NETBSD_NAMESZ 7 790 #define ELF_NOTE_NETBSD_DESCSZ 4 792 #define ELF_NOTE_NETBSD_NAME "NetBSD\0\0" 796 #define ELF_NOTE_TYPE_CHECKSUM_TAG 2 797 #define ELF_NOTE_CHECKSUM_CRC32 1 798 #define ELF_NOTE_CHECKSUM_MD5 2 799 #define ELF_NOTE_CHECKSUM_SHA1 3 800 #define ELF_NOTE_CHECKSUM_SHA256 4 804 #define ELF_NOTE_TYPE_PAX_TAG 3 805 #define ELF_NOTE_PAX_MPROTECT 0x01 806 #define ELF_NOTE_PAX_NOMPROTECT 0x02 807 #define ELF_NOTE_PAX_GUARD 0x04 808 #define ELF_NOTE_PAX_NOGUARD 0x08 809 #define ELF_NOTE_PAX_ASLR 0x10 810 #define ELF_NOTE_PAX_NOASLR 0x20 811 #define ELF_NOTE_PAX_NAMESZ 4 812 #define ELF_NOTE_PAX_NAME "PaX\0" 813 #define ELF_NOTE_PAX_DESCSZ 4 838 #define ELF_NOTE_NETBSD_CORE_NAME "NetBSD-CORE" 840 #define ELF_NOTE_NETBSD_CORE_PROCINFO 1 842 #define NETBSD_ELFCORE_PROCINFO_VERSION 1 846 uint32_t cpi_version;
847 uint32_t cpi_cpisize;
849 uint32_t cpi_sigcode;
850 uint32_t cpi_sigpend[4];
851 uint32_t cpi_sigmask[4];
852 uint32_t cpi_sigignore[4];
853 uint32_t cpi_sigcatch[4];
870 #if defined(ELFSIZE) && (ELFSIZE == 32) 871 #define Elf_Ehdr Elf32_Ehdr 872 #define Elf_Phdr Elf32_Phdr 873 #define Elf_Shdr Elf32_Shdr 874 #define Elf_Sym Elf32_Sym 875 #define Elf_Rel Elf32_Rel 876 #define Elf_Rela Elf32_Rela 877 #define Elf_Dyn Elf32_Dyn 878 #define Elf_Word Elf32_Word 879 #define Elf_Sword Elf32_Sword 880 #define Elf_Addr Elf32_Addr 881 #define Elf_Off Elf32_Off 882 #define Elf_SOff Elf32_SOff 883 #define Elf_Nhdr Elf32_Nhdr 885 #define ELF_R_SYM ELF32_R_SYM 886 #define ELF_R_TYPE ELF32_R_TYPE 887 #define ELFCLASS ELFCLASS32 889 #define AuxInfo Aux32Info 890 #elif defined(ELFSIZE) && (ELFSIZE == 64) 891 #define Elf_Ehdr Elf64_Ehdr 892 #define Elf_Phdr Elf64_Phdr 893 #define Elf_Shdr Elf64_Shdr 894 #define Elf_Sym Elf64_Sym 895 #define Elf_Rel Elf64_Rel 896 #define Elf_Rela Elf64_Rela 897 #define Elf_Dyn Elf64_Dyn 898 #define Elf_Word Elf64_Word 899 #define Elf_Sword Elf64_Sword 900 #define Elf_Addr Elf64_Addr 901 #define Elf_Off Elf64_Off 902 #define Elf_SOff Elf64_SOff 903 #define Elf_Nhdr Elf64_Nhdr 905 #define ELF_R_SYM ELF64_R_SYM 906 #define ELF_R_TYPE ELF64_R_TYPE 907 #define ELFCLASS ELFCLASS64 909 #define AuxInfo Aux64Info 912 #define ELF32_ST_BIND(info) ELF_ST_BIND(info) 913 #define ELF32_ST_TYPE(info) ELF_ST_TYPE(info) 914 #define ELF32_ST_INFO(bind,type) ELF_ST_INFO(bind,type) 915 #define ELF32_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) 917 #define ELF64_ST_BIND(info) ELF_ST_BIND(info) 918 #define ELF64_ST_TYPE(info) ELF_ST_TYPE(info) 919 #define ELF64_ST_INFO(bind,type) ELF_ST_INFO(bind,type) 920 #define ELF64_ST_VISIBILITY(other) ELF_ST_VISIBILITY(other) 923 Elf32_Half si_boundto;
928 Elf64_Half si_boundto;
932 #define SYMINFO_FLG_DIRECT 0x0001 934 #define SYMINFO_FLG_PASSTHRU 0x0002 935 #define SYMINFO_FLG_COPY 0x0004 936 #define SYMINFO_FLG_LAZYLOAD 0x0008 938 #define SYMINFO_FLG_DIRECTBIND 0x0010 940 #define SYMINFO_FLG_NOEXTDIRECT 0x0020 942 #define SYMINFO_FLG_FILTER 0x0002 943 #define SYMINFO_FLG_AUXILIARY 0x0040 945 #define SYMINFO_BT_SELF 0xffff 946 #define SYMINFO_BT_PARENT 0xfffe 947 #define SYMINFO_BT_NONE 0xfffd 948 #define SYMINFO_BT_EXTERN 0xfffc 949 #define SYMINFO_BT_LOWRESERVE 0xff00 951 #define SYMINFO_NONE 0 952 #define SYMINFO_CURRENT 1 953 #define SYMINFO_NUM 2 958 #define VER_DEF_NONE 0 959 #define VER_DEF_CURRENT 1 964 #define VER_FLG_BASE 0x1 965 #define VER_FLG_WEAK 0x2 970 #define VER_NDX_LOCAL 0 971 #define VER_NDX_GLOBAL 1 976 #define VER_NEED_NONE 0 977 #define VER_NEED_CURRENT 1 982 #define VERSYM_HIDDEN 0x8000 983 #define VERSYM_VERSION 0x7fff 985 #define ELF_VER_CHR '@' 992 Elf32_Half vd_version;
1003 Elf32_Word vda_name;
1004 Elf32_Word vda_next;
1009 Elf32_Half vn_version;
1018 Elf32_Word vna_hash;
1019 Elf32_Half vna_flags;
1020 Elf32_Half vna_other;
1021 Elf32_Word vna_name;
1022 Elf32_Word vna_next;
1033 #define ELF_AUX_ENTRIES 14 1034 #define ELF32_NO_ADDR (~(Elf32_Addr)0) 1035 #define ELF32_LINK_ADDR ((Elf32_Addr)-2) 1036 #define ELF64_NO_ADDR (~(Elf64_Addr)0) 1037 #define ELF64_LINK_ADDR ((Elf64_Addr)-2) 1039 #if defined(ELFSIZE) && (ELFSIZE == 64) 1040 #define ELF_NO_ADDR ELF64_NO_ADDR 1041 #define ELF_LINK_ADDR ELF64_LINK_ADDR 1042 #elif defined(ELFSIZE) && (ELFSIZE == 32) 1043 #define ELF_NO_ADDR ELF32_NO_ADDR 1044 #define ELF_LINK_ADDR ELF32_LINK_ADDR 1047 #ifndef ELF32_EHDR_FLAGS_OK 1048 #define ELF32_EHDR_FLAGS_OK(eh) 1 1051 #ifndef ELF64_EHDR_FLAGS_OK 1052 #define ELF64_EHDR_FLAGS_OK(eh) 1 1055 #if defined(ELFSIZE) && (ELFSIZE == 64) 1056 #define ELF_EHDR_FLAGS_OK(eh) ELF64_EHDR_FLAGS_OK(eh) 1058 #define ELF_EHDR_FLAGS_OK(eh) ELF32_EHDR_FLAGS_OK(eh) 1061 #if defined(ELFSIZE) 1064 Elf_Addr arg_interp;
1065 Elf_Addr arg_phaddr;
1066 Elf_Addr arg_phentsize;
1072 #include "opt_execfmt.h" 1076 int exec_elf32_makecmds(
struct lwp *,
struct exec_package *);
1077 int elf32_copyargs(
struct lwp *,
struct exec_package *,
1078 struct ps_strings *,
char **,
void *);
1080 int coredump_elf32(
struct lwp *,
void *);
1081 int coredump_writenote_elf32(
struct proc *,
void *,
Elf32_Nhdr *,
1082 const char *,
void *);
1088 int exec_elf64_makecmds(
struct lwp *,
struct exec_package *);
1089 int elf64_copyargs(
struct lwp *,
struct exec_package *,
1090 struct ps_strings *,
char **,
void *);
1092 int coredump_elf64(
struct lwp *,
void *);
1093 int coredump_writenote_elf64(
struct proc *,
void *,
Elf64_Nhdr *,
1094 const char *,
void *);
Definition: exec_elf.h:708
Definition: exec_elf.h:624
Definition: exec_elf.h:112
Definition: exec_elf.h:396
Definition: exec_elf.h:473
Definition: exec_elf.h:1017
Definition: exec_elf.h:922
Definition: exec_elf.h:844
Definition: exec_elf.h:567
Definition: exec_elf.h:583
Definition: exec_elf.h:643
Definition: exec_elf.h:562
Definition: exec_elf.h:991
Definition: exec_elf.h:927
Definition: exec_elf.h:713
Definition: exec_elf.h:767
Definition: exec_elf.h:761
Provide printf() PRIxxx Constante Beyond Standards.
Definition: exec_elf.h:651
Definition: exec_elf.h:1026
Definition: exec_elf.h:632
Definition: exec_elf.h:609
Definition: exec_elf.h:597
Definition: exec_elf.h:578
Definition: exec_elf.h:354
Definition: exec_elf.h:482
Definition: exec_elf.h:343
Definition: exec_elf.h:1002
Definition: exec_elf.h:1008
Definition: exec_elf.h:129
Definition: exec_elf.h:409