Annotation of nono/host/elf.h, revision 1.1

1.1     ! root        1: // NetBSD の elf.h -> sys/exec_elf.h をベースに書き換えたもの
        !             2: /*     $NetBSD: exec_elf.h,v 1.161 2019/06/07 23:35:52 christos Exp $  */
        !             3: 
        !             4: /*-
        !             5:  * Copyright (c) 1994 The NetBSD Foundation, Inc.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * This code is derived from software contributed to The NetBSD Foundation
        !             9:  * by Christos Zoulas.
        !            10:  *
        !            11:  * Redistribution and use in source and binary forms, with or without
        !            12:  * modification, are permitted provided that the following conditions
        !            13:  * are met:
        !            14:  * 1. Redistributions of source code must retain the above copyright
        !            15:  *    notice, this list of conditions and the following disclaimer.
        !            16:  * 2. Redistributions in binary form must reproduce the above copyright
        !            17:  *    notice, this list of conditions and the following disclaimer in the
        !            18:  *    documentation and/or other materials provided with the distribution.
        !            19:  *
        !            20:  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
        !            21:  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
        !            22:  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
        !            23:  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
        !            24:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            25:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            26:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            27:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            28:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            29:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
        !            30:  * POSSIBILITY OF SUCH DAMAGE.
        !            31:  */
        !            32: 
        !            33: #ifndef _SYS_EXEC_ELF_H_
        !            34: #define _SYS_EXEC_ELF_H_
        !            35: 
        !            36: /*
        !            37:  * The current ELF ABI specification is available at:
        !            38:  *     http://www.sco.com/developers/gabi/
        !            39:  *
        !            40:  * Current header definitions are in:
        !            41:  *     http://www.sco.com/developers/gabi/latest/ch4.eheader.html
        !            42:  */
        !            43: 
        !            44: #if defined(_KERNEL) || defined(_STANDALONE)
        !            45: #include <sys/types.h>
        !            46: #else
        !            47: #include <inttypes.h>
        !            48: #include <stddef.h>
        !            49: #endif /* _KERNEL || _STANDALONE */
        !            50: 
        !            51: typedef uint8_t                Elf_Byte;
        !            52: 
        !            53: typedef uint32_t       Elf32_Addr;
        !            54: #define ELF32_FSZ_ADDR 4
        !            55: typedef uint32_t       Elf32_Off;
        !            56: typedef int32_t                Elf32_SOff;
        !            57: #define ELF32_FSZ_OFF  4
        !            58: typedef int32_t                Elf32_Sword;
        !            59: #define ELF32_FSZ_SWORD 4
        !            60: typedef uint32_t       Elf32_Word;
        !            61: #define ELF32_FSZ_WORD 4
        !            62: typedef uint16_t       Elf32_Half;
        !            63: #define ELF32_FSZ_HALF 2
        !            64: typedef uint64_t       Elf32_Lword;
        !            65: #define ELF32_FSZ_LWORD 8
        !            66: 
        !            67: typedef uint64_t       Elf64_Addr;
        !            68: #define ELF64_FSZ_ADDR 8
        !            69: typedef uint64_t       Elf64_Off;
        !            70: typedef int64_t                Elf64_SOff;
        !            71: #define ELF64_FSZ_OFF  8
        !            72: 
        !            73: typedef int32_t                Elf64_Sword;
        !            74: #define ELF64_FSZ_SWORD 4
        !            75: typedef uint32_t       Elf64_Word;
        !            76: #define ELF64_FSZ_WORD 4
        !            77: 
        !            78: typedef int64_t                Elf64_Sxword;
        !            79: #define ELF64_FSZ_SXWORD 8
        !            80: typedef uint64_t       Elf64_Xword;
        !            81: #define ELF64_FSZ_XWORD 8
        !            82: typedef uint64_t       Elf64_Lword;
        !            83: #define ELF64_FSZ_LWORD 8
        !            84: typedef uint16_t       Elf64_Half;
        !            85: #define ELF64_FSZ_HALF 2
        !            86: 
        !            87: /*
        !            88:  * ELF Header
        !            89:  */
        !            90: #define ELF_NIDENT     16
        !            91: 
        !            92: typedef struct {
        !            93:        unsigned char   e_ident[ELF_NIDENT];    /* Id bytes */
        !            94:        Elf32_Half      e_type;                 /* file type */
        !            95:        Elf32_Half      e_machine;              /* machine type */
        !            96:        Elf32_Word      e_version;              /* version number */
        !            97:        Elf32_Addr      e_entry;                /* entry point */
        !            98:        Elf32_Off       e_phoff;                /* Program hdr offset */
        !            99:        Elf32_Off       e_shoff;                /* Section hdr offset */
        !           100:        Elf32_Word      e_flags;                /* Processor flags */
        !           101:        Elf32_Half      e_ehsize;               /* sizeof ehdr */
        !           102:        Elf32_Half      e_phentsize;            /* Program header entry size */
        !           103:        Elf32_Half      e_phnum;                /* Number of program headers */
        !           104:        Elf32_Half      e_shentsize;            /* Section header entry size */
        !           105:        Elf32_Half      e_shnum;                /* Number of section headers */
        !           106:        Elf32_Half      e_shstrndx;             /* String table index */
        !           107: } Elf32_Ehdr;
        !           108: 
        !           109: typedef struct {
        !           110:        unsigned char   e_ident[ELF_NIDENT];    /* Id bytes */
        !           111:        Elf64_Half      e_type;                 /* file type */
        !           112:        Elf64_Half      e_machine;              /* machine type */
        !           113:        Elf64_Word      e_version;              /* version number */
        !           114:        Elf64_Addr      e_entry;                /* entry point */
        !           115:        Elf64_Off       e_phoff;                /* Program hdr offset */
        !           116:        Elf64_Off       e_shoff;                /* Section hdr offset */
        !           117:        Elf64_Word      e_flags;                /* Processor flags */
        !           118:        Elf64_Half      e_ehsize;               /* sizeof ehdr */
        !           119:        Elf64_Half      e_phentsize;            /* Program header entry size */
        !           120:        Elf64_Half      e_phnum;                /* Number of program headers */
        !           121:        Elf64_Half      e_shentsize;            /* Section header entry size */
        !           122:        Elf64_Half      e_shnum;                /* Number of section headers */
        !           123:        Elf64_Half      e_shstrndx;             /* String table index */
        !           124: } Elf64_Ehdr;
        !           125: 
        !           126: /* e_ident offsets */
        !           127: #define EI_MAG0                0       /* '\177' */
        !           128: #define EI_MAG1                1       /* 'E'    */
        !           129: #define EI_MAG2                2       /* 'L'    */
        !           130: #define EI_MAG3                3       /* 'F'    */
        !           131: #define EI_CLASS       4       /* File class */
        !           132: #define EI_DATA                5       /* Data encoding */
        !           133: #define EI_VERSION     6       /* File version */
        !           134: #define EI_OSABI       7       /* Operating system/ABI identification */
        !           135: #define EI_ABIVERSION  8       /* ABI version */
        !           136: #define EI_PAD         9       /* Start of padding bytes up to EI_NIDENT*/
        !           137: #define EI_NIDENT      16      /* First non-ident header byte */
        !           138: 
        !           139: /* e_ident[EI_MAG0,EI_MAG3] */
        !           140: #define ELFMAG0                0x7f
        !           141: #define ELFMAG1                'E'
        !           142: #define ELFMAG2                'L'
        !           143: #define ELFMAG3                'F'
        !           144: #define ELFMAG         "\177ELF"
        !           145: #define SELFMAG                4
        !           146: 
        !           147: /* e_ident[EI_CLASS] */
        !           148: #define ELFCLASSNONE   0       /* Invalid class */
        !           149: #define ELFCLASS32     1       /* 32-bit objects */
        !           150: #define ELFCLASS64     2       /* 64-bit objects */
        !           151: #define ELFCLASSNUM    3
        !           152: 
        !           153: /* e_ident[EI_DATA] */
        !           154: #define ELFDATANONE    0       /* Invalid data encoding */
        !           155: #define ELFDATA2LSB    1       /* 2's complement values, LSB first */
        !           156: #define ELFDATA2MSB    2       /* 2's complement values, MSB first */
        !           157: 
        !           158: /* e_ident[EI_VERSION] */
        !           159: #define EV_NONE                0       /* Invalid version */
        !           160: #define EV_CURRENT     1       /* Current version */
        !           161: #define EV_NUM         2
        !           162: 
        !           163: /* e_ident[EI_OSABI] */
        !           164: #define ELFOSABI_SYSV          0       /* UNIX System V ABI */
        !           165: #define ELFOSABI_HPUX          1       /* HP-UX operating system */
        !           166: #define ELFOSABI_NETBSD                2       /* NetBSD */
        !           167: #define ELFOSABI_LINUX         3       /* GNU/Linux */
        !           168: #define ELFOSABI_HURD          4       /* GNU/Hurd */
        !           169: #define ELFOSABI_86OPEN                5       /* 86Open */
        !           170: #define ELFOSABI_SOLARIS       6       /* Solaris */
        !           171: #define ELFOSABI_MONTEREY      7       /* Monterey */
        !           172: #define ELFOSABI_IRIX          8       /* IRIX */
        !           173: #define ELFOSABI_FREEBSD       9       /* FreeBSD */
        !           174: #define ELFOSABI_TRU64         10      /* TRU64 UNIX */
        !           175: #define ELFOSABI_MODESTO       11      /* Novell Modesto */
        !           176: #define ELFOSABI_OPENBSD       12      /* OpenBSD */
        !           177: #define ELFOSABI_OPENVMS       13      /* OpenVMS */
        !           178: #define ELFOSABI_NSK           14      /* HP Non-Stop Kernel */
        !           179: #define ELFOSABI_AROS          15      /* Amiga Research OS */
        !           180: /* Unofficial OSABIs follow */
        !           181: #define ELFOSABI_ARM           97      /* ARM */
        !           182: #define ELFOSABI_STANDALONE    255     /* Standalone (embedded) application */
        !           183: 
        !           184: #define ELFOSABI_NONE          ELFOSABI_SYSV
        !           185: #define ELFOSABI_AIX           ELFOSABI_MONTEREY
        !           186: 
        !           187: /* e_type */
        !           188: #define ET_NONE                0       /* No file type */
        !           189: #define ET_REL         1       /* Relocatable file */
        !           190: #define ET_EXEC                2       /* Executable file */
        !           191: #define ET_DYN         3       /* Shared object file */
        !           192: #define ET_CORE                4       /* Core file */
        !           193: #define ET_NUM         5
        !           194: 
        !           195: #define ET_LOOS                0xfe00  /* Operating system specific range */
        !           196: #define ET_HIOS                0xfeff
        !           197: #define ET_LOPROC      0xff00  /* Processor-specific range */
        !           198: #define ET_HIPROC      0xffff
        !           199: 
        !           200: /* e_machine */
        !           201: #define EM_NONE                0       /* No machine */
        !           202: #define EM_M32         1       /* AT&T WE 32100 */
        !           203: #define EM_SPARC       2       /* SPARC */
        !           204: #define EM_386         3       /* Intel 80386 */
        !           205: #define EM_68K         4       /* Motorola 68000 */
        !           206: #define EM_88K         5       /* Motorola 88000 */
        !           207: #define EM_486         6       /* Intel 80486 [old] */
        !           208: #define EM_IAMCU       6       /* Intel MCU. */
        !           209: #define EM_860         7       /* Intel 80860 */
        !           210: #define EM_MIPS                8       /* MIPS I Architecture */
        !           211: #define EM_S370                9       /* Amdahl UTS on System/370 */
        !           212: #define EM_MIPS_RS3_LE 10      /* MIPS RS3000 Little-endian */
        !           213:                        /* 11-14 - Reserved */
        !           214: #define EM_RS6000      11      /* IBM RS/6000 XXX reserved */
        !           215: #define EM_PARISC      15      /* Hewlett-Packard PA-RISC */
        !           216: #define EM_NCUBE       16      /* NCube XXX reserved */
        !           217: #define EM_VPP500      17      /* Fujitsu VPP500 */
        !           218: #define EM_SPARC32PLUS 18      /* Enhanced instruction set SPARC */
        !           219: #define EM_960         19      /* Intel 80960 */
        !           220: #define EM_PPC         20      /* PowerPC */
        !           221: #define EM_PPC64       21      /* 64-bit PowerPC */
        !           222:                        /* 22-35 - Reserved */
        !           223: #define EM_S390                22      /* System/390 XXX reserved */
        !           224: #define EM_V800                36      /* NEC V800 */
        !           225: #define EM_FR20                37      /* Fujitsu FR20 */
        !           226: #define EM_RH32                38      /* TRW RH-32 */
        !           227: #define EM_RCE         39      /* Motorola RCE */
        !           228: #define EM_ARM         40      /* Advanced RISC Machines ARM */
        !           229: #define EM_ALPHA       41      /* DIGITAL Alpha */
        !           230: #define EM_SH          42      /* Hitachi Super-H */
        !           231: #define EM_SPARCV9     43      /* SPARC Version 9 */
        !           232: #define EM_TRICORE     44      /* Siemens Tricore */
        !           233: #define EM_ARC         45      /* Argonaut RISC Core */
        !           234: #define EM_H8_300      46      /* Hitachi H8/300 */
        !           235: #define EM_H8_300H     47      /* Hitachi H8/300H */
        !           236: #define EM_H8S         48      /* Hitachi H8S */
        !           237: #define EM_H8_500      49      /* Hitachi H8/500 */
        !           238: #define EM_IA_64       50      /* Intel Merced Processor */
        !           239: #define EM_MIPS_X      51      /* Stanford MIPS-X */
        !           240: #define EM_COLDFIRE    52      /* Motorola Coldfire */
        !           241: #define EM_68HC12      53      /* Motorola MC68HC12 */
        !           242: #define EM_MMA         54      /* Fujitsu MMA Multimedia Accelerator */
        !           243: #define EM_PCP         55      /* Siemens PCP */
        !           244: #define EM_NCPU                56      /* Sony nCPU embedded RISC processor */
        !           245: #define EM_NDR1                57      /* Denso NDR1 microprocessor */
        !           246: #define EM_STARCORE    58      /* Motorola Star*Core processor */
        !           247: #define EM_ME16                59      /* Toyota ME16 processor */
        !           248: #define EM_ST100       60      /* STMicroelectronics ST100 processor */
        !           249: #define EM_TINYJ       61      /* Advanced Logic Corp. TinyJ embedded family processor */
        !           250: #define EM_X86_64      62      /* AMD x86-64 architecture */
        !           251: #define EM_PDSP                63      /* Sony DSP Processor */
        !           252: #define EM_PDP10       64      /* Digital Equipment Corp. PDP-10 */
        !           253: #define EM_PDP11       65      /* Digital Equipment Corp. PDP-11 */
        !           254: #define EM_FX66                66      /* Siemens FX66 microcontroller */
        !           255: #define EM_ST9PLUS     67      /* STMicroelectronics ST9+ 8/16 bit microcontroller */
        !           256: #define EM_ST7         68      /* STMicroelectronics ST7 8-bit microcontroller */
        !           257: #define EM_68HC16      69      /* Motorola MC68HC16 Microcontroller */
        !           258: #define EM_68HC11      70      /* Motorola MC68HC11 Microcontroller */
        !           259: #define EM_68HC08      71      /* Motorola MC68HC08 Microcontroller */
        !           260: #define EM_68HC05      72      /* Motorola MC68HC05 Microcontroller */
        !           261: #define EM_SVX         73      /* Silicon Graphics SVx */
        !           262: #define EM_ST19                74      /* STMicroelectronics ST19 8-bit CPU */
        !           263: #define EM_VAX         75      /* Digital VAX */
        !           264: #define EM_CRIS                76      /* Axis Communications 32-bit embedded processor */
        !           265: #define EM_JAVELIN     77      /* Infineon Technologies 32-bit embedded CPU */
        !           266: #define EM_FIREPATH    78      /* Element 14 64-bit DSP processor */
        !           267: #define EM_ZSP         79      /* LSI Logic's 16-bit DSP processor */
        !           268: #define EM_MMIX                80      /* Donald Knuth's educational 64-bit processor */
        !           269: #define EM_HUANY       81      /* Harvard's machine-independent format */
        !           270: #define EM_PRISM       82      /* SiTera Prism */
        !           271: #define EM_AVR         83      /* Atmel AVR 8-bit microcontroller */
        !           272: #define EM_FR30                84      /* Fujitsu FR30 */
        !           273: #define EM_D10V                85      /* Mitsubishi D10V */
        !           274: #define EM_D30V                86      /* Mitsubishi D30V */
        !           275: #define EM_V850                87      /* NEC v850 */
        !           276: #define EM_M32R                88      /* Mitsubishi M32R */
        !           277: #define EM_MN10300     89      /* Matsushita MN10300 */
        !           278: #define EM_MN10200     90      /* Matsushita MN10200 */
        !           279: #define EM_PJ          91      /* picoJava */
        !           280: #define EM_OR1K                92      /* OpenRISC 32-bit embedded processor */
        !           281: #define EM_OPENRISC    EM_OR1K
        !           282: #define EM_ARC_A5      93      /* ARC Cores Tangent-A5 */
        !           283: #define EM_XTENSA      94      /* Tensilica Xtensa Architecture */
        !           284: #define EM_VIDEOCORE   95      /* Alphamosaic VideoCore processor */
        !           285: #define EM_TMM_GPP     96      /* Thompson Multimedia General Purpose Processor */
        !           286: #define EM_NS32K       97      /* National Semiconductor 32000 series */
        !           287: #define EM_TPC         98      /* Tenor Network TPC processor */
        !           288: #define EM_SNP1K       99      /* Trebia SNP 1000 processor */
        !           289: #define EM_ST200       100     /* STMicroelectronics ST200 microcontroller */
        !           290: #define EM_IP2K                101     /* Ubicom IP2xxx microcontroller family */
        !           291: #define EM_MAX         102     /* MAX processor */
        !           292: #define EM_CR          103     /* National Semiconductor CompactRISC micorprocessor */
        !           293: #define EM_F2MC16      104     /* Fujitsu F2MC16 */
        !           294: #define EM_MSP430      105     /* Texas Instruments MSP430 */
        !           295: #define EM_BLACKFIN    106     /* Analog Devices Blackfin DSP */
        !           296: #define EM_SE_C33      107     /* Seiko Epson S1C33 family */
        !           297: #define EM_SEP         108     /* Sharp embedded microprocessor */
        !           298: #define EM_ARCA                109     /* Arca RISC microprocessor */
        !           299: #define EM_UNICORE     110     /* UNICORE from PKU-Unity Ltd. and MPRC Peking University */
        !           300: #define EM_ALTERA_NIOS2        113     /* Altera Nios II soft-core processor */
        !           301: #define EM_AARCH64     183     /* AArch64 64-bit ARM microprocessor */
        !           302: #define EM_AVR32       185     /* Atmel Corporation 32-bit microprocessor family*/
        !           303: #define EM_TILE64      187     /* Tilera TILE64 multicore architecture family */
        !           304: #define EM_TILEPRO     188     /* Tilera TILEPro multicore architecture family */
        !           305: #define EM_MICROBLAZE  189     /* Xilinx MicroBlaze 32-bit RISC soft processor core */
        !           306: #define EM_TILEGX      192     /* Tilera TILE-GX multicore architecture family */
        !           307: #define EM_Z80         220     /* Zilog Z80 */
        !           308: #define EM_RISCV       243     /* RISC-V */
        !           309: 
        !           310: /* Unofficial machine types follow */
        !           311: #define EM_ALPHA_EXP   36902   /* used by NetBSD/alpha; obsolete */
        !           312: #define EM_NUM         36903
        !           313: 
        !           314: /*
        !           315:  * Program Header
        !           316:  */
        !           317: typedef struct {
        !           318:        Elf32_Word      p_type;         /* entry type */
        !           319:        Elf32_Off       p_offset;       /* offset */
        !           320:        Elf32_Addr      p_vaddr;        /* virtual address */
        !           321:        Elf32_Addr      p_paddr;        /* physical address */
        !           322:        Elf32_Word      p_filesz;       /* file size */
        !           323:        Elf32_Word      p_memsz;        /* memory size */
        !           324:        Elf32_Word      p_flags;        /* flags */
        !           325:        Elf32_Word      p_align;        /* memory & file alignment */
        !           326: } Elf32_Phdr;
        !           327: 
        !           328: typedef struct {
        !           329:        Elf64_Word      p_type;         /* entry type */
        !           330:        Elf64_Word      p_flags;        /* flags */
        !           331:        Elf64_Off       p_offset;       /* offset */
        !           332:        Elf64_Addr      p_vaddr;        /* virtual address */
        !           333:        Elf64_Addr      p_paddr;        /* physical address */
        !           334:        Elf64_Xword     p_filesz;       /* file size */
        !           335:        Elf64_Xword     p_memsz;        /* memory size */
        !           336:        Elf64_Xword     p_align;        /* memory & file alignment */
        !           337: } Elf64_Phdr;
        !           338: 
        !           339: /* p_type */
        !           340: #define PT_NULL                0               /* Program header table entry unused */
        !           341: #define PT_LOAD                1               /* Loadable program segment */
        !           342: #define PT_DYNAMIC     2               /* Dynamic linking information */
        !           343: #define PT_INTERP      3               /* Program interpreter */
        !           344: #define PT_NOTE                4               /* Auxiliary information */
        !           345: #define PT_SHLIB       5               /* Reserved, unspecified semantics */
        !           346: #define PT_PHDR                6               /* Entry for header table itself */
        !           347: #define PT_TLS         7               /* TLS initialisation image */
        !           348: #define PT_NUM         8
        !           349: 
        !           350: #define PT_LOOS                0x60000000      /* OS-specific range */
        !           351: 
        !           352: /* GNU-specific */
        !           353: #define PT_GNU_EH_FRAME 0x6474e550     /* EH frame segment */
        !           354: #define PT_GNU_STACK   0x6474e551      /* Indicate executable stack */
        !           355: #define PT_GNU_RELRO   0x6474e552      /* Make read-only after relocation */
        !           356: 
        !           357: #define PT_HIOS                0x6fffffff
        !           358: #define PT_LOPROC      0x70000000      /* Processor-specific range */
        !           359: #define PT_HIPROC      0x7fffffff
        !           360: 
        !           361: #define PT_MIPS_REGINFO 0x70000000
        !           362: #define PT_MIPS_ABIFLAGS 0x70000003
        !           363: 
        !           364: /* p_flags */
        !           365: #define PF_R           0x4             /* Segment is readable */
        !           366: #define PF_W           0x2             /* Segment is writable */
        !           367: #define PF_X           0x1             /* Segment is executable */
        !           368: 
        !           369: #define PF_MASKOS      0x0ff00000      /* Operating system specific values */
        !           370: #define PF_MASKPROC    0xf0000000      /* Processor-specific values */
        !           371: 
        !           372: /* Extended program header index. */
        !           373: #define PN_XNUM                0xffff
        !           374: 
        !           375: /*
        !           376:  * Section Headers
        !           377:  */
        !           378: typedef struct {
        !           379:        Elf32_Word      sh_name;        /* section name (.shstrtab index) */
        !           380:        Elf32_Word      sh_type;        /* section type */
        !           381:        Elf32_Word      sh_flags;       /* section flags */
        !           382:        Elf32_Addr      sh_addr;        /* virtual address */
        !           383:        Elf32_Off       sh_offset;      /* file offset */
        !           384:        Elf32_Word      sh_size;        /* section size */
        !           385:        Elf32_Word      sh_link;        /* link to another */
        !           386:        Elf32_Word      sh_info;        /* misc info */
        !           387:        Elf32_Word      sh_addralign;   /* memory alignment */
        !           388:        Elf32_Word      sh_entsize;     /* table entry size */
        !           389: } Elf32_Shdr;
        !           390: 
        !           391: typedef struct {
        !           392:        Elf64_Word      sh_name;        /* section name (.shstrtab index) */
        !           393:        Elf64_Word      sh_type;        /* section type */
        !           394:        Elf64_Xword     sh_flags;       /* section flags */
        !           395:        Elf64_Addr      sh_addr;        /* virtual address */
        !           396:        Elf64_Off       sh_offset;      /* file offset */
        !           397:        Elf64_Xword     sh_size;        /* section size */
        !           398:        Elf64_Word      sh_link;        /* link to another */
        !           399:        Elf64_Word      sh_info;        /* misc info */
        !           400:        Elf64_Xword     sh_addralign;   /* memory alignment */
        !           401:        Elf64_Xword     sh_entsize;     /* table entry size */
        !           402: } Elf64_Shdr;
        !           403: 
        !           404: /* sh_type */
        !           405: #define SHT_NULL             0         /* Section header table entry unused */
        !           406: #define SHT_PROGBITS         1         /* Program information */
        !           407: #define SHT_SYMTAB           2         /* Symbol table */
        !           408: #define SHT_STRTAB           3         /* String table */
        !           409: #define SHT_RELA             4         /* Relocation information w/ addend */
        !           410: #define SHT_HASH             5         /* Symbol hash table */
        !           411: #define SHT_DYNAMIC          6         /* Dynamic linking information */
        !           412: #define SHT_NOTE             7         /* Auxiliary information */
        !           413: #define SHT_NOBITS           8         /* No space allocated in file image */
        !           414: #define SHT_REL                      9         /* Relocation information w/o addend */
        !           415: #define SHT_SHLIB           10         /* Reserved, unspecified semantics */
        !           416: #define SHT_DYNSYM          11         /* Symbol table for dynamic linker */
        !           417: #define SHT_INIT_ARRAY      14         /* Initialization function pointers */
        !           418: #define SHT_FINI_ARRAY      15         /* Termination function pointers */
        !           419: #define SHT_PREINIT_ARRAY    16                /* Pre-initialization function ptrs */
        !           420: #define SHT_GROUP           17         /* Section group */
        !           421: #define SHT_SYMTAB_SHNDX     18                /* Section indexes (see SHN_XINDEX) */
        !           422: #define SHT_NUM                     19
        !           423: 
        !           424: #define SHT_LOOS            0x60000000 /* Operating system specific range */
        !           425: #define SHT_GNU_INCREMENTAL_INPUTS 0x6fff4700   /* GNU incremental build data */
        !           426: #define        SHT_LOSUNW           0x6ffffff4
        !           427: #define        SHT_SUNW_dof         0x6ffffff4
        !           428: #define        SHT_GNU_ATTRIBUTES   0x6ffffff5 /* GNU object attributes */
        !           429: #define        SHT_SUNW_cap         0x6ffffff5
        !           430: #define        SHT_SUNW_SIGNATURE   0x6ffffff6
        !           431: #define SHT_GNU_HASH        0x6ffffff6 /* GNU style symbol hash table */
        !           432: #define SHT_GNU_LIBLIST             0x6ffffff7 /* GNU list of prelink dependencies */
        !           433: #define SHT_SUNW_move       0x6ffffffa
        !           434: #define        SHT_SUNW_COMDAT      0x6ffffffb
        !           435: #define SHT_SUNW_syminfo     0x6ffffffc
        !           436: #define SHT_SUNW_verdef             0x6ffffffd /* Versions defined by file */
        !           437: #define SHT_GNU_verdef      SHT_SUNW_verdef
        !           438: #define SHT_SUNW_verneed     0x6ffffffe /* Versions needed by file */
        !           439: #define SHT_GNU_verneed             SHT_SUNW_verneed
        !           440: #define SHT_SUNW_versym             0x6fffffff /* Symbol versions */
        !           441: #define SHT_GNU_versym      SHT_SUNW_versym
        !           442: #define        SHT_HISUNW           0x6fffffff
        !           443: #define SHT_HIOS            0x6fffffff
        !           444: #define SHT_LOPROC          0x70000000 /* Processor-specific range */
        !           445: #define SHT_AMD64_UNWIND     0x70000001 /* unwind information */
        !           446: #define SHT_ARM_EXIDX       0x70000001 /* exception index table */
        !           447: #define SHT_ARM_PREEMPTMAP   0x70000002 /* BPABI DLL dynamic linking 
        !           448:                                         * pre-emption map */
        !           449: #define SHT_ARM_ATTRIBUTES   0x70000003 /* Object file compatibility 
        !           450:                                         * attributes */
        !           451: #define SHT_ARM_DEBUGOVERLAY 0x70000004 /* See DBGOVL for details */
        !           452: #define SHT_ARM_OVERLAYSECTION 0x70000005
        !           453: #define        SHT_MIPS_REGINFO     0x70000006
        !           454: #define        SHT_MIPS_OPTIONS     0x7000000d
        !           455: #define        SHT_MIPS_DWARF       0x7000001e /* MIPS gcc uses MIPS_DWARF */
        !           456: #define SHT_HIPROC          0x7fffffff
        !           457: #define SHT_LOUSER          0x80000000 /* Application-specific range */
        !           458: #define SHT_HIUSER          0xffffffff
        !           459: 
        !           460: /* sh_flags */
        !           461: #define SHF_WRITE           0x00000001 /* Contains writable data */
        !           462: #define SHF_ALLOC           0x00000002 /* Occupies memory */
        !           463: #define SHF_EXECINSTR       0x00000004 /* Contains executable insns */
        !           464: #define SHF_MERGE           0x00000010 /* Might be merged */
        !           465: #define SHF_STRINGS         0x00000020 /* Contains nul terminated strings */
        !           466: #define SHF_INFO_LINK       0x00000040 /* "sh_info" contains SHT index */
        !           467: #define SHF_LINK_ORDER      0x00000080 /* Preserve order after combining */
        !           468: #define SHF_OS_NONCONFORMING 0x00000100 /* OS specific handling required */
        !           469: #define SHF_GROUP           0x00000200 /* Is member of a group */
        !           470: #define SHF_TLS                     0x00000400 /* Holds thread-local data */
        !           471: #define SHF_MASKOS          0x0ff00000 /* Operating system specific values */
        !           472: #define SHF_MASKPROC        0xf0000000 /* Processor-specific values */
        !           473: #define SHF_ORDERED         0x40000000 /* Ordering requirement (Solaris) */
        !           474: #define SHF_EXCLUDE         0x80000000 /* Excluded unless unles ref/alloc
        !           475:                                           (Solaris).*/
        !           476: /*
        !           477:  * Symbol Table
        !           478:  */
        !           479: typedef struct {
        !           480:        Elf32_Word      st_name;        /* Symbol name (.strtab index) */
        !           481:        Elf32_Word      st_value;       /* value of symbol */
        !           482:        Elf32_Word      st_size;        /* size of symbol */
        !           483:        Elf_Byte        st_info;        /* type / binding attrs */
        !           484:        Elf_Byte        st_other;       /* unused */
        !           485:        Elf32_Half      st_shndx;       /* section index of symbol */
        !           486: } Elf32_Sym;
        !           487: 
        !           488: typedef struct {
        !           489:        Elf64_Word      st_name;        /* Symbol name (.strtab index) */
        !           490:        Elf_Byte        st_info;        /* type / binding attrs */
        !           491:        Elf_Byte        st_other;       /* unused */
        !           492:        Elf64_Half      st_shndx;       /* section index of symbol */
        !           493:        Elf64_Addr      st_value;       /* value of symbol */
        !           494:        Elf64_Xword     st_size;        /* size of symbol */
        !           495: } Elf64_Sym;
        !           496: 
        !           497: /* Symbol Table index of the undefined symbol */
        !           498: #define ELF_SYM_UNDEFINED      0
        !           499: 
        !           500: #define STN_UNDEF              0       /* undefined index */
        !           501: 
        !           502: /* st_info: Symbol Bindings */
        !           503: #define STB_LOCAL              0       /* local symbol */
        !           504: #define STB_GLOBAL             1       /* global symbol */
        !           505: #define STB_WEAK               2       /* weakly defined global symbol */
        !           506: #define STB_NUM                        3
        !           507: 
        !           508: #define STB_LOOS               10      /* Operating system specific range */
        !           509: #define STB_HIOS               12
        !           510: #define STB_LOPROC             13      /* Processor-specific range */
        !           511: #define STB_HIPROC             15
        !           512: 
        !           513: /* st_info: Symbol Types */
        !           514: #define STT_NOTYPE             0       /* Type not specified */
        !           515: #define STT_OBJECT             1       /* Associated with a data object */
        !           516: #define STT_FUNC               2       /* Associated with a function */
        !           517: #define STT_SECTION            3       /* Associated with a section */
        !           518: #define STT_FILE               4       /* Associated with a file name */
        !           519: #define STT_COMMON             5       /* Uninitialised common block */
        !           520: #define STT_TLS                        6       /* Thread local data object */
        !           521: #define STT_NUM                        7
        !           522: 
        !           523: #define STT_LOOS               10      /* Operating system specific range */
        !           524: #define STT_GNU_IFUNC          10      /* GNU extension: indirect function */
        !           525: #define STT_HIOS               12
        !           526: #define STT_LOPROC             13      /* Processor-specific range */
        !           527: #define STT_HIPROC             15
        !           528: 
        !           529: /* st_other: Visibility Types */
        !           530: #define STV_DEFAULT            0       /* use binding type */
        !           531: #define STV_INTERNAL           1       /* not referenced from outside */
        !           532: #define STV_HIDDEN             2       /* not visible, may be used via ptr */
        !           533: #define STV_PROTECTED          3       /* visible, not preemptible */
        !           534: #define STV_EXPORTED           4
        !           535: #define STV_SINGLETON          5
        !           536: #define STV_ELIMINATE          6
        !           537: 
        !           538: /* st_info/st_other utility macros */
        !           539: #define ELF_ST_BIND(info)              ((uint32_t)(info) >> 4)
        !           540: #define ELF_ST_TYPE(info)              ((uint32_t)(info) & 0xf)
        !           541: #define ELF_ST_INFO(bind,type)         ((Elf_Byte)(((bind) << 4) | \
        !           542:                                         ((type) & 0xf)))
        !           543: #define ELF_ST_VISIBILITY(other)       ((uint32_t)(other) & 3)
        !           544: 
        !           545: /*
        !           546:  * Special section indexes
        !           547:  */
        !           548: #define SHN_UNDEF      0               /* Undefined section */
        !           549: 
        !           550: #define SHN_LORESERVE  0xff00          /* Reserved range */
        !           551: #define SHN_ABS                0xfff1          /*  Absolute symbols */
        !           552: #define SHN_COMMON     0xfff2          /*  Common symbols */
        !           553: #define SHN_XINDEX     0xffff          /* Escape -- index stored elsewhere */
        !           554: #define SHN_HIRESERVE  0xffff
        !           555: 
        !           556: #define SHN_LOPROC     0xff00          /* Processor-specific range */
        !           557: #define SHN_HIPROC     0xff1f
        !           558: #define SHN_LOOS       0xff20          /* Operating system specific range */
        !           559: #define SHN_HIOS       0xff3f
        !           560: 
        !           561: #define SHN_MIPS_ACOMMON 0xff00
        !           562: #define SHN_MIPS_TEXT  0xff01
        !           563: #define SHN_MIPS_DATA  0xff02
        !           564: #define SHN_MIPS_SCOMMON 0xff03
        !           565: 
        !           566: /*
        !           567:  * Relocation Entries
        !           568:  */
        !           569: typedef struct {
        !           570:        Elf32_Word      r_offset;       /* where to do it */
        !           571:        Elf32_Word      r_info;         /* index & type of relocation */
        !           572: } Elf32_Rel;
        !           573: 
        !           574: typedef struct {
        !           575:        Elf32_Word      r_offset;       /* where to do it */
        !           576:        Elf32_Word      r_info;         /* index & type of relocation */
        !           577:        Elf32_Sword     r_addend;       /* adjustment value */
        !           578: } Elf32_Rela;
        !           579: 
        !           580: /* r_info utility macros */
        !           581: #define ELF32_R_SYM(info)      ((info) >> 8)
        !           582: #define ELF32_R_TYPE(info)     ((info) & 0xff)
        !           583: #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
        !           584: 
        !           585: typedef struct {
        !           586:        Elf64_Addr      r_offset;       /* where to do it */
        !           587:        Elf64_Xword     r_info;         /* index & type of relocation */
        !           588: } Elf64_Rel;
        !           589: 
        !           590: typedef struct {
        !           591:        Elf64_Addr      r_offset;       /* where to do it */
        !           592:        Elf64_Xword     r_info;         /* index & type of relocation */
        !           593:        Elf64_Sxword    r_addend;       /* adjustment value */
        !           594: } Elf64_Rela;
        !           595: 
        !           596: /* r_info utility macros */
        !           597: #define ELF64_R_SYM(info)      ((info) >> 32)
        !           598: #define ELF64_R_TYPE(info)     ((info) & 0xffffffff)
        !           599: #define ELF64_R_INFO(sym,type) (((sym) << 32) + (type))
        !           600: 
        !           601: /*
        !           602:  * Move entries
        !           603:  */
        !           604: typedef struct {
        !           605:        Elf32_Lword     m_value;        /* symbol value */
        !           606:        Elf32_Word      m_info;         /* size + index */
        !           607:        Elf32_Word      m_poffset;      /* symbol offset */
        !           608:        Elf32_Half      m_repeat;       /* repeat count */
        !           609:        Elf32_Half      m_stride;       /* stride info */
        !           610: } Elf32_Move;
        !           611: 
        !           612: #define ELF32_M_SYM(info)      ((info) >> 8)
        !           613: #define ELF32_M_SIZE(info)     ((info) & 0xff)
        !           614: #define ELF32_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size))
        !           615: 
        !           616: typedef struct {
        !           617:        Elf64_Lword     m_value;        /* symbol value */
        !           618:        Elf64_Xword     m_info;         /* size + index */
        !           619:        Elf64_Xword     m_poffset;      /* symbol offset */
        !           620:        Elf64_Word      m_repeat;       /* repeat count */
        !           621:        Elf64_Word      m_stride;       /* stride info */
        !           622: } Elf64_Move;
        !           623: 
        !           624: #define ELF64_M_SYM(info)      ((info) >> 8)
        !           625: #define ELF64_M_SIZE(info)     ((info) & 0xff)
        !           626: #define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size))
        !           627: 
        !           628: /*
        !           629:  * Hardware/software capabilities entry
        !           630:  */
        !           631: typedef struct {
        !           632:        Elf32_Word              c_tag;  /* entry tag value */
        !           633:        union {
        !           634:                Elf32_Addr      c_ptr;
        !           635:                Elf32_Word      c_val;
        !           636:        } c_un;
        !           637: } Elf32_Cap;
        !           638: 
        !           639: typedef struct {
        !           640:        Elf64_Xword             c_tag;  /* entry tag value */
        !           641:        union {
        !           642:                Elf64_Addr      c_ptr;
        !           643:                Elf64_Xword     c_val;
        !           644:        } c_un;
        !           645: } Elf64_Cap;
        !           646: 
        !           647: /*
        !           648:  * Dynamic Section structure array
        !           649:  */
        !           650: typedef struct {
        !           651:        Elf32_Word              d_tag;  /* entry tag value */
        !           652:        union {
        !           653:                Elf32_Addr      d_ptr;
        !           654:                Elf32_Word      d_val;
        !           655:        } d_un;
        !           656: } Elf32_Dyn;
        !           657: 
        !           658: typedef struct {
        !           659:        Elf64_Xword             d_tag;  /* entry tag value */
        !           660:        union {
        !           661:                Elf64_Addr      d_ptr;
        !           662:                Elf64_Xword     d_val;
        !           663:        } d_un;
        !           664: } Elf64_Dyn;
        !           665: 
        !           666: /* d_tag */
        !           667: #define DT_NULL                0       /* Marks end of dynamic array */
        !           668: #define DT_NEEDED      1       /* Name of needed library (DT_STRTAB offset) */
        !           669: #define DT_PLTRELSZ    2       /* Size, in bytes, of relocations in PLT */
        !           670: #define DT_PLTGOT      3       /* Address of PLT and/or GOT */
        !           671: #define DT_HASH                4       /* Address of symbol hash table */
        !           672: #define DT_STRTAB      5       /* Address of string table */
        !           673: #define DT_SYMTAB      6       /* Address of symbol table */
        !           674: #define DT_RELA                7       /* Address of Rela relocation table */
        !           675: #define DT_RELASZ      8       /* Size, in bytes, of DT_RELA table */
        !           676: #define DT_RELAENT     9       /* Size, in bytes, of one DT_RELA entry */
        !           677: #define DT_STRSZ       10      /* Size, in bytes, of DT_STRTAB table */
        !           678: #define DT_SYMENT      11      /* Size, in bytes, of one DT_SYMTAB entry */
        !           679: #define DT_INIT                12      /* Address of initialization function */
        !           680: #define DT_FINI                13      /* Address of termination function */
        !           681: #define DT_SONAME      14      /* Shared object name (DT_STRTAB offset) */
        !           682: #define DT_RPATH       15      /* Library search path (DT_STRTAB offset) */
        !           683: #define DT_SYMBOLIC    16      /* Start symbol search within local object */
        !           684: #define DT_REL         17      /* Address of Rel relocation table */
        !           685: #define DT_RELSZ       18      /* Size, in bytes, of DT_REL table */
        !           686: #define DT_RELENT      19      /* Size, in bytes, of one DT_REL entry */
        !           687: #define DT_PLTREL      20      /* Type of PLT relocation entries */
        !           688: #define DT_DEBUG       21      /* Used for debugging; unspecified */
        !           689: #define DT_TEXTREL     22      /* Relocations might modify non-writable seg */
        !           690: #define DT_JMPREL      23      /* Address of relocations associated with PLT */
        !           691: #define DT_BIND_NOW    24      /* Process all relocations at load-time */
        !           692: #define DT_INIT_ARRAY  25      /* Address of initialization function array */
        !           693: #define DT_FINI_ARRAY  26      /* Size, in bytes, of DT_INIT_ARRAY array */
        !           694: #define DT_INIT_ARRAYSZ 27     /* Address of termination function array */
        !           695: #define DT_FINI_ARRAYSZ 28     /* Size, in bytes, of DT_FINI_ARRAY array*/
        !           696: #define DT_RUNPATH     29      /* overrides DT_RPATH */
        !           697: #define DT_FLAGS       30      /* Encodes ORIGIN, SYMBOLIC, TEXTREL, BIND_NOW, STATIC_TLS */
        !           698: #define DT_ENCODING    31      /* ??? */
        !           699: #define DT_PREINIT_ARRAY 32    /* Address of pre-init function array */
        !           700: #define DT_PREINIT_ARRAYSZ 33  /* Size, in bytes, of DT_PREINIT_ARRAY array */
        !           701: #define DT_NUM         34
        !           702: 
        !           703: #define DT_LOOS                0x60000000      /* Operating system specific range */
        !           704: #define DT_VERSYM      0x6ffffff0      /* Symbol versions */
        !           705: #define DT_FLAGS_1     0x6ffffffb      /* ELF dynamic flags */
        !           706: #define DT_VERDEF      0x6ffffffc      /* Versions defined by file */
        !           707: #define DT_VERDEFNUM   0x6ffffffd      /* Number of versions defined by file */
        !           708: #define DT_VERNEED     0x6ffffffe      /* Versions needed by file */
        !           709: #define DT_VERNEEDNUM  0x6fffffff      /* Number of versions needed by file */
        !           710: #define DT_HIOS                0x6fffffff
        !           711: #define DT_LOPROC      0x70000000      /* Processor-specific range */
        !           712: #define DT_HIPROC      0x7fffffff
        !           713: 
        !           714: /* Flag values for DT_FLAGS */
        !           715: #define DF_ORIGIN      0x00000001      /* uses $ORIGIN */
        !           716: #define DF_SYMBOLIC    0x00000002      /* */
        !           717: #define DF_TEXTREL     0x00000004      /* */
        !           718: #define DF_BIND_NOW    0x00000008      /* */
        !           719: #define DF_STATIC_TLS  0x00000010      /* */
        !           720: 
        !           721: /* Flag values for DT_FLAGS_1 */
        !           722: #define        DF_1_NOW        0x00000001      /* Same as DF_BIND_NOW */
        !           723: #define        DF_1_GLOBAL     0x00000002      /* Unused */
        !           724: #define        DF_1_GROUP      0x00000004      /* Is member of group */
        !           725: #define        DF_1_NODELETE   0x00000008      /* Cannot be deleted from process */
        !           726: #define        DF_1_LOADFLTR   0x00000010      /* Immediate loading of filters */
        !           727: #define        DF_1_INITFIRST  0x00000020      /* init/fini takes priority */
        !           728: #define        DF_1_NOOPEN     0x00000040      /* Do not allow loading on dlopen() */
        !           729: #define        DF_1_ORIGIN     0x00000080      /* Require $ORIGIN processing */
        !           730: #define        DF_1_DIRECT     0x00000100      /* Enable direct bindings */
        !           731: #define        DF_1_INTERPOSE  0x00000400      /* Is an interposer */
        !           732: #define        DF_1_NODEFLIB   0x00000800      /* Ignore default library search path */
        !           733: #define        DF_1_NODUMP     0x00001000      /* Cannot be dumped with dldump(3C) */
        !           734: #define        DF_1_CONFALT    0x00002000      /* Configuration alternative */
        !           735: #define        DF_1_ENDFILTEE  0x00004000      /* Filtee ends filter's search */
        !           736: #define        DF_1_DISPRELDNE 0x00008000      /* Did displacement relocation */
        !           737: #define        DF_1_DISPRELPND 0x00010000      /* Pending displacement relocation */
        !           738: #define        DF_1_NODIRECT   0x00020000      /* Has non-direct bindings */
        !           739: #define        DF_1_IGNMULDEF  0x00040000      /* Used internally */
        !           740: #define        DF_1_NOKSYMS    0x00080000      /* Used internally */
        !           741: #define        DF_1_NOHDR      0x00100000      /* Used internally */
        !           742: #define        DF_1_EDITED     0x00200000      /* Has been modified since build */
        !           743: #define        DF_1_NORELOC    0x00400000      /* Used internally */
        !           744: #define        DF_1_SYMINTPOSE 0x00800000      /* Has individual symbol interposers */
        !           745: #define        DF_1_GLOBAUDIT  0x01000000      /* Require global auditing */
        !           746: #define        DF_1_SINGLETON  0x02000000      /* Has singleton symbols */
        !           747: #define        DF_1_STUB       0x04000000      /* Stub */
        !           748: #define        DF_1_PIE        0x08000000      /* Position Independent Executable */
        !           749: 
        !           750: /*
        !           751:  * Auxiliary Vectors
        !           752:  */
        !           753: typedef struct {
        !           754:        Elf32_Word      a_type;                         /* 32-bit id */
        !           755:        Elf32_Word      a_v;                            /* 32-bit id */
        !           756: } Aux32Info;
        !           757: 
        !           758: typedef struct {
        !           759:        Elf64_Word      a_type;         /* 32-bit id */
        !           760:        Elf64_Xword     a_v;            /* 64-bit id */
        !           761: } Aux64Info;
        !           762: 
        !           763: /* a_type */
        !           764: #define AT_NULL                0       /* Marks end of array */
        !           765: #define AT_IGNORE      1       /* No meaning, a_un is undefined */
        !           766: #define AT_EXECFD      2       /* Open file descriptor of object file */
        !           767: #define AT_PHDR                3       /* &phdr[0] */
        !           768: #define AT_PHENT       4       /* sizeof(phdr[0]) */
        !           769: #define AT_PHNUM       5       /* # phdr entries */
        !           770: #define AT_PAGESZ      6       /* PAGESIZE */
        !           771: #define AT_BASE                7       /* Interpreter base addr */
        !           772: #define AT_FLAGS       8       /* Processor flags */
        !           773: #define AT_ENTRY       9       /* Entry address of executable */
        !           774: #define AT_DCACHEBSIZE 10      /* Data cache block size */
        !           775: #define AT_ICACHEBSIZE 11      /* Instruction cache block size */
        !           776: #define AT_UCACHEBSIZE 12      /* Unified cache block size */
        !           777: #define AT_STACKBASE   13      /* Base address of the main thread */
        !           778: 
        !           779:        /* Vendor specific */
        !           780: #define AT_MIPS_NOTELF 10      /* XXX a_val != 0 -> MIPS XCOFF executable */
        !           781: 
        !           782: #define AT_EUID                2000    /* euid (solaris compatible numbers) */
        !           783: #define AT_RUID                2001    /* ruid (solaris compatible numbers) */
        !           784: #define AT_EGID                2002    /* egid (solaris compatible numbers) */
        !           785: #define AT_RGID                2003    /* rgid (solaris compatible numbers) */
        !           786: 
        !           787:        /* Solaris kernel specific */
        !           788: #define AT_SUN_LDELF   2004    /* dynamic linker's ELF header */
        !           789: #define AT_SUN_LDSHDR  2005    /* dynamic linker's section header */
        !           790: #define AT_SUN_LDNAME  2006    /* dynamic linker's name */
        !           791: #define AT_SUN_LPGSIZE 2007    /* large pagesize */
        !           792: 
        !           793:        /* Other information */
        !           794: #define AT_SUN_PLATFORM 2008   /* sysinfo(SI_PLATFORM) */
        !           795: #define AT_SUN_HWCAP   2009    /* process hardware capabilities */
        !           796: #define AT_SUN_IFLUSH  2010    /* do we need to flush the instruction cache? */
        !           797: #define AT_SUN_CPU     2011    /* CPU name */
        !           798:        /* ibcs2 emulation band aid */
        !           799: #define AT_SUN_EMUL_ENTRY 2012 /* coff entry point */
        !           800: #define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */
        !           801:        /* Executable's fully resolved name */
        !           802: #define AT_SUN_EXECNAME 2014
        !           803: 
        !           804: /*
        !           805:  * The header for GNU-style hash sections.
        !           806:  */
        !           807: typedef struct {
        !           808:        uint32_t        gh_nbuckets;    /* Number of hash buckets. */
        !           809:        uint32_t        gh_symndx;      /* First visible symbol in .dynsym. */
        !           810:        uint32_t        gh_maskwords;   /* #maskwords used in bloom filter. */
        !           811:        uint32_t        gh_shift2;      /* Bloom filter shift count. */
        !           812: } Elf_GNU_Hash_Header;
        !           813: 
        !           814: /*
        !           815:  * Note Headers
        !           816:  */
        !           817: typedef struct {
        !           818:        Elf32_Word n_namesz;
        !           819:        Elf32_Word n_descsz;
        !           820:        Elf32_Word n_type;
        !           821: } Elf32_Nhdr;
        !           822: 
        !           823: typedef struct {
        !           824:        Elf64_Word n_namesz;
        !           825:        Elf64_Word n_descsz;
        !           826:        Elf64_Word n_type;
        !           827: } Elf64_Nhdr;
        !           828: 
        !           829: #define ELF_NOTE_GNU_NAMESZ            4
        !           830: #define ELF_NOTE_GNU_NAME              "GNU\0"
        !           831: 
        !           832: /*
        !           833:  * GNU-specific note type: ABI tag
        !           834:  * name: GNU\0
        !           835:  * namesz: 4
        !           836:  * desc:
        !           837:  *     word[0]: OS tag
        !           838:  *     word[1]: major version
        !           839:  *     word[2]: minor version
        !           840:  *     word[3]: teeny version
        !           841:  * descsz: 16
        !           842:  */
        !           843: /* GNU-specific note name and description sizes */
        !           844: #define ELF_NOTE_TYPE_ABI_TAG          1
        !           845: #define ELF_NOTE_ABI_NAME              ELF_NOTE_GNU_NAME
        !           846: #define ELF_NOTE_ABI_NAMESZ            ELF_NOTE_GNU_NAMESZ
        !           847: #define ELF_NOTE_ABI_DESCSZ            16
        !           848: /* GNU-specific OS/version value stuff */
        !           849: #define ELF_NOTE_ABI_OS_LINUX          0
        !           850: #define ELF_NOTE_ABI_OS_HURD           1
        !           851: #define ELF_NOTE_ABI_OS_SOLARIS                2
        !           852: #define ELF_NOTE_ABI_OS_KFREEBSD       3
        !           853: #define ELF_NOTE_ABI_OS_KNETBSD                4
        !           854: 
        !           855: /* Old gcc style, under the ABI tag */
        !           856: #define ELF_NOTE_OGCC_NAMESZ           8
        !           857: #define ELF_NOTE_OGCC_NAME             "01.01\0\0\0\0"
        !           858: #define ELF_NOTE_OGCC_DESCSZ           0
        !           859: 
        !           860: /*
        !           861:  * GNU-specific note type: Hardware capabilities
        !           862:  * name: GNU\0
        !           863:  * namesz: 4
        !           864:  * desc:
        !           865:  *     word[0]: Number of entries
        !           866:  *     word[1]: Bitmask of enabled entries
        !           867:  *     Followed by a byte id, and a NUL terminated string per entry
        !           868:  * descsz: variable
        !           869:  */
        !           870: #define ELF_NOTE_TYPE_GNU_HWCAP                2
        !           871: 
        !           872: /*
        !           873:  * GNU-specific note type: Build ID generated by ld
        !           874:  * name: GNU\0
        !           875:  * desc:
        !           876:  *     word[0..4] SHA1 [default] 
        !           877:  * or
        !           878:  *     word[0..3] md5 or uuid
        !           879:  * descsz: 16 or 20
        !           880:  */
        !           881: #define ELF_NOTE_TYPE_GNU_BUILD_ID     3
        !           882: 
        !           883: /* SuSE-specific note type: ABI
        !           884:  * name: SuSE\0
        !           885:  * namesz: 5
        !           886:  * desc:
        !           887:  *     half[0] = MMmm
        !           888:  *
        !           889:  *     M = product major version
        !           890:  *     m = product minor version
        !           891:  * descsz: 2
        !           892:  */
        !           893: #define ELF_NOTE_TYPE_SUSE_TAG 1
        !           894: /* SuSE-specific note name and description sizes */
        !           895: #define ELF_NOTE_SUSE_NAMESZ   5
        !           896: #define ELF_NOTE_SUSE_DESCSZ   2
        !           897: /* SuSE-specific note name */
        !           898: #define ELF_NOTE_SUSE_NAME             "SuSE\0"
        !           899: 
        !           900: /* SuSE-specific note type: version
        !           901:  * name: SuSE\0\0\0\0
        !           902:  * namesz: 8
        !           903:  * desc: 
        !           904:  *     word[0] = VVTTMMmm
        !           905:  *
        !           906:  *     V = version of following data
        !           907:  *     T = product type: [box, sles, nld, whatever]
        !           908:  *     M = product major version
        !           909:  *     m = product minor version
        !           910:  * descsz: 8
        !           911:  */
        !           912: #define ELF_NOTE_TYPE_SUSE_VERSION_TAG 0x45537553      /* SuSE in LE */
        !           913: /* SuSE-specific note name and description sizes */
        !           914: #define ELF_NOTE_SUSE_VERSION_NAMESZ   8
        !           915: #define ELF_NOTE_SUSE_VERSION_DESCSZ   8
        !           916: /* SuSE-specific note name */
        !           917: #define ELF_NOTE_SUSE_VERSION_NAME             "SuSE\0\0\0\0"
        !           918: 
        !           919: /* Go-specific note type: buildid
        !           920:  * name: Go\0\0
        !           921:  * namesz: 4
        !           922:  * desc: 
        !           923:  *     words[10]
        !           924:  * descsz: 40
        !           925:  */
        !           926: #define ELF_NOTE_TYPE_GO_BUILDID_TAG   4
        !           927: #define ELF_NOTE_GO_BUILDID_NAMESZ     4
        !           928: #define ELF_NOTE_GO_BUILDID_DESCSZ     40
        !           929: #define ELF_NOTE_GO_BUILDID_NAME       "Go\0\0"
        !           930: 
        !           931: /* NetBSD-specific note type: NetBSD ABI version.
        !           932:  * name: NetBSD\0\0
        !           933:  * namesz: 8
        !           934:  * desc: 
        !           935:  *     word[0]: MMmmrrpp00
        !           936:  *
        !           937:  *     M = major version
        !           938:  *     m = minor version
        !           939:  *     r = release ["",A-Z,Z[A-Z] but numeric]
        !           940:  *     p = patchlevel
        !           941:  * descsz: 4
        !           942:  */
        !           943: #define ELF_NOTE_TYPE_NETBSD_TAG       1
        !           944: /* NetBSD-specific note name and description sizes */
        !           945: #define ELF_NOTE_NETBSD_NAMESZ         7
        !           946: #define ELF_NOTE_NETBSD_DESCSZ         4
        !           947: /* NetBSD-specific note name */
        !           948: #define ELF_NOTE_NETBSD_NAME           "NetBSD\0\0"
        !           949: 
        !           950: /* NetBSD-specific note type: Emulation (obsolete; last used early 2000)
        !           951:  * name: NetBSD\0\0
        !           952:  * namesz: 8
        !           953:  * desc:
        !           954:  *     "netbsd\0"
        !           955:  *     
        !           956:  * descsz: 8
        !           957:  */
        !           958: #define ELF_NOTE_TYPE_NETBSD_EMUL_TAG  2
        !           959: #define ELF_NOTE_NETBSD_EMUL_NAMESZ    7
        !           960: #define ELF_NOTE_NETBSD_EMUL_DESCSZ    7
        !           961: /* NetBSD-specific note name */
        !           962: #define ELF_NOTE_NETBSD_EMUL_NAME      "NetBSD\0\0"
        !           963: 
        !           964: /*
        !           965:  * NetBSD-specific note type: PaX.
        !           966:  * There should be 1 NOTE per executable.
        !           967:  * name: PaX\0
        !           968:  * namesz: 4
        !           969:  * desc:
        !           970:  *     word[0]: capability bitmask
        !           971:  * descsz: 4
        !           972:  */
        !           973: #define ELF_NOTE_TYPE_PAX_TAG          3
        !           974: #define ELF_NOTE_PAX_MPROTECT          0x01    /* Force enable Mprotect */
        !           975: #define ELF_NOTE_PAX_NOMPROTECT                0x02    /* Force disable Mprotect */
        !           976: #define ELF_NOTE_PAX_GUARD             0x04    /* Force enable Segvguard */
        !           977: #define ELF_NOTE_PAX_NOGUARD           0x08    /* Force disable Segvguard */
        !           978: #define ELF_NOTE_PAX_ASLR              0x10    /* Force enable ASLR */
        !           979: #define ELF_NOTE_PAX_NOASLR            0x20    /* Force disable ASLR */
        !           980: #define ELF_NOTE_PAX_NAMESZ            4
        !           981: #define ELF_NOTE_PAX_NAME              "PaX\0"
        !           982: #define ELF_NOTE_PAX_DESCSZ            4
        !           983: 
        !           984: /*
        !           985:  * NetBSD-specific core file information.
        !           986:  *
        !           987:  * NetBSD ELF core files use notes to provide information about
        !           988:  * the process's state.         The note name is "NetBSD-CORE" for
        !           989:  * information that is global to the process, and "NetBSD-CORE@nn",
        !           990:  * where "nn" is the lwpid of the LWP that the information belongs
        !           991:  * to (such as register state).
        !           992:  *
        !           993:  * We use the following note identifiers:
        !           994:  *
        !           995:  *     ELF_NOTE_NETBSD_CORE_PROCINFO
        !           996:  *             Note is a "netbsd_elfcore_procinfo" structure.
        !           997:  *     ELF_NOTE_NETBSD_CORE_AUXV
        !           998:  *             Note is an array of AuxInfo structures.
        !           999:  *
        !          1000:  * We also use ptrace(2) request numbers (the ones that exist in
        !          1001:  * machine-dependent space) to identify register info notes.  The
        !          1002:  * info in such notes is in the same format that ptrace(2) would
        !          1003:  * export that information.
        !          1004:  *
        !          1005:  * Please try to keep the members of this structure nicely aligned,
        !          1006:  * and if you add elements, add them to the end and bump the version.
        !          1007:  */
        !          1008: 
        !          1009: #define ELF_NOTE_NETBSD_CORE_NAME      "NetBSD-CORE"
        !          1010: 
        !          1011: #define ELF_NOTE_NETBSD_CORE_PROCINFO  1
        !          1012: #define ELF_NOTE_NETBSD_CORE_AUXV      2
        !          1013: 
        !          1014: #define NETBSD_ELFCORE_PROCINFO_VERSION 1
        !          1015: 
        !          1016: struct netbsd_elfcore_procinfo {
        !          1017:        /* Version 1 fields start here. */
        !          1018:        uint32_t        cpi_version;            /* our version */
        !          1019:        uint32_t        cpi_cpisize;            /* sizeof(this struct) */
        !          1020:        uint32_t        cpi_signo;              /* killing signal */
        !          1021:        uint32_t        cpi_sigcode;            /* signal code */
        !          1022:        uint32_t        cpi_sigpend[4];         /* pending signals */
        !          1023:        uint32_t        cpi_sigmask[4];         /* blocked signals */
        !          1024:        uint32_t        cpi_sigignore[4];       /* ignored signals */
        !          1025:        uint32_t        cpi_sigcatch[4];        /* caught signals */
        !          1026:        int32_t         cpi_pid;                /* process ID */
        !          1027:        int32_t         cpi_ppid;               /* parent process ID */
        !          1028:        int32_t         cpi_pgrp;               /* process group ID */
        !          1029:        int32_t         cpi_sid;                /* session ID */
        !          1030:        uint32_t        cpi_ruid;               /* real user ID */
        !          1031:        uint32_t        cpi_euid;               /* effective user ID */
        !          1032:        uint32_t        cpi_svuid;              /* saved user ID */
        !          1033:        uint32_t        cpi_rgid;               /* real group ID */
        !          1034:        uint32_t        cpi_egid;               /* effective group ID */
        !          1035:        uint32_t        cpi_svgid;              /* saved group ID */
        !          1036:        uint32_t        cpi_nlwps;              /* number of LWPs */
        !          1037:        int8_t          cpi_name[32];           /* copy of p->p_comm */
        !          1038:        /* Add version 2 fields below here. */
        !          1039:        int32_t         cpi_siglwp;     /* LWP target of killing signal */
        !          1040: };
        !          1041: 
        !          1042: /*
        !          1043:  * NetBSD-specific note type: MACHINE_ARCH.
        !          1044:  * There should be 1 NOTE per executable.
        !          1045:  * name:       NetBSD\0
        !          1046:  * namesz:     7
        !          1047:  * desc:       string
        !          1048:  * descsz:     variable
        !          1049:  */
        !          1050: #define ELF_NOTE_TYPE_MARCH_TAG                5
        !          1051: /* NetBSD-specific note name and description sizes */
        !          1052: #define ELF_NOTE_MARCH_NAMESZ          ELF_NOTE_NETBSD_NAMESZ
        !          1053: /* NetBSD-specific note name */
        !          1054: #define ELF_NOTE_MARCH_NAME            ELF_NOTE_NETBSD_NAME
        !          1055: 
        !          1056: /*
        !          1057:  * NetBSD-specific note type: MCMODEL
        !          1058:  * There should be 1 NOTE per executable.
        !          1059:  * name:       NetBSD\0
        !          1060:  * namesz:     7
        !          1061:  * code model: string
        !          1062:  */
        !          1063: 
        !          1064: #define ELF_NOTE_TYPE_MCMODEL_TAG      6
        !          1065: /* NetBSD-specific note name and description sizes */
        !          1066: #define ELF_NOTE_MCMODEL_NAMESZ                ELF_NOTE_NETBSD_NAMESZ
        !          1067: /* NetBSD-specific note name */
        !          1068: #define ELF_NOTE_MCMODEL_NAME          ELF_NOTE_NETBSD_NAME
        !          1069: 
        !          1070: 
        !          1071: #if !defined(ELFSIZE)
        !          1072: # if defined(_RUMPKERNEL) || !defined(_KERNEL)
        !          1073: #  define ELFSIZE ARCH_ELFSIZE
        !          1074: # else
        !          1075: #  define ELFSIZE KERN_ELFSIZE
        !          1076: # endif
        !          1077: #endif
        !          1078: 
        !          1079: #if defined(ELFSIZE)
        !          1080: #define CONCAT(x,y)    __CONCAT(x,y)
        !          1081: #define ELFNAME(x)     CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
        !          1082: #define ELFNAME2(x,y)  CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
        !          1083: #define ELFNAMEEND(x)  CONCAT(x,CONCAT(_elf,ELFSIZE))
        !          1084: #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
        !          1085: #define        ElfW(x)         CONCAT(Elf,CONCAT(ELFSIZE,CONCAT(_,x)))
        !          1086: #endif
        !          1087: 
        !          1088: #if defined(ELFSIZE) && (ELFSIZE == 32)
        !          1089: #define Elf_Ehdr       Elf32_Ehdr
        !          1090: #define Elf_Phdr       Elf32_Phdr
        !          1091: #define Elf_Shdr       Elf32_Shdr
        !          1092: #define Elf_Sym                Elf32_Sym
        !          1093: #define Elf_Rel                Elf32_Rel
        !          1094: #define Elf_Rela       Elf32_Rela
        !          1095: #define Elf_Dyn                Elf32_Dyn
        !          1096: #define Elf_Word       Elf32_Word
        !          1097: #define Elf_Sword      Elf32_Sword
        !          1098: #define Elf_Half       Elf32_Half
        !          1099: #define Elf_Addr       Elf32_Addr
        !          1100: #define Elf_Off                Elf32_Off
        !          1101: #define Elf_SOff       Elf32_SOff
        !          1102: #define Elf_Nhdr       Elf32_Nhdr
        !          1103: #define Elf_Verdef     Elf32_Verdef
        !          1104: #define Elf_Verdaux    Elf32_Verdaux
        !          1105: #define Elf_Verneed    Elf32_Verneed
        !          1106: #define Elf_Vernaux    Elf32_Vernaux
        !          1107: #define Elf_Versym     Elf32_Versym
        !          1108: 
        !          1109: #define ELF_R_SYM      ELF32_R_SYM
        !          1110: #define ELF_R_TYPE     ELF32_R_TYPE
        !          1111: #define ELFCLASS       ELFCLASS32
        !          1112: 
        !          1113: #define AuxInfo                Aux32Info
        !          1114: #elif defined(ELFSIZE) && (ELFSIZE == 64)
        !          1115: #define Elf_Ehdr       Elf64_Ehdr
        !          1116: #define Elf_Phdr       Elf64_Phdr
        !          1117: #define Elf_Shdr       Elf64_Shdr
        !          1118: #define Elf_Sym                Elf64_Sym
        !          1119: #define Elf_Rel                Elf64_Rel
        !          1120: #define Elf_Rela       Elf64_Rela
        !          1121: #define Elf_Dyn                Elf64_Dyn
        !          1122: #define Elf_Word       Elf64_Word
        !          1123: #define Elf_Sword      Elf64_Sword
        !          1124: #define Elf_Half       Elf64_Half
        !          1125: #define Elf_Addr       Elf64_Addr
        !          1126: #define Elf_Off                Elf64_Off
        !          1127: #define Elf_SOff       Elf64_SOff
        !          1128: #define Elf_Nhdr       Elf64_Nhdr
        !          1129: #define Elf_Verdef     Elf64_Verdef
        !          1130: #define Elf_Verdaux    Elf64_Verdaux
        !          1131: #define Elf_Verneed    Elf64_Verneed
        !          1132: #define Elf_Vernaux    Elf64_Vernaux
        !          1133: #define Elf_Versym     Elf64_Versym
        !          1134: 
        !          1135: #define ELF_R_SYM      ELF64_R_SYM
        !          1136: #define ELF_R_TYPE     ELF64_R_TYPE
        !          1137: #define ELFCLASS       ELFCLASS64
        !          1138: 
        !          1139: #define AuxInfo                Aux64Info
        !          1140: #endif
        !          1141: 
        !          1142: #ifndef Elf_Symindx
        !          1143: #define Elf_Symindx    uint32_t
        !          1144: #endif
        !          1145: 
        !          1146: #define ELF32_ST_BIND(info)            ELF_ST_BIND(info)
        !          1147: #define ELF32_ST_TYPE(info)            ELF_ST_TYPE(info)
        !          1148: #define ELF32_ST_INFO(bind,type)       ELF_ST_INFO(bind,type)
        !          1149: #define ELF32_ST_VISIBILITY(other)     ELF_ST_VISIBILITY(other)
        !          1150: 
        !          1151: #define ELF64_ST_BIND(info)            ELF_ST_BIND(info)
        !          1152: #define ELF64_ST_TYPE(info)            ELF_ST_TYPE(info)
        !          1153: #define ELF64_ST_INFO(bind,type)       ELF_ST_INFO(bind,type)
        !          1154: #define ELF64_ST_VISIBILITY(other)     ELF_ST_VISIBILITY(other)
        !          1155: 
        !          1156: typedef struct {
        !          1157:        Elf32_Half      si_boundto;     /* direct bindings - symbol bound to */
        !          1158:        Elf32_Half      si_flags;       /* per symbol flags */
        !          1159: } Elf32_Syminfo;
        !          1160: 
        !          1161: typedef struct {
        !          1162:        Elf64_Word      si_boundto;     /* direct bindings - symbol bound to */
        !          1163:        Elf64_Word      si_flags;       /* per symbol flags */
        !          1164: } Elf64_Syminfo;
        !          1165: 
        !          1166: #define SYMINFO_FLG_DIRECT     0x0001  /* symbol ref has direct association
        !          1167:                                           to object containing definition */
        !          1168: #define SYMINFO_FLG_PASSTHRU   0x0002  /* ignored - see SYMINFO_FLG_FILTER */
        !          1169: #define SYMINFO_FLG_COPY       0x0004  /* symbol is a copy-reloc */
        !          1170: #define SYMINFO_FLG_LAZYLOAD   0x0008  /* object containing defn should be
        !          1171:                                           lazily-loaded */
        !          1172: #define SYMINFO_FLG_DIRECTBIND 0x0010  /* ref should be bound directly to
        !          1173:                                           object containing definition */
        !          1174: #define SYMINFO_FLG_NOEXTDIRECT 0x0020 /* don't let an external reference
        !          1175:                                           directly bind to this symbol */
        !          1176: #define SYMINFO_FLG_FILTER     0x0002  /* symbol ref is associated to a */
        !          1177: #define SYMINFO_FLG_AUXILIARY  0x0040  /*      standard or auxiliary filter */
        !          1178: 
        !          1179: #define SYMINFO_BT_SELF                0xffff  /* symbol bound to self */
        !          1180: #define SYMINFO_BT_PARENT      0xfffe  /* symbol bound to parent */
        !          1181: #define SYMINFO_BT_NONE                0xfffd  /* no special symbol binding */
        !          1182: #define SYMINFO_BT_EXTERN      0xfffc  /* symbol defined as external */
        !          1183: #define SYMINFO_BT_LOWRESERVE  0xff00  /* beginning of reserved entries */
        !          1184: 
        !          1185: #define SYMINFO_NONE           0       /* Syminfo version */
        !          1186: #define SYMINFO_CURRENT                1
        !          1187: #define SYMINFO_NUM            2
        !          1188: 
        !          1189: /*
        !          1190:  * These constants are used for Elf32_Verdef struct's version number.  
        !          1191:  */
        !          1192: #define VER_DEF_NONE           0
        !          1193: #define VER_DEF_CURRENT                1
        !          1194: 
        !          1195: /*
        !          1196:  * These constants are used for Elf32_Verdef struct's vd_ndx.
        !          1197:  */
        !          1198: #define VER_DEF_IDX(x)         VER_NDX(x)
        !          1199: 
        !          1200: /*
        !          1201:  * These constants are used for Elf32_Verdef struct's vd_flags.         
        !          1202:  */
        !          1203: #define VER_FLG_BASE           0x1
        !          1204: #define VER_FLG_WEAK           0x2
        !          1205: 
        !          1206: /*
        !          1207:  * These are used in an Elf32_Versym field.
        !          1208:  */
        !          1209: #define VER_NDX_LOCAL          0
        !          1210: #define VER_NDX_GLOBAL         1
        !          1211: #define VER_NDX_GIVEN          2
        !          1212: 
        !          1213: /*
        !          1214:  * These constants are used for Elf32_Verneed struct's version number. 
        !          1215:  */
        !          1216: #define VER_NEED_NONE          0
        !          1217: #define VER_NEED_CURRENT       1
        !          1218: 
        !          1219: /*
        !          1220:  * These constants are used for Elf32_Vernaux struct's vna_other.
        !          1221:  */
        !          1222: #define VER_NEED_HIDDEN                VER_NDX_HIDDEN
        !          1223: #define VER_NEED_IDX(x)                VER_NDX(x)
        !          1224: 
        !          1225: /* index */
        !          1226: #define VER_NDX_HIDDEN         0x8000
        !          1227: #define VER_NDX(x)             ((x) & ~VER_NDX_HIDDEN)
        !          1228: 
        !          1229: /*
        !          1230:  * GNU Extension hidding symbol
        !          1231:  */
        !          1232: #define VERSYM_HIDDEN          0x8000
        !          1233: #define VERSYM_VERSION         0x7fff
        !          1234: 
        !          1235: #define ELF_VER_CHR            '@'
        !          1236: 
        !          1237: /*
        !          1238:  * These are current size independent.
        !          1239:  */
        !          1240: 
        !          1241: typedef struct {
        !          1242:        Elf32_Half      vd_version;     /* version number of structure */
        !          1243:        Elf32_Half      vd_flags;       /* flags (VER_FLG_*) */
        !          1244:        Elf32_Half      vd_ndx;         /* version index */
        !          1245:        Elf32_Half      vd_cnt;         /* number of verdaux entries */
        !          1246:        Elf32_Word      vd_hash;        /* hash of name */
        !          1247:        Elf32_Word      vd_aux;         /* offset to verdaux entries */
        !          1248:        Elf32_Word      vd_next;        /* offset to next verdef */
        !          1249: } Elf32_Verdef;
        !          1250: typedef Elf32_Verdef   Elf64_Verdef;
        !          1251: 
        !          1252: typedef struct {
        !          1253:        Elf32_Word      vda_name;       /* string table offset of name */
        !          1254:        Elf32_Word      vda_next;       /* offset to verdaux */
        !          1255: } Elf32_Verdaux;
        !          1256: typedef Elf32_Verdaux  Elf64_Verdaux;
        !          1257: 
        !          1258: typedef struct {
        !          1259:        Elf32_Half      vn_version;     /* version number of structure */
        !          1260:        Elf32_Half      vn_cnt;         /* number of vernaux entries */
        !          1261:        Elf32_Word      vn_file;        /* string table offset of library name*/
        !          1262:        Elf32_Word      vn_aux;         /* offset to vernaux entries */
        !          1263:        Elf32_Word      vn_next;        /* offset to next verneed */
        !          1264: } Elf32_Verneed;
        !          1265: typedef Elf32_Verneed  Elf64_Verneed;
        !          1266: 
        !          1267: typedef struct {
        !          1268:        Elf32_Word      vna_hash;       /* Hash of dependency name */
        !          1269:        Elf32_Half      vna_flags;      /* flags (VER_FLG_*) */
        !          1270:        Elf32_Half      vna_other;      /* unused */
        !          1271:        Elf32_Word      vna_name;       /* string table offset to version name*/
        !          1272:        Elf32_Word      vna_next;       /* offset to next vernaux */
        !          1273: } Elf32_Vernaux;
        !          1274: typedef Elf32_Vernaux  Elf64_Vernaux;
        !          1275: 
        !          1276: typedef struct {
        !          1277:        Elf32_Half      vs_vers;
        !          1278: } Elf32_Versym;
        !          1279: typedef Elf32_Versym   Elf64_Versym;
        !          1280: 
        !          1281: #ifdef _KERNEL
        !          1282: 
        !          1283: /*
        !          1284:  * Arbitrary limits to avoid DoS for excessive memory allocation.
        !          1285:  */
        !          1286: #define ELF_MAXPHNUM   128
        !          1287: #define ELF_MAXSHNUM   32768
        !          1288: #define ELF_MAXNOTESIZE        1024
        !          1289: 
        !          1290: #define ELF_AUX_ENTRIES 15     /* Max size of aux array passed to loader */
        !          1291: #define ELF32_NO_ADDR  (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */
        !          1292: #define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */
        !          1293: #define ELF64_NO_ADDR  (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */
        !          1294: #define ELF64_LINK_ADDR ((Elf64_Addr)-2) /* advises to use link address */
        !          1295: 
        !          1296: #if defined(ELFSIZE) && (ELFSIZE == 64)
        !          1297: #define ELF_NO_ADDR    ELF64_NO_ADDR
        !          1298: #define ELF_LINK_ADDR  ELF64_LINK_ADDR
        !          1299: #elif defined(ELFSIZE) && (ELFSIZE == 32)
        !          1300: #define ELF_NO_ADDR    ELF32_NO_ADDR
        !          1301: #define ELF_LINK_ADDR  ELF32_LINK_ADDR
        !          1302: #endif
        !          1303: 
        !          1304: #ifndef ELF32_EHDR_FLAGS_OK
        !          1305: #define ELF32_EHDR_FLAGS_OK(eh) 1
        !          1306: #endif
        !          1307: 
        !          1308: #ifndef ELF64_EHDR_FLAGS_OK
        !          1309: #define ELF64_EHDR_FLAGS_OK(eh) 1
        !          1310: #endif
        !          1311: 
        !          1312: #if defined(ELFSIZE) && (ELFSIZE == 64)
        !          1313: #define ELF_EHDR_FLAGS_OK(eh)  ELF64_EHDR_FLAGS_OK(eh)
        !          1314: #else
        !          1315: #define ELF_EHDR_FLAGS_OK(eh)  ELF32_EHDR_FLAGS_OK(eh)
        !          1316: #endif
        !          1317: 
        !          1318: #if defined(ELFSIZE)
        !          1319: struct elf_args {
        !          1320:        Elf_Addr        arg_entry;      /* program entry point */
        !          1321:        Elf_Addr        arg_interp;     /* Interpreter load address */
        !          1322:        Elf_Addr        arg_phaddr;     /* program header address */
        !          1323:        Elf_Addr        arg_phentsize;  /* Size of program header */
        !          1324:        Elf_Addr        arg_phnum;      /* Number of program headers */
        !          1325: };
        !          1326: #endif
        !          1327: 
        !          1328: #ifdef _KERNEL_OPT
        !          1329: #include "opt_execfmt.h"
        !          1330: #endif
        !          1331: 
        !          1332: struct ps_strings;
        !          1333: struct coredump_iostate;
        !          1334: struct note_state;
        !          1335: struct exec_package;
        !          1336: 
        !          1337: #ifdef EXEC_ELF32
        !          1338: int    exec_elf32_makecmds(struct lwp *, struct exec_package *);
        !          1339: int    elf32_populate_auxv(struct lwp *, struct exec_package *, char **);
        !          1340: int    elf32_copyargs(struct lwp *, struct exec_package *,
        !          1341:     struct ps_strings *, char **, void *);
        !          1342: 
        !          1343: int    coredump_elf32(struct lwp *, struct coredump_iostate *);
        !          1344: void   coredump_savenote_elf32(struct note_state *, unsigned int,
        !          1345:            const char *, void *, size_t);
        !          1346: 
        !          1347: int    elf32_check_header(Elf32_Ehdr *);
        !          1348: #endif
        !          1349: 
        !          1350: #ifdef EXEC_ELF64
        !          1351: int    exec_elf64_makecmds(struct lwp *, struct exec_package *);
        !          1352: int    elf64_populate_auxv(struct lwp *, struct exec_package *, char **);
        !          1353: int    elf64_copyargs(struct lwp *, struct exec_package *,
        !          1354:     struct ps_strings *, char **, void *);
        !          1355: 
        !          1356: int    coredump_elf64(struct lwp *, struct coredump_iostate *);
        !          1357: void   coredump_savenote_elf64(struct note_state *, unsigned int,
        !          1358:            const char *, void *, size_t);
        !          1359: 
        !          1360: int    elf64_check_header(Elf64_Ehdr *);
        !          1361: #endif
        !          1362: 
        !          1363: #endif /* _KERNEL */
        !          1364: 
        !          1365: #endif /* !_SYS_EXEC_ELF_H_ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.