The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/exec_elf.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: exec_elf.h,v 1.81 2005/02/26 22:25:34 perry Exp $      */
    2 
    3 /*-
    4  * Copyright (c) 1994 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Christos Zoulas.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *      This product includes software developed by the NetBSD
   21  *      Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 #ifndef _SYS_EXEC_ELF_H_
   40 #define _SYS_EXEC_ELF_H_
   41 
   42 /*
   43  * The current ELF ABI specification is available at:
   44  *      http://www.sco.com/developers/gabi/
   45  *
   46  * Current header definitions are in:
   47  *      http://www.sco.com/developers/gabi/latest/ch4.eheader.html
   48  */
   49 
   50 #if defined(_KERNEL) || defined(_STANDALONE)
   51 #include <sys/types.h>
   52 #else
   53 #include <inttypes.h>
   54 #endif /* _KERNEL || _STANDALONE */
   55 
   56 #include <machine/elf_machdep.h>
   57 
   58 typedef uint8_t         Elf_Byte;
   59 
   60 typedef uint32_t        Elf32_Addr;
   61 #define ELF32_FSZ_ADDR  4
   62 typedef uint32_t        Elf32_Off;
   63 #define ELF32_FSZ_OFF   4
   64 typedef int32_t         Elf32_Sword;
   65 #define ELF32_FSZ_SWORD 4
   66 typedef uint32_t        Elf32_Word;
   67 #define ELF32_FSZ_WORD  4
   68 typedef uint16_t        Elf32_Half;
   69 #define ELF32_FSZ_HALF  2
   70 
   71 typedef uint64_t        Elf64_Addr;
   72 #define ELF64_FSZ_ADDR  8
   73 typedef uint64_t        Elf64_Off;
   74 #define ELF64_FSZ_OFF   8
   75 typedef int32_t         Elf64_Shalf;
   76 #define ELF64_FSZ_SHALF 4
   77 
   78 #ifndef ELF64_FSZ_SWORD
   79 typedef int32_t         Elf64_Sword;
   80 #define ELF64_FSZ_SWORD 4
   81 #endif /* ELF64_FSZ_SWORD */
   82 #ifndef ELF64_FSZ_WORD
   83 typedef uint32_t        Elf64_Word;
   84 #define ELF64_FSZ_WORD  4
   85 #endif /* ELF64_FSZ_WORD */
   86 
   87 typedef int64_t         Elf64_Sxword;
   88 #define ELF64_FSZ_XWORD 8
   89 typedef uint64_t        Elf64_Xword;
   90 #define ELF64_FSZ_XWORD 8
   91 typedef uint32_t        Elf64_Half;
   92 #define ELF64_FSZ_HALF  4
   93 typedef uint16_t        Elf64_Quarter;
   94 #define ELF64_FSZ_QUARTER 2
   95 
   96 /*
   97  * ELF Header
   98  */
   99 #define ELF_NIDENT      16
  100 
  101 typedef struct {
  102         unsigned char   e_ident[ELF_NIDENT];    /* Id bytes */
  103         Elf32_Half      e_type;                 /* file type */
  104         Elf32_Half      e_machine;              /* machine type */
  105         Elf32_Word      e_version;              /* version number */
  106         Elf32_Addr      e_entry;                /* entry point */
  107         Elf32_Off       e_phoff;                /* Program hdr offset */
  108         Elf32_Off       e_shoff;                /* Section hdr offset */
  109         Elf32_Word      e_flags;                /* Processor flags */
  110         Elf32_Half      e_ehsize;               /* sizeof ehdr */
  111         Elf32_Half      e_phentsize;            /* Program header entry size */
  112         Elf32_Half      e_phnum;                /* Number of program headers */
  113         Elf32_Half      e_shentsize;            /* Section header entry size */
  114         Elf32_Half      e_shnum;                /* Number of section headers */
  115         Elf32_Half      e_shstrndx;             /* String table index */
  116 } Elf32_Ehdr;
  117 
  118 typedef struct {
  119         unsigned char   e_ident[ELF_NIDENT];    /* Id bytes */
  120         Elf64_Quarter   e_type;                 /* file type */
  121         Elf64_Quarter   e_machine;              /* machine type */
  122         Elf64_Half      e_version;              /* version number */
  123         Elf64_Addr      e_entry;                /* entry point */
  124         Elf64_Off       e_phoff;                /* Program hdr offset */
  125         Elf64_Off       e_shoff;                /* Section hdr offset */
  126         Elf64_Half      e_flags;                /* Processor flags */
  127         Elf64_Quarter   e_ehsize;               /* sizeof ehdr */
  128         Elf64_Quarter   e_phentsize;            /* Program header entry size */
  129         Elf64_Quarter   e_phnum;                /* Number of program headers */
  130         Elf64_Quarter   e_shentsize;            /* Section header entry size */
  131         Elf64_Quarter   e_shnum;                /* Number of section headers */
  132         Elf64_Quarter   e_shstrndx;             /* String table index */
  133 } Elf64_Ehdr;
  134 
  135 /* e_ident offsets */
  136 #define EI_MAG0         0       /* '\177' */
  137 #define EI_MAG1         1       /* 'E'    */
  138 #define EI_MAG2         2       /* 'L'    */
  139 #define EI_MAG3         3       /* 'F'    */
  140 #define EI_CLASS        4       /* File class */
  141 #define EI_DATA         5       /* Data encoding */
  142 #define EI_VERSION      6       /* File version */
  143 #define EI_OSABI        7       /* Operating system/ABI identification */
  144 #define EI_ABIVERSION   8       /* ABI version */
  145 #define EI_PAD          9       /* Start of padding bytes up to EI_NIDENT*/
  146 #define EI_NIDENT       16      /* First non-ident header byte */
  147 
  148 /* e_ident[EI_MAG0,EI_MAG3] */
  149 #define ELFMAG0         0x7f
  150 #define ELFMAG1         'E'
  151 #define ELFMAG2         'L'
  152 #define ELFMAG3         'F'
  153 #define ELFMAG          "\177ELF"
  154 #define SELFMAG         4
  155 
  156 /* e_ident[EI_CLASS] */
  157 #define ELFCLASSNONE    0       /* Invalid class */
  158 #define ELFCLASS32      1       /* 32-bit objects */
  159 #define ELFCLASS64      2       /* 64-bit objects */
  160 #define ELFCLASSNUM     3
  161 
  162 /* e_ident[EI_DATA] */
  163 #define ELFDATANONE     0       /* Invalid data encoding */
  164 #define ELFDATA2LSB     1       /* 2's complement values, LSB first */
  165 #define ELFDATA2MSB     2       /* 2's complement values, MSB first */
  166 
  167 /* e_ident[EI_VERSION] */
  168 #define EV_NONE         0       /* Invalid version */
  169 #define EV_CURRENT      1       /* Current version */
  170 #define EV_NUM          2
  171 
  172 /* e_ident[EI_OSABI] */
  173 #define ELFOSABI_SYSV           0       /* UNIX System V ABI */
  174 #define ELFOSABI_HPUX           1       /* HP-UX operating system */
  175 #define ELFOSABI_NETBSD         2       /* NetBSD */
  176 #define ELFOSABI_LINUX          3       /* GNU/Linux */
  177 #define ELFOSABI_HURD           4       /* GNU/Hurd */
  178 #define ELFOSABI_86OPEN         5       /* 86Open */
  179 #define ELFOSABI_SOLARIS        6       /* Solaris */
  180 #define ELFOSABI_MONTEREY       7       /* Monterey */
  181 #define ELFOSABI_IRIX           8       /* IRIX */
  182 #define ELFOSABI_FREEBSD        9       /* FreeBSD */
  183 #define ELFOSABI_TRU64          10      /* TRU64 UNIX */
  184 #define ELFOSABI_MODESTO        11      /* Novell Modesto */
  185 #define ELFOSABI_OPENBSD        12      /* OpenBSD */
  186 /* Unofficial OSABIs follow */
  187 #define ELFOSABI_ARM            97      /* ARM */
  188 #define ELFOSABI_STANDALONE     255     /* Standalone (embedded) application */
  189 
  190 /* e_type */
  191 #define ET_NONE         0       /* No file type */
  192 #define ET_REL          1       /* Relocatable file */
  193 #define ET_EXEC         2       /* Executable file */
  194 #define ET_DYN          3       /* Shared object file */
  195 #define ET_CORE         4       /* Core file */
  196 #define ET_NUM          5
  197 
  198 #define ET_LOOS         0xfe00  /* Operating system specific range */
  199 #define ET_HIOS         0xfeff
  200 #define ET_LOPROC       0xff00  /* Processor-specific range */
  201 #define ET_HIPROC       0xffff
  202 
  203 /* e_machine */
  204 #define EM_NONE         0       /* No machine */
  205 #define EM_M32          1       /* AT&T WE 32100 */
  206 #define EM_SPARC        2       /* SPARC */
  207 #define EM_386          3       /* Intel 80386 */
  208 #define EM_68K          4       /* Motorola 68000 */
  209 #define EM_88K          5       /* Motorola 88000 */
  210 #define EM_486          6       /* Intel 80486 */
  211 #define EM_860          7       /* Intel 80860 */
  212 #define EM_MIPS         8       /* MIPS I Architecture */
  213 #define EM_S370         9       /* Amdahl UTS on System/370 */
  214 #define EM_MIPS_RS3_LE  10      /* MIPS RS3000 Little-endian */
  215                         /* 11-14 - Reserved */
  216 #define EM_RS6000       11      /* IBM RS/6000 XXX reserved */
  217 #define EM_PARISC       15      /* Hewlett-Packard PA-RISC */
  218 #define EM_NCUBE        16      /* NCube XXX reserved */
  219 #define EM_VPP500       17      /* Fujitsu VPP500 */
  220 #define EM_SPARC32PLUS  18      /* Enhanced instruction set SPARC */
  221 #define EM_960          19      /* Intel 80960 */
  222 #define EM_PPC          20      /* PowerPC */
  223 #define EM_PPC64        21      /* 64-bit PowerPC */
  224                         /* 22-35 - Reserved */
  225 #define EM_V800         36      /* NEC V800 */
  226 #define EM_FR20         37      /* Fujitsu FR20 */
  227 #define EM_RH32         38      /* TRW RH-32 */
  228 #define EM_RCE          39      /* Motorola RCE */
  229 #define EM_ARM          40      /* Advanced RISC Machines ARM */
  230 #define EM_ALPHA        41      /* DIGITAL Alpha */
  231 #define EM_SH           42      /* Hitachi Super-H */
  232 #define EM_SPARCV9      43      /* SPARC Version 9 */
  233 #define EM_TRICORE      44      /* Siemens Tricore */
  234 #define EM_ARC          45      /* Argonaut RISC Core */
  235 #define EM_H8_300       46      /* Hitachi H8/300 */
  236 #define EM_H8_300H      47      /* Hitachi H8/300H */
  237 #define EM_H8S          48      /* Hitachi H8S */
  238 #define EM_H8_500       49      /* Hitachi H8/500 */
  239 #define EM_IA_64        50      /* Intel Merced Processor */
  240 #define EM_MIPS_X       51      /* Stanford MIPS-X */
  241 #define EM_COLDFIRE     52      /* Motorola Coldfire */
  242 #define EM_68HC12       53      /* Motorola MC68HC12 */
  243 #define EM_MMA          54      /* Fujitsu MMA Multimedia Accelerator */
  244 #define EM_PCP          55      /* Siemens PCP */
  245 #define EM_NCPU         56      /* Sony nCPU embedded RISC processor */
  246 #define EM_NDR1         57      /* Denso NDR1 microprocessor */
  247 #define EM_STARCORE     58      /* Motorola Star*Core processor */
  248 #define EM_ME16         59      /* Toyota ME16 processor */
  249 #define EM_ST100        60      /* STMicroelectronics ST100 processor */
  250 #define EM_TINYJ        61      /* Advanced Logic Corp. TinyJ embedded family processor */
  251 #define EM_X86_64       62      /* AMD x86-64 architecture */
  252 #define EM_PDSP         63      /* Sony DSP Processor */
  253 #define EM_PDP10        64      /* Digital Equipment Corp. PDP-10 */
  254 #define EM_PDP11        65      /* Digital Equipment Corp. PDP-11 */
  255 #define EM_FX66         66      /* Siemens FX66 microcontroller */
  256 #define EM_ST9PLUS      67      /* STMicroelectronics ST9+ 8/16 bit microcontroller */
  257 #define EM_ST7          68      /* STMicroelectronics ST7 8-bit microcontroller */
  258 #define EM_68HC16       69      /* Motorola MC68HC16 Microcontroller */
  259 #define EM_68HC11       70      /* Motorola MC68HC11 Microcontroller */
  260 #define EM_68HC08       71      /* Motorola MC68HC08 Microcontroller */
  261 #define EM_68HC05       72      /* Motorola MC68HC05 Microcontroller */
  262 #define EM_SVX          73      /* Silicon Graphics SVx */
  263 #define EM_ST19         74      /* STMicroelectronics ST19 8-bit CPU */
  264 #define EM_VAX          75      /* Digital VAX */
  265 #define EM_CRIS         76      /* Axis Communications 32-bit embedded processor */
  266 #define EM_JAVELIN      77      /* Infineon Technologies 32-bit embedded CPU */
  267 #define EM_FIREPATH     78      /* Element 14 64-bit DSP processor */
  268 #define EM_ZSP          79      /* LSI Logic's 16-bit DSP processor */
  269 #define EM_MMIX         80      /* Donald Knuth's educational 64-bit processor */
  270 #define EM_HUANY        81      /* Harvard's machine-independent format */
  271 #define EM_PRISM        82      /* SiTera Prism */
  272 #define EM_AVR          83      /* Atmel AVR 8-bit microcontroller */
  273 #define EM_FR30         84      /* Fujitsu FR30 */
  274 #define EM_D10V         85      /* Mitsubishi D10V */
  275 #define EM_D30V         86      /* Mitsubishi D30V */
  276 #define EM_V850         87      /* NEC v850 */
  277 #define EM_M32R         88      /* Mitsubishi M32R */
  278 #define EM_MN10300      89      /* Matsushita MN10300 */
  279 #define EM_MN10200      90      /* Matsushita MN10200 */
  280 #define EM_PJ           91      /* picoJava */
  281 #define EM_OPENRISC     92      /* OpenRISC 32-bit embedded processor */
  282 #define EM_ARC_A5       93      /* ARC Cores Tangent-A5 */
  283 #define EM_XTENSA       94      /* Tensilica Xtensa Architecture */
  284 #define EM_NS32K        97      /* National Semiconductor 32000 series */
  285 
  286 /* Unofficial machine types follow */
  287 #define EM_ALPHA_EXP    36902   /* used by NetBSD/alpha; obsolete */
  288 #define EM_NUM          36903
  289 
  290 /*
  291  * Program Header
  292  */
  293 typedef struct {
  294         Elf32_Word      p_type;         /* entry type */
  295         Elf32_Off       p_offset;       /* offset */
  296         Elf32_Addr      p_vaddr;        /* virtual address */
  297         Elf32_Addr      p_paddr;        /* physical address */
  298         Elf32_Word      p_filesz;       /* file size */
  299         Elf32_Word      p_memsz;        /* memory size */
  300         Elf32_Word      p_flags;        /* flags */
  301         Elf32_Word      p_align;        /* memory & file alignment */
  302 } Elf32_Phdr;
  303 
  304 typedef struct {
  305         Elf64_Half      p_type;         /* entry type */
  306         Elf64_Half      p_flags;        /* flags */
  307         Elf64_Off       p_offset;       /* offset */
  308         Elf64_Addr      p_vaddr;        /* virtual address */
  309         Elf64_Addr      p_paddr;        /* physical address */
  310         Elf64_Xword     p_filesz;       /* file size */
  311         Elf64_Xword     p_memsz;        /* memory size */
  312         Elf64_Xword     p_align;        /* memory & file alignment */
  313 } Elf64_Phdr;
  314 
  315 /* p_type */
  316 #define PT_NULL         0               /* Program header table entry unused */
  317 #define PT_LOAD         1               /* Loadable program segment */
  318 #define PT_DYNAMIC      2               /* Dynamic linking information */
  319 #define PT_INTERP       3               /* Program interpreter */
  320 #define PT_NOTE         4               /* Auxiliary information */
  321 #define PT_SHLIB        5               /* Reserved, unspecified semantics */
  322 #define PT_PHDR         6               /* Entry for header table itself */
  323 #define PT_NUM          7
  324 
  325 #define PT_LOOS         0x60000000      /* OS-specific range */
  326 #define PT_HIOS         0x6fffffff
  327 #define PT_LOPROC       0x70000000      /* Processor-specific range */
  328 #define PT_HIPROC       0x7fffffff
  329 
  330 #define PT_MIPS_REGINFO 0x70000000
  331 
  332 /* p_flags */
  333 #define PF_R            0x4     /* Segment is readable */
  334 #define PF_W            0x2     /* Segment is writable */
  335 #define PF_X            0x1     /* Segment is executable */
  336 
  337 #define PF_MASKOS       0x0ff00000      /* Operating system specific values */
  338 #define PF_MASKPROC     0xf0000000      /* Processor-specific values */
  339 
  340 /*
  341  * Section Headers
  342  */
  343 typedef struct {
  344         Elf32_Word      sh_name;        /* section name (.shstrtab index) */
  345         Elf32_Word      sh_type;        /* section type */
  346         Elf32_Word      sh_flags;       /* section flags */
  347         Elf32_Addr      sh_addr;        /* virtual address */
  348         Elf32_Off       sh_offset;      /* file offset */
  349         Elf32_Word      sh_size;        /* section size */
  350         Elf32_Word      sh_link;        /* link to another */
  351         Elf32_Word      sh_info;        /* misc info */
  352         Elf32_Word      sh_addralign;   /* memory alignment */
  353         Elf32_Word      sh_entsize;     /* table entry size */
  354 } Elf32_Shdr;
  355 
  356 typedef struct {
  357         Elf64_Half      sh_name;        /* section name (.shstrtab index) */
  358         Elf64_Half      sh_type;        /* section type */
  359         Elf64_Xword     sh_flags;       /* section flags */
  360         Elf64_Addr      sh_addr;        /* virtual address */
  361         Elf64_Off       sh_offset;      /* file offset */
  362         Elf64_Xword     sh_size;        /* section size */
  363         Elf64_Half      sh_link;        /* link to another */
  364         Elf64_Half      sh_info;        /* misc info */
  365         Elf64_Xword     sh_addralign;   /* memory alignment */
  366         Elf64_Xword     sh_entsize;     /* table entry size */
  367 } Elf64_Shdr;
  368 
  369 /* sh_type */
  370 #define SHT_NULL        0               /* Section header table entry unused */
  371 #define SHT_PROGBITS    1               /* Program information */
  372 #define SHT_SYMTAB      2               /* Symbol table */
  373 #define SHT_STRTAB      3               /* String table */
  374 #define SHT_RELA        4               /* Relocation information w/ addend */
  375 #define SHT_HASH        5               /* Symbol hash table */
  376 #define SHT_DYNAMIC     6               /* Dynamic linking information */
  377 #define SHT_NOTE        7               /* Auxiliary information */
  378 #define SHT_NOBITS      8               /* No space allocated in file image */
  379 #define SHT_REL         9               /* Relocation information w/o addend */
  380 #define SHT_SHLIB       10              /* Reserved, unspecified semantics */
  381 #define SHT_DYNSYM      11              /* Symbol table for dynamic linker */
  382 #define SHT_NUM         12
  383 
  384 #define SHT_LOOS        0x60000000      /* Operating system specific range */
  385 #define SHT_HIOS        0x6fffffff
  386 #define SHT_LOPROC      0x70000000      /* Processor-specific range */
  387 #define SHT_HIPROC      0x7fffffff
  388 #define SHT_LOUSER      0x80000000      /* Application-specific range */
  389 #define SHT_HIUSER      0xffffffff
  390 
  391 /* sh_flags */
  392 #define SHF_WRITE       0x1             /* Section contains writable data */
  393 #define SHF_ALLOC       0x2             /* Section occupies memory */
  394 #define SHF_EXECINSTR   0x4             /* Section contains executable insns */
  395 
  396 #define SHF_MASKOS      0x0f000000      /* Operating system specific values */
  397 #define SHF_MASKPROC    0xf0000000      /* Processor-specific values */
  398 
  399 /*
  400  * Symbol Table
  401  */
  402 typedef struct {
  403         Elf32_Word      st_name;        /* Symbol name (.symtab index) */
  404         Elf32_Word      st_value;       /* value of symbol */
  405         Elf32_Word      st_size;        /* size of symbol */
  406         Elf_Byte        st_info;        /* type / binding attrs */
  407         Elf_Byte        st_other;       /* unused */
  408         Elf32_Half      st_shndx;       /* section index of symbol */
  409 } Elf32_Sym;
  410 
  411 typedef struct {
  412         Elf64_Half      st_name;        /* Symbol name (.symtab index) */
  413         Elf_Byte        st_info;        /* type / binding attrs */
  414         Elf_Byte        st_other;       /* unused */
  415         Elf64_Quarter   st_shndx;       /* section index of symbol */
  416         Elf64_Addr      st_value;       /* value of symbol */
  417         Elf64_Xword     st_size;        /* size of symbol */
  418 } Elf64_Sym;
  419 
  420 /* Symbol Table index of the undefined symbol */
  421 #define ELF_SYM_UNDEFINED       0
  422 
  423 #define STN_UNDEF               0       /* undefined index */
  424 
  425 /* st_info: Symbol Bindings */
  426 #define STB_LOCAL               0       /* local symbol */
  427 #define STB_GLOBAL              1       /* global symbol */
  428 #define STB_WEAK                2       /* weakly defined global symbol */
  429 #define STB_NUM                 3
  430 
  431 #define STB_LOOS                10      /* Operating system specific range */
  432 #define STB_HIOS                12
  433 #define STB_LOPROC              13      /* Processor-specific range */
  434 #define STB_HIPROC              15
  435 
  436 /* st_info: Symbol Types */
  437 #define STT_NOTYPE              0       /* Type not specified */
  438 #define STT_OBJECT              1       /* Associated with a data object */
  439 #define STT_FUNC                2       /* Associated with a function */
  440 #define STT_SECTION             3       /* Associated with a section */
  441 #define STT_FILE                4       /* Associated with a file name */
  442 #define STT_NUM                 5
  443 
  444 #define STT_LOOS                10      /* Operating system specific range */
  445 #define STT_HIOS                12
  446 #define STT_LOPROC              13      /* Processor-specific range */
  447 #define STT_HIPROC              15
  448 
  449 /* st_other: Visibility Types */
  450 #define STV_DEFAULT             0       /* use binding type */
  451 #define STV_INTERNAL            1       /* not referenced from outside */
  452 #define STV_HIDDEN              2       /* not visible, may be used via ptr */
  453 #define STV_PROTECTED           3       /* visible, not preemptible */
  454 
  455 /* st_info/st_other utility macros */
  456 #define ELF_ST_BIND(info)               ((uint32_t)(info) >> 4)
  457 #define ELF_ST_TYPE(info)               ((uint32_t)(info) & 0xf)
  458 #define ELF_ST_INFO(bind,type)          ((Elf_Byte)(((bind) << 4) | \
  459                                          ((type) & 0xf)))
  460 #define ELF_ST_VISIBILITY(other)        ((uint32_t)(other) & 3)
  461 
  462 /*
  463  * Special section indexes
  464  */
  465 #define SHN_UNDEF       0               /* Undefined section */
  466 
  467 #define SHN_LORESERVE   0xff00          /* Reserved range */
  468 #define SHN_ABS         0xfff1          /*  Absolute symbols */
  469 #define SHN_COMMON      0xfff2          /*  Common symbols */
  470 #define SHN_HIRESERVE   0xffff
  471 
  472 #define SHN_LOPROC      0xff00          /* Processor-specific range */
  473 #define SHN_HIPROC      0xff1f
  474 #define SHN_LOOS        0xff20          /* Operating system specific range */
  475 #define SHN_HIOS        0xff3f
  476 
  477 #define SHN_MIPS_ACOMMON 0xff00
  478 #define SHN_MIPS_TEXT   0xff01
  479 #define SHN_MIPS_DATA   0xff02
  480 #define SHN_MIPS_SCOMMON 0xff03
  481 
  482 /*
  483  * Relocation Entries
  484  */
  485 typedef struct {
  486         Elf32_Word      r_offset;       /* where to do it */
  487         Elf32_Word      r_info;         /* index & type of relocation */
  488 } Elf32_Rel;
  489 
  490 typedef struct {
  491         Elf32_Word      r_offset;       /* where to do it */
  492         Elf32_Word      r_info;         /* index & type of relocation */
  493         Elf32_Sword     r_addend;       /* adjustment value */
  494 } Elf32_Rela;
  495 
  496 /* r_info utility macros */
  497 #define ELF32_R_SYM(info)       ((info) >> 8)
  498 #define ELF32_R_TYPE(info)      ((info) & 0xff)
  499 #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
  500 
  501 typedef struct {
  502         Elf64_Addr      r_offset;       /* where to do it */
  503         Elf64_Xword     r_info;         /* index & type of relocation */
  504 } Elf64_Rel;
  505 
  506 typedef struct {
  507         Elf64_Addr      r_offset;       /* where to do it */
  508         Elf64_Xword     r_info;         /* index & type of relocation */
  509         Elf64_Sxword    r_addend;       /* adjustment value */
  510 } Elf64_Rela;
  511 
  512 /* r_info utility macros */
  513 #define ELF64_R_SYM(info)       ((info) >> 32)
  514 #define ELF64_R_TYPE(info)      ((info) & 0xffffffff)
  515 #define ELF64_R_INFO(sym,type)  (((sym) << 32) + (type))
  516 
  517 /*
  518  * Dynamic Section structure array
  519  */
  520 typedef struct {
  521         Elf32_Word      d_tag;          /* entry tag value */
  522         union {
  523             Elf32_Addr  d_ptr;
  524             Elf32_Word  d_val;
  525         } d_un;
  526 } Elf32_Dyn;
  527 
  528 typedef struct {
  529         Elf64_Xword     d_tag;          /* entry tag value */
  530         union {
  531             Elf64_Addr  d_ptr;
  532             Elf64_Xword d_val;
  533         } d_un;
  534 } Elf64_Dyn;
  535 
  536 /* d_tag */
  537 #define DT_NULL         0       /* Marks end of dynamic array */
  538 #define DT_NEEDED       1       /* Name of needed library (DT_STRTAB offset) */
  539 #define DT_PLTRELSZ     2       /* Size, in bytes, of relocations in PLT */
  540 #define DT_PLTGOT       3       /* Address of PLT and/or GOT */
  541 #define DT_HASH         4       /* Address of symbol hash table */
  542 #define DT_STRTAB       5       /* Address of string table */
  543 #define DT_SYMTAB       6       /* Address of symbol table */
  544 #define DT_RELA         7       /* Address of Rela relocation table */
  545 #define DT_RELASZ       8       /* Size, in bytes, of DT_RELA table */
  546 #define DT_RELAENT      9       /* Size, in bytes, of one DT_RELA entry */
  547 #define DT_STRSZ        10      /* Size, in bytes, of DT_STRTAB table */
  548 #define DT_SYMENT       11      /* Size, in bytes, of one DT_SYMTAB entry */
  549 #define DT_INIT         12      /* Address of initialization function */
  550 #define DT_FINI         13      /* Address of termination function */
  551 #define DT_SONAME       14      /* Shared object name (DT_STRTAB offset) */
  552 #define DT_RPATH        15      /* Library search path (DT_STRTAB offset) */
  553 #define DT_SYMBOLIC     16      /* Start symbol search within local object */
  554 #define DT_REL          17      /* Address of Rel relocation table */
  555 #define DT_RELSZ        18      /* Size, in bytes, of DT_REL table */
  556 #define DT_RELENT       19      /* Size, in bytes, of one DT_REL entry */
  557 #define DT_PLTREL       20      /* Type of PLT relocation entries */
  558 #define DT_DEBUG        21      /* Used for debugging; unspecified */
  559 #define DT_TEXTREL      22      /* Relocations might modify non-writable seg */
  560 #define DT_JMPREL       23      /* Address of relocations associated with PLT */
  561 #define DT_BIND_NOW     24      /* Process all relocations at load-time */
  562 #define DT_INIT_ARRAY   25      /* Address of initialization function array */
  563 #define DT_FINI_ARRAY   26      /* Size, in bytes, of DT_INIT_ARRAY array */
  564 #define DT_INIT_ARRAYSZ 27      /* Address of termination function array */
  565 #define DT_FINI_ARRAYSZ 28      /* Size, in bytes, of DT_FINI_ARRAY array*/
  566 #define DT_NUM          29
  567 
  568 #define DT_LOOS         0x60000000      /* Operating system specific range */
  569 #define DT_HIOS         0x6fffffff
  570 #define DT_LOPROC       0x70000000      /* Processor-specific range */
  571 #define DT_HIPROC       0x7fffffff
  572 
  573 /*
  574  * Auxiliary Vectors
  575  */
  576 typedef struct {
  577         Elf32_Word      a_type;                         /* 32-bit id */
  578         Elf32_Word      a_v;                            /* 32-bit id */
  579 } Aux32Info;
  580 
  581 typedef struct {
  582         Elf64_Half      a_type;                         /* 32-bit id */
  583         Elf64_Xword     a_v;                            /* 64-bit id */
  584 } Aux64Info;
  585 
  586 /* a_type */
  587 #define AT_NULL         0       /* Marks end of array */
  588 #define AT_IGNORE       1       /* No meaning, a_un is undefined */
  589 #define AT_EXECFD       2       /* Open file descriptor of object file */
  590 #define AT_PHDR         3       /* &phdr[0] */
  591 #define AT_PHENT        4       /* sizeof(phdr[0]) */
  592 #define AT_PHNUM        5       /* # phdr entries */
  593 #define AT_PAGESZ       6       /* PAGESIZE */
  594 #define AT_BASE         7       /* Interpreter base addr */
  595 #define AT_FLAGS        8       /* Processor flags */
  596 #define AT_ENTRY        9       /* Entry address of executable */
  597 #define AT_DCACHEBSIZE  10      /* Data cache block size */
  598 #define AT_ICACHEBSIZE  11      /* Instruction cache block size */
  599 #define AT_UCACHEBSIZE  12      /* Unified cache block size */
  600 
  601         /* Vendor specific */
  602 #define AT_MIPS_NOTELF  10      /* XXX a_val != 0 -> MIPS XCOFF executable */
  603 
  604 #define AT_EUID         2000    /* euid (solaris compatible numbers) */
  605 #define AT_RUID         2001    /* ruid (solaris compatible numbers) */
  606 #define AT_EGID         2002    /* egid (solaris compatible numbers) */
  607 #define AT_RGID         2003    /* rgid (solaris compatible numbers) */
  608 
  609         /* Solaris kernel specific */
  610 #define AT_SUN_LDELF    2004    /* dynamic linker's ELF header */
  611 #define AT_SUN_LDSHDR   2005    /* dynamic linker's section header */
  612 #define AT_SUN_LDNAME   2006    /* dynamic linker's name */
  613 #define AT_SUN_LPGSIZE  2007    /* large pagesize */
  614 
  615         /* Other information */
  616 #define AT_SUN_PLATFORM 2008    /* sysinfo(SI_PLATFORM) */
  617 #define AT_SUN_HWCAP    2009    /* process hardware capabilities */
  618 #define AT_SUN_IFLUSH   2010    /* do we need to flush the instruction cache? */
  619 #define AT_SUN_CPU      2011    /* CPU name */
  620         /* ibcs2 emulation band aid */
  621 #define AT_SUN_EMUL_ENTRY 2012  /* coff entry point */
  622 #define AT_SUN_EMUL_EXECFD 2013 /* coff file descriptor */
  623         /* Executable's fully resolved name */
  624 #define AT_SUN_EXECNAME 2014
  625 
  626 /*
  627  * Note Headers
  628  */
  629 typedef struct {
  630         Elf32_Word n_namesz;
  631         Elf32_Word n_descsz;
  632         Elf32_Word n_type;
  633 } Elf32_Nhdr;
  634 
  635 typedef struct {
  636         Elf64_Half n_namesz;
  637         Elf64_Half n_descsz;
  638         Elf64_Half n_type;
  639 } Elf64_Nhdr;
  640 
  641 #define ELF_NOTE_TYPE_ABI_TAG           1
  642 
  643 /* GNU-specific note name and description sizes */
  644 #define ELF_NOTE_ABI_NAMESZ             4
  645 #define ELF_NOTE_ABI_DESCSZ             16
  646 /* GNU-specific note name */
  647 #define ELF_NOTE_ABI_NAME               "GNU\0"
  648 
  649 /* GNU-specific OS/version value stuff */
  650 #define ELF_NOTE_ABI_OS_LINUX           0
  651 #define ELF_NOTE_ABI_OS_HURD            1
  652 #define ELF_NOTE_ABI_OS_SOLARIS         2
  653 
  654 /* NetBSD-specific note type: Emulation name.  desc is emul name string. */
  655 #define ELF_NOTE_TYPE_NETBSD_TAG        1
  656 
  657 /* NetBSD-specific note name and description sizes */
  658 #define ELF_NOTE_NETBSD_NAMESZ          7
  659 #define ELF_NOTE_NETBSD_DESCSZ          4
  660 /* NetBSD-specific note name */
  661 #define ELF_NOTE_NETBSD_NAME            "NetBSD\0\0"
  662 
  663 /*
  664  * NetBSD-specific core file information.
  665  *
  666  * NetBSD ELF core files use notes to provide information about
  667  * the process's state.  The note name is "NetBSD-CORE" for
  668  * information that is global to the process, and "NetBSD-CORE@nn",
  669  * where "nn" is the lwpid of the LWP that the information belongs
  670  * to (such as register state).
  671  *
  672  * We use the following note identifiers:
  673  *
  674  *      ELF_NOTE_NETBSD_CORE_PROCINFO
  675  *              Note is a "netbsd_elfcore_procinfo" structure.
  676  *
  677  * We also use ptrace(2) request numbers (the ones that exist in
  678  * machine-dependent space) to identify register info notes.  The
  679  * info in such notes is in the same format that ptrace(2) would
  680  * export that information.
  681  *
  682  * Please try to keep the members of this structure nicely aligned,
  683  * and if you add elements, add them to the end and bump the version.
  684  */
  685 
  686 #define ELF_NOTE_NETBSD_CORE_NAME       "NetBSD-CORE"
  687 
  688 #define ELF_NOTE_NETBSD_CORE_PROCINFO   1
  689 
  690 #define NETBSD_ELFCORE_PROCINFO_VERSION 1
  691 
  692 struct netbsd_elfcore_procinfo {
  693         /* Version 1 fields start here. */
  694         uint32_t        cpi_version;    /* netbsd_elfcore_procinfo version */
  695         uint32_t        cpi_cpisize;    /* sizeof(netbsd_elfcore_procinfo) */
  696         uint32_t        cpi_signo;      /* killing signal */
  697         uint32_t        cpi_sigcode;    /* signal code */
  698         uint32_t        cpi_sigpend[4]; /* pending signals */
  699         uint32_t        cpi_sigmask[4]; /* blocked signals */
  700         uint32_t        cpi_sigignore[4];/* blocked signals */
  701         uint32_t        cpi_sigcatch[4];/* blocked signals */
  702         int32_t         cpi_pid;        /* process ID */
  703         int32_t         cpi_ppid;       /* parent process ID */
  704         int32_t         cpi_pgrp;       /* process group ID */
  705         int32_t         cpi_sid;        /* session ID */
  706         uint32_t        cpi_ruid;       /* real user ID */
  707         uint32_t        cpi_euid;       /* effective user ID */
  708         uint32_t        cpi_svuid;      /* saved user ID */
  709         uint32_t        cpi_rgid;       /* real group ID */
  710         uint32_t        cpi_egid;       /* effective group ID */
  711         uint32_t        cpi_svgid;      /* saved group ID */
  712         uint32_t        cpi_nlwps;      /* number of LWPs */
  713         int8_t          cpi_name[32];   /* copy of p->p_comm */
  714         /* Add version 2 fields below here. */
  715         int32_t         cpi_siglwp;     /* LWP target of killing signal */
  716 };
  717 
  718 #if defined(ELFSIZE)
  719 #define CONCAT(x,y)     __CONCAT(x,y)
  720 #define ELFNAME(x)      CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
  721 #define ELFNAME2(x,y)   CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
  722 #define ELFNAMEEND(x)   CONCAT(x,CONCAT(_elf,ELFSIZE))
  723 #define ELFDEFNNAME(x)  CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
  724 #endif
  725 
  726 #if defined(ELFSIZE) && (ELFSIZE == 32)
  727 #define Elf_Ehdr        Elf32_Ehdr
  728 #define Elf_Phdr        Elf32_Phdr
  729 #define Elf_Shdr        Elf32_Shdr
  730 #define Elf_Sym         Elf32_Sym
  731 #define Elf_Rel         Elf32_Rel
  732 #define Elf_Rela        Elf32_Rela
  733 #define Elf_Dyn         Elf32_Dyn
  734 #define Elf_Word        Elf32_Word
  735 #define Elf_Sword       Elf32_Sword
  736 #define Elf_Addr        Elf32_Addr
  737 #define Elf_Off         Elf32_Off
  738 #define Elf_Nhdr        Elf32_Nhdr
  739 
  740 #define ELF_R_SYM       ELF32_R_SYM
  741 #define ELF_R_TYPE      ELF32_R_TYPE
  742 #define ELFCLASS        ELFCLASS32
  743 
  744 #define AuxInfo         Aux32Info
  745 #elif defined(ELFSIZE) && (ELFSIZE == 64)
  746 #define Elf_Ehdr        Elf64_Ehdr
  747 #define Elf_Phdr        Elf64_Phdr
  748 #define Elf_Shdr        Elf64_Shdr
  749 #define Elf_Sym         Elf64_Sym
  750 #define Elf_Rel         Elf64_Rel
  751 #define Elf_Rela        Elf64_Rela
  752 #define Elf_Dyn         Elf64_Dyn
  753 #define Elf_Word        Elf64_Word
  754 #define Elf_Sword       Elf64_Sword
  755 #define Elf_Addr        Elf64_Addr
  756 #define Elf_Off         Elf64_Off
  757 #define Elf_Nhdr        Elf64_Nhdr
  758 
  759 #define ELF_R_SYM       ELF64_R_SYM
  760 #define ELF_R_TYPE      ELF64_R_TYPE
  761 #define ELFCLASS        ELFCLASS64
  762 
  763 #define AuxInfo         Aux64Info
  764 #endif
  765 
  766 #define ELF32_ST_BIND(info)             ELF_ST_BIND(info)
  767 #define ELF32_ST_TYPE(info)             ELF_ST_TYPE(info)
  768 #define ELF32_ST_INFO(bind,type)        ELF_ST_INFO(bind,type)
  769 #define ELF32_ST_VISIBILITY(other)      ELF_ST_VISIBILITY(other)
  770 
  771 #define ELF64_ST_BIND(info)             ELF_ST_BIND(info)
  772 #define ELF64_ST_TYPE(info)             ELF_ST_TYPE(info)
  773 #define ELF64_ST_INFO(bind,type)        ELF_ST_INFO(bind,type)
  774 #define ELF64_ST_VISIBILITY(other)      ELF_ST_VISIBILITY(other)
  775 
  776 #ifdef _KERNEL
  777 
  778 #define ELF_AUX_ENTRIES 12              /* Size of aux array passed to loader */
  779 #define ELF32_NO_ADDR   (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */
  780 #define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */
  781 #define ELF64_NO_ADDR   (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */
  782 #define ELF64_LINK_ADDR ((Elf64_Addr)-2) /* advises to use link address */
  783 
  784 #if defined(ELFSIZE) && (ELFSIZE == 64)
  785 #define ELF_NO_ADDR     ELF64_NO_ADDR
  786 #define ELF_LINK_ADDR   ELF64_LINK_ADDR
  787 #elif defined(ELFSIZE) && (ELFSIZE == 32)
  788 #define ELF_NO_ADDR     ELF32_NO_ADDR
  789 #define ELF_LINK_ADDR   ELF32_LINK_ADDR
  790 #endif
  791 
  792 #ifndef ELF32_EHDR_FLAGS_OK
  793 #define ELF32_EHDR_FLAGS_OK(eh) 1
  794 #endif
  795 
  796 #ifndef ELF64_EHDR_FLAGS_OK
  797 #define ELF64_EHDR_FLAGS_OK(eh) 1
  798 #endif
  799 
  800 #if defined(ELFSIZE) && (ELFSIZE == 64)
  801 #define ELF_EHDR_FLAGS_OK(eh)   ELF64_EHDR_FLAGS_OK(eh)
  802 #else
  803 #define ELF_EHDR_FLAGS_OK(eh)   ELF32_EHDR_FLAGS_OK(eh)
  804 #endif
  805 
  806 #if defined(ELFSIZE)
  807 struct elf_args {
  808         Elf_Addr  arg_entry;      /* program entry point */
  809         Elf_Addr  arg_interp;     /* Interpreter load address */
  810         Elf_Addr  arg_phaddr;     /* program header address */
  811         Elf_Addr  arg_phentsize;  /* Size of program header */
  812         Elf_Addr  arg_phnum;      /* Number of program headers */
  813 };
  814 #endif
  815 
  816 #ifndef _LKM
  817 #include "opt_execfmt.h"
  818 #endif
  819 
  820 #ifdef EXEC_ELF32
  821 int     exec_elf32_makecmds(struct proc *, struct exec_package *);
  822 int     elf32_copyargs(struct proc *, struct exec_package *,
  823             struct ps_strings *, char **, void *);
  824 
  825 int     coredump_elf32(struct lwp *, struct vnode *, struct ucred *);
  826 int     coredump_writenote_elf32(struct proc *, struct vnode *,
  827             struct ucred *, off_t, Elf32_Nhdr *, const char *, void *);
  828 
  829 int     elf32_check_header(Elf32_Ehdr *, int);
  830 #endif
  831 
  832 #ifdef EXEC_ELF64
  833 int     exec_elf64_makecmds(struct proc *, struct exec_package *);
  834 int     elf64_read_from(struct proc *, struct vnode *, u_long, caddr_t, int);
  835 int     elf64_copyargs(struct proc *, struct exec_package *,
  836             struct ps_strings *, char **, void *);
  837 
  838 int     coredump_elf64(struct lwp *, struct vnode *, struct ucred *);
  839 int     coredump_writenote_elf64(struct proc *, struct vnode *,
  840             struct ucred *, off_t, Elf64_Nhdr *, const char *, void *);
  841 
  842 int     elf64_check_header(Elf64_Ehdr *, int);
  843 #endif
  844 
  845 #endif /* _KERNEL */
  846 
  847 #endif /* !_SYS_EXEC_ELF_H_ */

Cache object: c773110340fcd30f7581b53c635ef0bc


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.