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/elf32.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1996-1997 John D. Polstra.
    3  * 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  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD: src/sys/sys/elf32.h,v 1.2.2.3 1999/09/05 08:22:15 peter Exp $
   27  */
   28 
   29 #ifndef _SYS_ELF32_H_
   30 #define _SYS_ELF32_H_ 1
   31 
   32 /*
   33  * ELF definitions common to all 32-bit architectures.
   34  */
   35 
   36 typedef u_int32_t       Elf32_Addr;
   37 typedef u_int16_t       Elf32_Half;
   38 typedef u_int32_t       Elf32_Off;
   39 typedef int32_t         Elf32_Sword;
   40 typedef u_int32_t       Elf32_Word;
   41 
   42 /*
   43  * ELF header.
   44  */
   45 
   46 #define EI_NIDENT       16              /* Size of e_ident array. */
   47 
   48 typedef struct {
   49         unsigned char   e_ident[EI_NIDENT];     /* File identification. */
   50         Elf32_Half      e_type;         /* File type. */
   51         Elf32_Half      e_machine;      /* Machine architecture. */
   52         Elf32_Word      e_version;      /* ELF format version. */
   53         Elf32_Addr      e_entry;        /* Entry point. */
   54         Elf32_Off       e_phoff;        /* Program header file offset. */
   55         Elf32_Off       e_shoff;        /* Section header file offset. */
   56         Elf32_Word      e_flags;        /* Architecture-specific flags. */
   57         Elf32_Half      e_ehsize;       /* Size of ELF header in bytes. */
   58         Elf32_Half      e_phentsize;    /* Size of program header entry. */
   59         Elf32_Half      e_phnum;        /* Number of program header entries. */
   60         Elf32_Half      e_shentsize;    /* Size of section header entry. */
   61         Elf32_Half      e_shnum;        /* Number of section header entries. */
   62         Elf32_Half      e_shstrndx;     /* Section name strings section. */
   63 } Elf32_Ehdr;
   64 
   65 /* Indexes into the e_ident array. */
   66 #define EI_MAG0         0       /* Magic number, byte 0. */
   67 #define EI_MAG1         1       /* Magic number, byte 1. */
   68 #define EI_MAG2         2       /* Magic number, byte 2. */
   69 #define EI_MAG3         3       /* Magic number, byte 3. */
   70 #define EI_CLASS        4       /* Class of machine. */
   71 #define EI_DATA         5       /* Data format. */
   72 #define EI_VERSION      6       /* ELF format version. */
   73 #define EI_PAD          7       /* Start of padding (per SVR4 ABI). */
   74 #define EI_BRAND        8       /* Start of architecture identification. */
   75 
   76 /* Values for the magic number bytes. */
   77 #define ELFMAG0         0x7f
   78 #define ELFMAG1         'E'
   79 #define ELFMAG2         'L'
   80 #define ELFMAG3         'F'
   81 
   82 /* Values for e_ident[EI_VERSION] and e_version. */
   83 #define EV_NONE         0
   84 #define EV_CURRENT      1
   85 
   86 /* Values for e_ident[EI_CLASS]. */
   87 #define ELFCLASSNONE    0       /* Unknown class. */
   88 #define ELFCLASS32      1       /* 32-bit architecture. */
   89 #define ELFCLASS64      2       /* 64-bit architecture. */
   90 
   91 /* Values for e_ident[EI_DATA]. */
   92 #define ELFDATANONE     0       /* Unknown data format. */
   93 #define ELFDATA2LSB     1       /* 2's complement little-endian. */
   94 #define ELFDATA2MSB     2       /* 2's complement big-endian. */
   95 
   96 /* e_ident */
   97 #define IS_ELF(ehdr)    ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
   98                          (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
   99                          (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
  100                          (ehdr).e_ident[EI_MAG3] == ELFMAG3)
  101 
  102 /* Values for e_type. */
  103 #define ET_NONE         0       /* Unknown type. */
  104 #define ET_REL          1       /* Relocatable. */
  105 #define ET_EXEC         2       /* Executable. */
  106 #define ET_DYN          3       /* Shared object. */
  107 #define ET_CORE         4       /* Core file. */
  108 
  109 /* Values for e_machine. */
  110 #define EM_NONE         0       /* Unknown machine. */
  111 #define EM_M32          1       /* AT&T WE32100. */
  112 #define EM_SPARC        2       /* Sun SPARC. */
  113 #define EM_386          3       /* Intel i386. */
  114 #define EM_68K          4       /* Motorola 68000. */
  115 #define EM_88K          5       /* Motorola 88000. */
  116 #define EM_486          6       /* Intel i486. */
  117 #define EM_860          7       /* Intel i860. */
  118 #define EM_MIPS         8       /* MIPS R3000 Big-Endian only */
  119 
  120 /* Extensions */
  121 #define EM_MIPS_RS4_BE  10      /* MIPS R4000 Big-Endian */
  122 #define EM_SPARC64      11      /* SPARC v9 64-bit unoffical */
  123 #define EM_PARISC       15      /* HPPA */
  124 #define EM_PPC          20      /* PowerPC */
  125 
  126 
  127 /*
  128  * Section header.
  129  */
  130 
  131 typedef struct {
  132         Elf32_Word      sh_name;        /* Section name (index into the
  133                                            section header string table). */
  134         Elf32_Word      sh_type;        /* Section type. */
  135         Elf32_Word      sh_flags;       /* Section flags. */
  136         Elf32_Addr      sh_addr;        /* Address in memory image. */
  137         Elf32_Off       sh_offset;      /* Offset in file. */
  138         Elf32_Word      sh_size;        /* Size in bytes. */
  139         Elf32_Word      sh_link;        /* Index of a related section. */
  140         Elf32_Word      sh_info;        /* Depends on section type. */
  141         Elf32_Word      sh_addralign;   /* Alignment in bytes. */
  142         Elf32_Word      sh_entsize;     /* Size of each entry in section. */
  143 } Elf32_Shdr;
  144 
  145 /* Special section indexes. */
  146 #define SHN_UNDEF            0          /* Undefined, missing, irrelevant. */
  147 #define SHN_LORESERVE   0xff00          /* First of reserved range. */
  148 #define SHN_LOPROC      0xff00          /* First processor-specific. */
  149 #define SHN_HIPROC      0xff1f          /* Last processor-specific. */
  150 #define SHN_ABS         0xfff1          /* Absolute values. */
  151 #define SHN_COMMON      0xfff2          /* Common data. */
  152 #define SHN_HIRESERVE   0xffff          /* Last of reserved range. */
  153 
  154 /* sh_type */
  155 #define SHT_NULL        0               /* inactive */
  156 #define SHT_PROGBITS    1               /* program defined information */
  157 #define SHT_SYMTAB      2               /* symbol table section */
  158 #define SHT_STRTAB      3               /* string table section */
  159 #define SHT_RELA        4               /* relocation section with addends*/
  160 #define SHT_HASH        5               /* symbol hash table section */
  161 #define SHT_DYNAMIC     6               /* dynamic section */ 
  162 #define SHT_NOTE        7               /* note section */
  163 #define SHT_NOBITS      8               /* no space section */
  164 #define SHT_REL         9               /* relation section without addends */
  165 #define SHT_SHLIB       10              /* reserved - purpose unknown */
  166 #define SHT_DYNSYM      11              /* dynamic symbol table section */ 
  167 #define SHT_LOPROC      0x70000000      /* reserved range for processor */
  168 #define SHT_HIPROC      0x7fffffff      /* specific section header types */
  169 #define SHT_LOUSER      0x80000000      /* reserved range for application */
  170 #define SHT_HIUSER      0xffffffff      /* specific indexes */
  171 
  172 
  173 /*
  174  * Program header.
  175  */
  176 
  177 typedef struct {
  178         Elf32_Word      p_type;         /* Entry type. */
  179         Elf32_Off       p_offset;       /* File offset of contents. */
  180         Elf32_Addr      p_vaddr;        /* Virtual address in memory image. */
  181         Elf32_Addr      p_paddr;        /* Physical address (not used). */
  182         Elf32_Word      p_filesz;       /* Size of contents in file. */
  183         Elf32_Word      p_memsz;        /* Size of contents in memory. */
  184         Elf32_Word      p_flags;        /* Access permission flags. */
  185         Elf32_Word      p_align;        /* Alignment in memory and file. */
  186 } Elf32_Phdr;
  187 
  188 /* Values for p_type. */
  189 #define PT_NULL         0       /* Unused entry. */
  190 #define PT_LOAD         1       /* Loadable segment. */
  191 #define PT_DYNAMIC      2       /* Dynamic linking information segment. */
  192 #define PT_INTERP       3       /* Pathname of interpreter. */
  193 #define PT_NOTE         4       /* Auxiliary information. */
  194 #define PT_SHLIB        5       /* Reserved (not used). */
  195 #define PT_PHDR         6       /* Location of program header itself. */
  196 
  197 #define PT_COUNT        7       /* Number of defined p_type values. */
  198 
  199 #define PT_LOPROC       0x70000000      /* First processor-specific type. */
  200 #define PT_HIPROC       0x7fffffff      /* Last processor-specific type. */
  201 
  202 /* Values for p_flags. */
  203 #define PF_X            0x1     /* Executable. */
  204 #define PF_W            0x2     /* Writable. */
  205 #define PF_R            0x4     /* Readable. */
  206 
  207 /*
  208  * Dynamic structure.  The ".dynamic" section contains an array of them.
  209  */
  210 
  211 typedef struct {
  212         Elf32_Sword     d_tag;          /* Entry type. */
  213         union {
  214                 Elf32_Word      d_val;  /* Integer value. */
  215                 Elf32_Addr      d_ptr;  /* Address value. */
  216         } d_un;
  217 } Elf32_Dyn;
  218 
  219 /* Values for d_tag. */
  220 #define DT_NULL         0       /* Terminating entry. */
  221 #define DT_NEEDED       1       /* String table offset of a needed shared
  222                                    library. */
  223 #define DT_PLTRELSZ     2       /* Total size in bytes of PLT relocations. */
  224 #define DT_PLTGOT       3       /* Processor-dependent address. */
  225 #define DT_HASH         4       /* Address of symbol hash table. */
  226 #define DT_STRTAB       5       /* Address of string table. */
  227 #define DT_SYMTAB       6       /* Address of symbol table. */
  228 #define DT_RELA         7       /* Address of Elf32_Rela relocations. */
  229 #define DT_RELASZ       8       /* Total size of Elf32_Rela relocations. */
  230 #define DT_RELAENT      9       /* Size of each Elf32_Rela relocation entry. */
  231 #define DT_STRSZ        10      /* Size of string table. */
  232 #define DT_SYMENT       11      /* Size of each symbol table entry. */
  233 #define DT_INIT         12      /* Address of initialization function. */
  234 #define DT_FINI         13      /* Address of finalization function. */
  235 #define DT_SONAME       14      /* String table offset of shared object
  236                                    name. */
  237 #define DT_RPATH        15      /* String table offset of library path. */
  238 #define DT_SYMBOLIC     16      /* Indicates "symbolic" linking. */
  239 #define DT_REL          17      /* Address of Elf32_Rel relocations. */
  240 #define DT_RELSZ        18      /* Total size of Elf32_Rel relocations. */
  241 #define DT_RELENT       19      /* Size of each Elf32_Rel relocation. */
  242 #define DT_PLTREL       20      /* Type of relocation used for PLT. */
  243 #define DT_DEBUG        21      /* Reserved (not used). */
  244 #define DT_TEXTREL      22      /* Indicates there may be relocations in
  245                                    non-writable segments. */
  246 #define DT_JMPREL       23      /* Address of PLT relocations. */
  247 
  248 #define DT_COUNT        24      /* Number of defined d_tag values. */
  249 
  250 /*
  251  * Relocation entries.
  252  */
  253 
  254 /* Relocations that don't need an addend field. */
  255 typedef struct {
  256         Elf32_Addr      r_offset;       /* Location to be relocated. */
  257         Elf32_Word      r_info;         /* Relocation type and symbol index. */
  258 } Elf32_Rel;
  259 
  260 /* Relocations that need an addend field. */
  261 typedef struct {
  262         Elf32_Addr      r_offset;       /* Location to be relocated. */
  263         Elf32_Word      r_info;         /* Relocation type and symbol index. */
  264         Elf32_Sword     r_addend;       /* Addend. */
  265 } Elf32_Rela;
  266 
  267 /* Macros for accessing the fields of r_info. */
  268 #define ELF32_R_SYM(info)       ((info) >> 8)
  269 #define ELF32_R_TYPE(info)      ((unsigned char)(info))
  270 
  271 /* Macro for constructing r_info from field values. */
  272 #define ELF32_R_INFO(sym, type) (((sym) << 8) + (unsigned char)(type))
  273 
  274 /*
  275  * Symbol table entries.
  276  */
  277 
  278 typedef struct {
  279         Elf32_Word      st_name;        /* String table index of name. */
  280         Elf32_Addr      st_value;       /* Symbol value. */
  281         Elf32_Word      st_size;        /* Size of associated object. */
  282         unsigned char   st_info;        /* Type and binding information. */
  283         unsigned char   st_other;       /* Reserved (not used). */
  284         Elf32_Half      st_shndx;       /* Section index of symbol. */
  285 } Elf32_Sym;
  286 
  287 /* Macros for accessing the fields of st_info. */
  288 #define ELF32_ST_BIND(info)             ((info) >> 4)
  289 #define ELF32_ST_TYPE(info)             ((info) & 0xf)
  290 
  291 /* Macro for constructing st_info from field values. */
  292 #define ELF32_ST_INFO(bind, type)       (((bind) << 4) + ((type) & 0xf))
  293 
  294 /* Symbol Binding - ELF32_ST_BIND - st_info */
  295 #define STB_LOCAL       0       /* Local symbol */
  296 #define STB_GLOBAL      1       /* Global symbol */
  297 #define STB_WEAK        2       /* like global - lower precedence */
  298 #define STB_LOPROC      13      /* reserved range for processor */
  299 #define STB_HIPROC      15      /*  specific symbol bindings */
  300 
  301 /* Symbol type - ELF32_ST_TYPE - st_info */
  302 #define STT_NOTYPE      0       /* Unspecified type. */
  303 #define STT_OBJECT      1       /* Data object. */
  304 #define STT_FUNC        2       /* Function. */
  305 #define STT_SECTION     3       /* Section. */
  306 #define STT_FILE        4       /* Source file. */
  307 #define STT_LOPROC      13      /* reserved range for processor */
  308 #define STT_HIPROC      15      /*  specific symbol types */
  309 
  310 /* Special symbol table indexes. */
  311 #define STN_UNDEF       0       /* Undefined symbol index. */
  312 
  313 #endif /* !_SYS_ELF32_H_ */

Cache object: 05cfdae9e435200e979891f22eee0f2f


[ 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.