[BACK]Return to exec_elf.h CVS log [TXT][DIR] Up to [local] / sys / sys

Annotation of sys/sys/exec_elf.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: exec_elf.h,v 1.43 2007/05/14 05:04:58 tedu Exp $      */
        !             2: /*
        !             3:  * Copyright (c) 1995, 1996 Erik Theisen.  All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms, with or without
        !             6:  * modification, are permitted provided that the following conditions
        !             7:  * are met:
        !             8:  * 1. Redistributions of source code must retain the above copyright
        !             9:  *    notice, this list of conditions and the following disclaimer.
        !            10:  * 2. Redistributions in binary form must reproduce the above copyright
        !            11:  *    notice, this list of conditions and the following disclaimer in the
        !            12:  *    documentation and/or other materials provided with the distribution.
        !            13:  * 3. The name of the author may not be used to endorse or promote products
        !            14:  *    derived from this software without specific prior written permission
        !            15:  *
        !            16:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
        !            17:  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
        !            18:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
        !            19:  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
        !            20:  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
        !            21:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
        !            22:  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
        !            23:  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
        !            24:  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
        !            25:  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        !            26:  */
        !            27:
        !            28: /*
        !            29:  * This is the ELF ABI header file
        !            30:  * formerly known as "elf_abi.h".
        !            31:  */
        !            32:
        !            33: #ifndef _SYS_EXEC_ELF_H_
        !            34: #define _SYS_EXEC_ELF_H_
        !            35:
        !            36: #include <machine/_types.h>
        !            37: #include <machine/exec.h>
        !            38:
        !            39: typedef __uint8_t      Elf_Byte;
        !            40:
        !            41: typedef __uint32_t     Elf32_Addr;     /* Unsigned program address */
        !            42: typedef __uint32_t     Elf32_Off;      /* Unsigned file offset */
        !            43: typedef __int32_t      Elf32_Sword;    /* Signed large integer */
        !            44: typedef __uint32_t     Elf32_Word;     /* Unsigned large integer */
        !            45: typedef __uint16_t     Elf32_Half;     /* Unsigned medium integer */
        !            46:
        !            47: typedef __uint64_t     Elf64_Addr;
        !            48: typedef __uint64_t     Elf64_Off;
        !            49: typedef __int32_t      Elf64_Shalf;
        !            50:
        !            51: #ifdef __alpha__
        !            52: typedef __int64_t      Elf64_Sword;
        !            53: typedef __uint64_t     Elf64_Word;
        !            54: #else
        !            55: typedef __int32_t      Elf64_Sword;
        !            56: typedef __uint32_t     Elf64_Word;
        !            57: #endif
        !            58:
        !            59: typedef __int64_t      Elf64_Sxword;
        !            60: typedef __uint64_t     Elf64_Xword;
        !            61:
        !            62: typedef __uint32_t     Elf64_Half;
        !            63: typedef __uint16_t     Elf64_Quarter;
        !            64:
        !            65: /*
        !            66:  * e_ident[] identification indexes
        !            67:  * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html
        !            68:  */
        !            69: #define EI_MAG0                0               /* file ID */
        !            70: #define EI_MAG1                1               /* file ID */
        !            71: #define EI_MAG2                2               /* file ID */
        !            72: #define EI_MAG3                3               /* file ID */
        !            73: #define EI_CLASS       4               /* file class */
        !            74: #define EI_DATA                5               /* data encoding */
        !            75: #define EI_VERSION     6               /* ELF header version */
        !            76: #define EI_OSABI       7               /* OS/ABI ID */
        !            77: #define EI_ABIVERSION  8               /* ABI version */
        !            78: #define EI_PAD         9               /* start of pad bytes */
        !            79: #define EI_NIDENT      16              /* Size of e_ident[] */
        !            80:
        !            81: /* e_ident[] magic number */
        !            82: #define        ELFMAG0         0x7f            /* e_ident[EI_MAG0] */
        !            83: #define        ELFMAG1         'E'             /* e_ident[EI_MAG1] */
        !            84: #define        ELFMAG2         'L'             /* e_ident[EI_MAG2] */
        !            85: #define        ELFMAG3         'F'             /* e_ident[EI_MAG3] */
        !            86: #define        ELFMAG          "\177ELF"       /* magic */
        !            87: #define        SELFMAG         4               /* size of magic */
        !            88:
        !            89: /* e_ident[] file class */
        !            90: #define        ELFCLASSNONE    0               /* invalid */
        !            91: #define        ELFCLASS32      1               /* 32-bit objs */
        !            92: #define        ELFCLASS64      2               /* 64-bit objs */
        !            93: #define        ELFCLASSNUM     3               /* number of classes */
        !            94:
        !            95: /* e_ident[] data encoding */
        !            96: #define ELFDATANONE    0               /* invalid */
        !            97: #define ELFDATA2LSB    1               /* Little-Endian */
        !            98: #define ELFDATA2MSB    2               /* Big-Endian */
        !            99: #define ELFDATANUM     3               /* number of data encode defines */
        !           100:
        !           101: /* e_ident[] Operating System/ABI */
        !           102: #define ELFOSABI_SYSV          0       /* UNIX System V ABI */
        !           103: #define ELFOSABI_HPUX          1       /* HP-UX operating system */
        !           104: #define ELFOSABI_NETBSD                2       /* NetBSD */
        !           105: #define ELFOSABI_LINUX         3       /* GNU/Linux */
        !           106: #define ELFOSABI_HURD          4       /* GNU/Hurd */
        !           107: #define ELFOSABI_86OPEN                5       /* 86Open common IA32 ABI */
        !           108: #define ELFOSABI_SOLARIS       6       /* Solaris */
        !           109: #define ELFOSABI_MONTEREY      7       /* Monterey */
        !           110: #define ELFOSABI_IRIX          8       /* IRIX */
        !           111: #define ELFOSABI_FREEBSD       9       /* FreeBSD */
        !           112: #define ELFOSABI_TRU64         10      /* TRU64 UNIX */
        !           113: #define ELFOSABI_MODESTO       11      /* Novell Modesto */
        !           114: #define ELFOSABI_OPENBSD       12      /* OpenBSD */
        !           115: #define ELFOSABI_ARM           97      /* ARM */
        !           116: #define ELFOSABI_STANDALONE    255     /* Standalone (embedded) application */
        !           117:
        !           118: /* e_ident */
        !           119: #define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
        !           120:                       (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
        !           121:                       (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
        !           122:                       (ehdr).e_ident[EI_MAG3] == ELFMAG3)
        !           123:
        !           124: /* ELF Header */
        !           125: typedef struct elfhdr {
        !           126:        unsigned char   e_ident[EI_NIDENT]; /* ELF Identification */
        !           127:        Elf32_Half      e_type;         /* object file type */
        !           128:        Elf32_Half      e_machine;      /* machine */
        !           129:        Elf32_Word      e_version;      /* object file version */
        !           130:        Elf32_Addr      e_entry;        /* virtual entry point */
        !           131:        Elf32_Off       e_phoff;        /* program header table offset */
        !           132:        Elf32_Off       e_shoff;        /* section header table offset */
        !           133:        Elf32_Word      e_flags;        /* processor-specific flags */
        !           134:        Elf32_Half      e_ehsize;       /* ELF header size */
        !           135:        Elf32_Half      e_phentsize;    /* program header entry size */
        !           136:        Elf32_Half      e_phnum;        /* number of program header entries */
        !           137:        Elf32_Half      e_shentsize;    /* section header entry size */
        !           138:        Elf32_Half      e_shnum;        /* number of section header entries */
        !           139:        Elf32_Half      e_shstrndx;     /* section header table's "section
        !           140:                                           header string table" entry offset */
        !           141: } Elf32_Ehdr;
        !           142:
        !           143: typedef struct {
        !           144:        unsigned char   e_ident[EI_NIDENT];     /* Id bytes */
        !           145:        Elf64_Quarter   e_type;                 /* file type */
        !           146:        Elf64_Quarter   e_machine;              /* machine type */
        !           147:        Elf64_Half      e_version;              /* version number */
        !           148:        Elf64_Addr      e_entry;                /* entry point */
        !           149:        Elf64_Off       e_phoff;                /* Program hdr offset */
        !           150:        Elf64_Off       e_shoff;                /* Section hdr offset */
        !           151:        Elf64_Half      e_flags;                /* Processor flags */
        !           152:        Elf64_Quarter   e_ehsize;               /* sizeof ehdr */
        !           153:        Elf64_Quarter   e_phentsize;            /* Program header entry size */
        !           154:        Elf64_Quarter   e_phnum;                /* Number of program headers */
        !           155:        Elf64_Quarter   e_shentsize;            /* Section header entry size */
        !           156:        Elf64_Quarter   e_shnum;                /* Number of section headers */
        !           157:        Elf64_Quarter   e_shstrndx;             /* String table index */
        !           158: } Elf64_Ehdr;
        !           159:
        !           160: /* e_type */
        !           161: #define ET_NONE                0               /* No file type */
        !           162: #define ET_REL         1               /* relocatable file */
        !           163: #define ET_EXEC                2               /* executable file */
        !           164: #define ET_DYN         3               /* shared object file */
        !           165: #define ET_CORE                4               /* core file */
        !           166: #define ET_NUM         5               /* number of types */
        !           167: #define ET_LOPROC      0xff00          /* reserved range for processor */
        !           168: #define ET_HIPROC      0xffff          /*  specific e_type */
        !           169:
        !           170: /* e_machine */
        !           171: #define EM_NONE                0               /* No Machine */
        !           172: #define EM_M32         1               /* AT&T WE 32100 */
        !           173: #define EM_SPARC       2               /* SPARC */
        !           174: #define EM_386         3               /* Intel 80386 */
        !           175: #define EM_68K         4               /* Motorola 68000 */
        !           176: #define EM_88K         5               /* Motorola 88000 */
        !           177: #define EM_486         6               /* Intel 80486 - unused? */
        !           178: #define EM_860         7               /* Intel 80860 */
        !           179: #define EM_MIPS                8               /* MIPS R3000 Big-Endian only */
        !           180: /*
        !           181:  * Don't know if EM_MIPS_RS4_BE,
        !           182:  * EM_SPARC64, EM_PARISC,
        !           183:  * or EM_PPC are ABI compliant
        !           184:  */
        !           185: #define EM_MIPS_RS4_BE 10              /* MIPS R4000 Big-Endian */
        !           186: #define EM_SPARC64     11              /* SPARC v9 64-bit unoffical */
        !           187: #define EM_PARISC      15              /* HPPA */
        !           188: #define EM_SPARC32PLUS 18              /* Enhanced instruction set SPARC */
        !           189: #define EM_PPC         20              /* PowerPC */
        !           190: #define EM_ARM         40              /* Advanced RISC Machines ARM */
        !           191: #define EM_ALPHA       41              /* DEC ALPHA */
        !           192: #define        EM_SH           42              /* Hitachi/Renesas Super-H */
        !           193: #define EM_SPARCV9     43              /* SPARC version 9 */
        !           194: #define EM_ALPHA_EXP   0x9026          /* DEC ALPHA */
        !           195: #define EM_AMD64       62              /* AMD64 architecture */
        !           196: #define EM_VAX         75              /* DEC VAX */
        !           197: #define EM_NUM         15              /* number of machine types */
        !           198:
        !           199: /* Version */
        !           200: #define EV_NONE                0               /* Invalid */
        !           201: #define EV_CURRENT     1               /* Current */
        !           202: #define EV_NUM         2               /* number of versions */
        !           203:
        !           204: /* Section Header */
        !           205: typedef struct {
        !           206:        Elf32_Word      sh_name;        /* name - index into section header
        !           207:                                           string table section */
        !           208:        Elf32_Word      sh_type;        /* type */
        !           209:        Elf32_Word      sh_flags;       /* flags */
        !           210:        Elf32_Addr      sh_addr;        /* address */
        !           211:        Elf32_Off       sh_offset;      /* file offset */
        !           212:        Elf32_Word      sh_size;        /* section size */
        !           213:        Elf32_Word      sh_link;        /* section header table index link */
        !           214:        Elf32_Word      sh_info;        /* extra information */
        !           215:        Elf32_Word      sh_addralign;   /* address alignment */
        !           216:        Elf32_Word      sh_entsize;     /* section entry size */
        !           217: } Elf32_Shdr;
        !           218:
        !           219: typedef struct {
        !           220:        Elf64_Half      sh_name;        /* section name */
        !           221:        Elf64_Half      sh_type;        /* section type */
        !           222:        Elf64_Xword     sh_flags;       /* section flags */
        !           223:        Elf64_Addr      sh_addr;        /* virtual address */
        !           224:        Elf64_Off       sh_offset;      /* file offset */
        !           225:        Elf64_Xword     sh_size;        /* section size */
        !           226:        Elf64_Half      sh_link;        /* link to another */
        !           227:        Elf64_Half      sh_info;        /* misc info */
        !           228:        Elf64_Xword     sh_addralign;   /* memory alignment */
        !           229:        Elf64_Xword     sh_entsize;     /* table entry size */
        !           230: } Elf64_Shdr;
        !           231:
        !           232: /* Special Section Indexes */
        !           233: #define SHN_UNDEF      0               /* undefined */
        !           234: #define SHN_LORESERVE  0xff00          /* lower bounds of reserved indexes */
        !           235: #define SHN_LOPROC     0xff00          /* reserved range for processor */
        !           236: #define SHN_HIPROC     0xff1f          /*   specific section indexes */
        !           237: #define SHN_ABS                0xfff1          /* absolute value */
        !           238: #define SHN_COMMON     0xfff2          /* common symbol */
        !           239: #define SHN_HIRESERVE  0xffff          /* upper bounds of reserved indexes */
        !           240:
        !           241: /* sh_type */
        !           242: #define SHT_NULL       0               /* inactive */
        !           243: #define SHT_PROGBITS   1               /* program defined information */
        !           244: #define SHT_SYMTAB     2               /* symbol table section */
        !           245: #define SHT_STRTAB     3               /* string table section */
        !           246: #define SHT_RELA       4               /* relocation section with addends*/
        !           247: #define SHT_HASH       5               /* symbol hash table section */
        !           248: #define SHT_DYNAMIC    6               /* dynamic section */
        !           249: #define SHT_NOTE       7               /* note section */
        !           250: #define SHT_NOBITS     8               /* no space section */
        !           251: #define SHT_REL                9               /* relation section without addends */
        !           252: #define SHT_SHLIB      10              /* reserved - purpose unknown */
        !           253: #define SHT_DYNSYM     11              /* dynamic symbol table section */
        !           254: #define SHT_NUM                12              /* number of section types */
        !           255: #define SHT_LOPROC     0x70000000      /* reserved range for processor */
        !           256: #define SHT_HIPROC     0x7fffffff      /*  specific section header types */
        !           257: #define SHT_LOUSER     0x80000000      /* reserved range for application */
        !           258: #define SHT_HIUSER     0xffffffff      /*  specific indexes */
        !           259:
        !           260: /* Section names */
        !           261: #define ELF_BSS         ".bss"         /* uninitialized data */
        !           262: #define ELF_DATA        ".data"                /* initialized data */
        !           263: #define ELF_DEBUG       ".debug"       /* debug */
        !           264: #define ELF_DYNAMIC     ".dynamic"     /* dynamic linking information */
        !           265: #define ELF_DYNSTR      ".dynstr"      /* dynamic string table */
        !           266: #define ELF_DYNSYM      ".dynsym"      /* dynamic symbol table */
        !           267: #define ELF_FINI        ".fini"                /* termination code */
        !           268: #define ELF_GOT         ".got"         /* global offset table */
        !           269: #define ELF_HASH        ".hash"                /* symbol hash table */
        !           270: #define ELF_INIT        ".init"                /* initialization code */
        !           271: #define ELF_REL_DATA    ".rel.data"    /* relocation data */
        !           272: #define ELF_REL_FINI    ".rel.fini"    /* relocation termination code */
        !           273: #define ELF_REL_INIT    ".rel.init"    /* relocation initialization code */
        !           274: #define ELF_REL_DYN     ".rel.dyn"     /* relocaltion dynamic link info */
        !           275: #define ELF_REL_RODATA  ".rel.rodata"  /* relocation read-only data */
        !           276: #define ELF_REL_TEXT    ".rel.text"    /* relocation code */
        !           277: #define ELF_RODATA      ".rodata"      /* read-only data */
        !           278: #define ELF_SHSTRTAB    ".shstrtab"    /* section header string table */
        !           279: #define ELF_STRTAB      ".strtab"      /* string table */
        !           280: #define ELF_SYMTAB      ".symtab"      /* symbol table */
        !           281: #define ELF_TEXT        ".text"                /* code */
        !           282:
        !           283:
        !           284: /* Section Attribute Flags - sh_flags */
        !           285: #define SHF_WRITE      0x1             /* Writable */
        !           286: #define SHF_ALLOC      0x2             /* occupies memory */
        !           287: #define SHF_EXECINSTR  0x4             /* executable */
        !           288: #define SHF_MASKPROC   0xf0000000      /* reserved bits for processor */
        !           289:                                        /*  specific section attributes */
        !           290:
        !           291: /* Symbol Table Entry */
        !           292: typedef struct elf32_sym {
        !           293:        Elf32_Word      st_name;        /* name - index into string table */
        !           294:        Elf32_Addr      st_value;       /* symbol value */
        !           295:        Elf32_Word      st_size;        /* symbol size */
        !           296:        unsigned char   st_info;        /* type and binding */
        !           297:        unsigned char   st_other;       /* 0 - no defined meaning */
        !           298:        Elf32_Half      st_shndx;       /* section header index */
        !           299: } Elf32_Sym;
        !           300:
        !           301: typedef struct {
        !           302:        Elf64_Half      st_name;        /* Symbol name index in str table */
        !           303:        Elf_Byte        st_info;        /* type / binding attrs */
        !           304:        Elf_Byte        st_other;       /* unused */
        !           305:        Elf64_Quarter   st_shndx;       /* section index of symbol */
        !           306:        Elf64_Xword     st_value;       /* value of symbol */
        !           307:        Elf64_Xword     st_size;        /* size of symbol */
        !           308: } Elf64_Sym;
        !           309:
        !           310: /* Symbol table index */
        !           311: #define STN_UNDEF      0               /* undefined */
        !           312:
        !           313: /* Extract symbol info - st_info */
        !           314: #define ELF32_ST_BIND(x)       ((x) >> 4)
        !           315: #define ELF32_ST_TYPE(x)       (((unsigned int) x) & 0xf)
        !           316: #define ELF32_ST_INFO(b,t)     (((b) << 4) + ((t) & 0xf))
        !           317:
        !           318: #define ELF64_ST_BIND(x)       ((x) >> 4)
        !           319: #define ELF64_ST_TYPE(x)       (((unsigned int) x) & 0xf)
        !           320: #define ELF64_ST_INFO(b,t)     (((b) << 4) + ((t) & 0xf))
        !           321:
        !           322: /* Symbol Binding - ELF32_ST_BIND - st_info */
        !           323: #define STB_LOCAL      0               /* Local symbol */
        !           324: #define STB_GLOBAL     1               /* Global symbol */
        !           325: #define STB_WEAK       2               /* like global - lower precedence */
        !           326: #define STB_NUM                3               /* number of symbol bindings */
        !           327: #define STB_LOPROC     13              /* reserved range for processor */
        !           328: #define STB_HIPROC     15              /*  specific symbol bindings */
        !           329:
        !           330: /* Symbol type - ELF32_ST_TYPE - st_info */
        !           331: #define STT_NOTYPE     0               /* not specified */
        !           332: #define STT_OBJECT     1               /* data object */
        !           333: #define STT_FUNC       2               /* function */
        !           334: #define STT_SECTION    3               /* section */
        !           335: #define STT_FILE       4               /* file */
        !           336: #define STT_NUM                5               /* number of symbol types */
        !           337: #define STT_LOPROC     13              /* reserved range for processor */
        !           338: #define STT_HIPROC     15              /*  specific symbol types */
        !           339:
        !           340: /* Relocation entry with implicit addend */
        !           341: typedef struct {
        !           342:        Elf32_Addr      r_offset;       /* offset of relocation */
        !           343:        Elf32_Word      r_info;         /* symbol table index and type */
        !           344: } Elf32_Rel;
        !           345:
        !           346: /* Relocation entry with explicit addend */
        !           347: typedef struct {
        !           348:        Elf32_Addr      r_offset;       /* offset of relocation */
        !           349:        Elf32_Word      r_info;         /* symbol table index and type */
        !           350:        Elf32_Sword     r_addend;
        !           351: } Elf32_Rela;
        !           352:
        !           353: /* Extract relocation info - r_info */
        !           354: #define ELF32_R_SYM(i)         ((i) >> 8)
        !           355: #define ELF32_R_TYPE(i)                ((unsigned char) (i))
        !           356: #define ELF32_R_INFO(s,t)      (((s) << 8) + (unsigned char)(t))
        !           357:
        !           358: typedef struct {
        !           359:        Elf64_Xword     r_offset;       /* where to do it */
        !           360:        Elf64_Xword     r_info;         /* index & type of relocation */
        !           361: } Elf64_Rel;
        !           362:
        !           363: typedef struct {
        !           364:        Elf64_Xword     r_offset;       /* where to do it */
        !           365:        Elf64_Xword     r_info;         /* index & type of relocation */
        !           366:        Elf64_Sxword    r_addend;       /* adjustment value */
        !           367: } Elf64_Rela;
        !           368:
        !           369: #define        ELF64_R_SYM(info)       ((info) >> 32)
        !           370: #define        ELF64_R_TYPE(info)      ((info) & 0xFFFFFFFF)
        !           371: #define ELF64_R_INFO(s,t)      (((s) << 32) + (__uint32_t)(t))
        !           372:
        !           373: /* Program Header */
        !           374: typedef struct {
        !           375:        Elf32_Word      p_type;         /* segment type */
        !           376:        Elf32_Off       p_offset;       /* segment offset */
        !           377:        Elf32_Addr      p_vaddr;        /* virtual address of segment */
        !           378:        Elf32_Addr      p_paddr;        /* physical address - ignored? */
        !           379:        Elf32_Word      p_filesz;       /* number of bytes in file for seg. */
        !           380:        Elf32_Word      p_memsz;        /* number of bytes in mem. for seg. */
        !           381:        Elf32_Word      p_flags;        /* flags */
        !           382:        Elf32_Word      p_align;        /* memory alignment */
        !           383: } Elf32_Phdr;
        !           384:
        !           385: typedef struct {
        !           386:        Elf64_Half      p_type;         /* entry type */
        !           387:        Elf64_Half      p_flags;        /* flags */
        !           388:        Elf64_Off       p_offset;       /* offset */
        !           389:        Elf64_Addr      p_vaddr;        /* virtual address */
        !           390:        Elf64_Addr      p_paddr;        /* physical address */
        !           391:        Elf64_Xword     p_filesz;       /* file size */
        !           392:        Elf64_Xword     p_memsz;        /* memory size */
        !           393:        Elf64_Xword     p_align;        /* memory & file alignment */
        !           394: } Elf64_Phdr;
        !           395:
        !           396: /* Segment types - p_type */
        !           397: #define PT_NULL                0               /* unused */
        !           398: #define PT_LOAD                1               /* loadable segment */
        !           399: #define PT_DYNAMIC     2               /* dynamic linking section */
        !           400: #define PT_INTERP      3               /* the RTLD */
        !           401: #define PT_NOTE                4               /* auxiliary information */
        !           402: #define PT_SHLIB       5               /* reserved - purpose undefined */
        !           403: #define PT_PHDR                6               /* program header */
        !           404: #define PT_NUM         7               /* Number of segment types */
        !           405: #define PT_LOOS                0x60000000      /* reserved range for OS */
        !           406: #define PT_HIOS                0x6fffffff      /*  specific segment types */
        !           407: #define PT_LOPROC      0x70000000      /* reserved range for processor */
        !           408: #define PT_HIPROC      0x7fffffff      /*  specific segment types */
        !           409:
        !           410: /* Segment flags - p_flags */
        !           411: #define PF_X           0x1             /* Executable */
        !           412: #define PF_W           0x2             /* Writable */
        !           413: #define PF_R           0x4             /* Readable */
        !           414: #define PF_MASKPROC    0xf0000000      /* reserved bits for processor */
        !           415:                                        /*  specific segment flags */
        !           416:
        !           417: /* Dynamic structure */
        !           418: typedef struct {
        !           419:        Elf32_Sword     d_tag;          /* controls meaning of d_val */
        !           420:        union {
        !           421:                Elf32_Word      d_val;  /* Multiple meanings - see d_tag */
        !           422:                Elf32_Addr      d_ptr;  /* program virtual address */
        !           423:        } d_un;
        !           424: } Elf32_Dyn;
        !           425:
        !           426: typedef struct {
        !           427:        Elf64_Xword     d_tag;          /* controls meaning of d_val */
        !           428:        union {
        !           429:                Elf64_Addr      d_ptr;
        !           430:                Elf64_Xword     d_val;
        !           431:        } d_un;
        !           432: } Elf64_Dyn;
        !           433:
        !           434: /* Dynamic Array Tags - d_tag */
        !           435: #define DT_NULL                0               /* marks end of _DYNAMIC array */
        !           436: #define DT_NEEDED      1               /* string table offset of needed lib */
        !           437: #define DT_PLTRELSZ    2               /* size of relocation entries in PLT */
        !           438: #define DT_PLTGOT      3               /* address PLT/GOT */
        !           439: #define DT_HASH                4               /* address of symbol hash table */
        !           440: #define DT_STRTAB      5               /* address of string table */
        !           441: #define DT_SYMTAB      6               /* address of symbol table */
        !           442: #define DT_RELA                7               /* address of relocation table */
        !           443: #define DT_RELASZ      8               /* size of relocation table */
        !           444: #define DT_RELAENT     9               /* size of relocation entry */
        !           445: #define DT_STRSZ       10              /* size of string table */
        !           446: #define DT_SYMENT      11              /* size of symbol table entry */
        !           447: #define DT_INIT                12              /* address of initialization func. */
        !           448: #define DT_FINI                13              /* address of termination function */
        !           449: #define DT_SONAME      14              /* string table offset of shared obj */
        !           450: #define DT_RPATH       15              /* string table offset of library
        !           451:                                           search path */
        !           452: #define DT_SYMBOLIC    16              /* start sym search in shared obj. */
        !           453: #define DT_REL         17              /* address of rel. tbl. w addends */
        !           454: #define DT_RELSZ       18              /* size of DT_REL relocation table */
        !           455: #define DT_RELENT      19              /* size of DT_REL relocation entry */
        !           456: #define DT_PLTREL      20              /* PLT referenced relocation entry */
        !           457: #define DT_DEBUG       21              /* bugger */
        !           458: #define DT_TEXTREL     22              /* Allow rel. mod. to unwritable seg */
        !           459: #define DT_JMPREL      23              /* add. of PLT's relocation entries */
        !           460: #define DT_BIND_NOW    24              /* Bind now regardless of env setting */
        !           461: #define DT_NUM         25              /* Number used. */
        !           462: #define DT_LOPROC      0x70000000      /* reserved range for processor */
        !           463: #define DT_HIPROC      0x7fffffff      /*  specific dynamic array tags */
        !           464:
        !           465: /* Standard ELF hashing function */
        !           466: unsigned int elf_hash(const unsigned char *name);
        !           467:
        !           468: /*
        !           469:  * Note Definitions
        !           470:  */
        !           471: typedef struct {
        !           472:        Elf32_Word namesz;
        !           473:        Elf32_Word descsz;
        !           474:        Elf32_Word type;
        !           475: } Elf32_Note;
        !           476:
        !           477: typedef struct {
        !           478:        Elf64_Half namesz;
        !           479:        Elf64_Half descsz;
        !           480:        Elf64_Half type;
        !           481: } Elf64_Note;
        !           482:
        !           483: /*
        !           484:  * XXX - these _KERNEL items aren't part of the ABI!
        !           485:  */
        !           486: #if defined(_KERNEL) || defined(_DYN_LOADER)
        !           487:
        !           488: #define ELF32_NO_ADDR  ((uint32_t) ~0) /* Indicates addr. not yet filled in */
        !           489: #define ELF_AUX_ENTRIES        8               /* Size of aux array passed to loader */
        !           490:
        !           491: typedef struct {
        !           492:        Elf32_Sword     au_id;                          /* 32-bit id */
        !           493:        Elf32_Word      au_v;                           /* 32-bit value */
        !           494: } Aux32Info;
        !           495:
        !           496: #define ELF64_NO_ADDR  ((__uint64_t) ~0)/* Indicates addr. not yet filled in */
        !           497: #define ELF64_AUX_ENTRIES      8       /* Size of aux array passed to loader */
        !           498:
        !           499: typedef struct {
        !           500:        Elf64_Shalf     au_id;                          /* 32-bit id */
        !           501:        Elf64_Xword     au_v;                           /* 64-bit id */
        !           502: } Aux64Info;
        !           503:
        !           504: enum AuxID {
        !           505:        AUX_null = 0,
        !           506:        AUX_ignore = 1,
        !           507:        AUX_execfd = 2,
        !           508:        AUX_phdr = 3,                   /* &phdr[0] */
        !           509:        AUX_phent = 4,                  /* sizeof(phdr[0]) */
        !           510:        AUX_phnum = 5,                  /* # phdr entries */
        !           511:        AUX_pagesz = 6,                 /* PAGESIZE */
        !           512:        AUX_base = 7,                   /* ld.so base addr */
        !           513:        AUX_flags = 8,                  /* processor flags */
        !           514:        AUX_entry = 9,                  /* a.out entry */
        !           515:        AUX_sun_uid = 2000,             /* euid */
        !           516:        AUX_sun_ruid = 2001,            /* ruid */
        !           517:        AUX_sun_gid = 2002,             /* egid */
        !           518:        AUX_sun_rgid = 2003             /* rgid */
        !           519: };
        !           520:
        !           521: struct elf_args {
        !           522:         u_long  arg_entry;             /* program entry point */
        !           523:         u_long  arg_interp;            /* Interpreter load address */
        !           524:         u_long  arg_phaddr;            /* program header address */
        !           525:         u_long  arg_phentsize;         /* Size of program header */
        !           526:         u_long  arg_phnum;             /* Number of program headers */
        !           527:         u_long  arg_os;                        /* OS tag */
        !           528: };
        !           529:
        !           530: #endif
        !           531:
        !           532: #if !defined(ELFSIZE) && defined(ARCH_ELFSIZE)
        !           533: #define ELFSIZE ARCH_ELFSIZE
        !           534: #endif
        !           535:
        !           536: #if defined(ELFSIZE)
        !           537: #define CONCAT(x,y)    __CONCAT(x,y)
        !           538: #define ELFNAME(x)     CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
        !           539: #define ELFNAME2(x,y)  CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
        !           540: #define ELFNAMEEND(x)  CONCAT(x,CONCAT(_elf,ELFSIZE))
        !           541: #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
        !           542: #endif
        !           543:
        !           544: #if defined(ELFSIZE) && (ELFSIZE == 32)
        !           545: #define Elf_Ehdr       Elf32_Ehdr
        !           546: #define Elf_Phdr       Elf32_Phdr
        !           547: #define Elf_Shdr       Elf32_Shdr
        !           548: #define Elf_Sym                Elf32_Sym
        !           549: #define Elf_Rel                Elf32_Rel
        !           550: #define Elf_RelA       Elf32_Rela
        !           551: #define Elf_Dyn                Elf32_Dyn
        !           552: #define Elf_Half       Elf32_Half
        !           553: #define Elf_Word       Elf32_Word
        !           554: #define Elf_Sword      Elf32_Sword
        !           555: #define Elf_Addr       Elf32_Addr
        !           556: #define Elf_Off                Elf32_Off
        !           557: #define Elf_Nhdr       Elf32_Nhdr
        !           558: #define Elf_Note       Elf32_Note
        !           559:
        !           560: #define ELF_R_SYM      ELF32_R_SYM
        !           561: #define ELF_R_TYPE     ELF32_R_TYPE
        !           562: #define ELF_R_INFO     ELF32_R_INFO
        !           563: #define ELFCLASS       ELFCLASS32
        !           564:
        !           565: #define ELF_ST_BIND    ELF32_ST_BIND
        !           566: #define ELF_ST_TYPE    ELF32_ST_TYPE
        !           567: #define ELF_ST_INFO    ELF32_ST_INFO
        !           568:
        !           569: #define AuxInfo                Aux32Info
        !           570: #elif defined(ELFSIZE) && (ELFSIZE == 64)
        !           571: #define Elf_Ehdr       Elf64_Ehdr
        !           572: #define Elf_Phdr       Elf64_Phdr
        !           573: #define Elf_Shdr       Elf64_Shdr
        !           574: #define Elf_Sym                Elf64_Sym
        !           575: #define Elf_Rel                Elf64_Rel
        !           576: #define Elf_RelA       Elf64_Rela
        !           577: #define Elf_Dyn                Elf64_Dyn
        !           578: #define Elf_Half       Elf64_Half
        !           579: #define Elf_Word       Elf64_Word
        !           580: #define Elf_Sword      Elf64_Sword
        !           581: #define Elf_Addr       Elf64_Addr
        !           582: #define Elf_Off                Elf64_Off
        !           583: #define Elf_Nhdr       Elf64_Nhdr
        !           584: #define Elf_Note       Elf64_Note
        !           585:
        !           586: #define ELF_R_SYM      ELF64_R_SYM
        !           587: #define ELF_R_TYPE     ELF64_R_TYPE
        !           588: #define ELF_R_INFO     ELF64_R_INFO
        !           589: #define ELFCLASS       ELFCLASS64
        !           590:
        !           591: #define ELF_ST_BIND    ELF64_ST_BIND
        !           592: #define ELF_ST_TYPE    ELF64_ST_TYPE
        !           593: #define ELF_ST_INFO    ELF64_ST_INFO
        !           594:
        !           595: #define AuxInfo                Aux64Info
        !           596: #endif
        !           597:
        !           598: #ifndef _KERNEL
        !           599: extern Elf_Dyn         _DYNAMIC[];
        !           600: #endif
        !           601:
        !           602: #ifdef _KERNEL
        !           603: #ifdef _KERN_DO_ELF64
        !           604: int exec_elf64_makecmds(struct proc *, struct exec_package *);
        !           605: void *elf64_copyargs(struct exec_package *, struct ps_strings *,
        !           606:         void *, void *);
        !           607: int exec_elf64_fixup(struct proc *, struct exec_package *);
        !           608: char *elf64_check_brand(Elf64_Ehdr *);
        !           609: int elf64_os_pt_note(struct proc *, struct exec_package *, Elf64_Ehdr *,
        !           610:        char *, size_t, size_t);
        !           611: #endif
        !           612: #ifdef _KERN_DO_ELF
        !           613: int exec_elf32_makecmds(struct proc *, struct exec_package *);
        !           614: void *elf32_copyargs(struct exec_package *, struct ps_strings *,
        !           615:         void *, void *);
        !           616: int exec_elf32_fixup(struct proc *, struct exec_package *);
        !           617: char *elf32_check_brand(Elf32_Ehdr *);
        !           618: int elf32_os_pt_note(struct proc *, struct exec_package *, Elf32_Ehdr *,
        !           619:        char *, size_t, size_t);
        !           620: #endif
        !           621:
        !           622: #endif /* _KERNEL */
        !           623:
        !           624: #define ELF_TARG_VER   1       /* The ver for which this code is intended */
        !           625:
        !           626: #endif /* _SYS_EXEC_ELF_H_ */

CVSweb