github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/cpvmm/vmm/bootstrap/elf_defns.h (about)

     1  /*
     2   * elf_defns.h: ELF file type definitions
     3   *
     4   * Copyright (c) 2006-2007, Intel Corporation
     5   * All rights reserved.
     6   *
     7   * Redistribution and use in source and binary forms, with or without
     8   * modification, are permitted provided that the following conditions
     9   * are met:
    10   *
    11   *   * Redistributions of source code must retain the above copyright
    12   *     notice, this list of conditions and the following disclaimer.
    13   *   * Redistributions in binary form must reproduce the above
    14   *     copyright notice, this list of conditions and the following
    15   *     disclaimer in the documentation and/or other materials provided
    16   *     with the distribution.
    17   *   * Neither the name of the Intel Corporation nor the names of its
    18   *     contributors may be used to endorse or promote products derived
    19   *     from this software without specific prior written permission.
    20   *
    21   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    22   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    23   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    24   * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    25   * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    26   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    27   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    28   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    29   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    30   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    31   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
    32   * OF THE POSSIBILITY OF SUCH DAMAGE.
    33   *
    34   */
    35  
    36  #ifndef __ELF_DEFNS_H__
    37  #define __ELF_DEFNS_H__
    38  
    39  /* Elf header */
    40  typedef struct {
    41      unsigned char e_ident[16];
    42      uint16_t e_type;
    43      uint16_t e_machine;
    44      uint32_t e_version;
    45      uint32_t e_entry;
    46      uint32_t e_phoff;
    47      uint32_t e_shoff;
    48      uint32_t e_flags;
    49      uint16_t e_ehsz;
    50      uint16_t e_phentsize;
    51      uint16_t e_phnum;
    52      uint16_t e_shentsize;
    53      uint16_t e_shnum;
    54      uint16_t e_shstrndx;
    55  } elf_header_t;
    56  
    57  /* e_ident[] Identification Indexes */
    58  #define EI_MAG0        0         /* File identification */
    59  #define EI_MAG1        1         /* File identification */
    60  #define EI_MAG2        2         /* File identification */
    61  #define EI_MAG3        3         /* File identification */
    62  #define EI_CLASS       4         /* File class */
    63  #define EI_DATA        5         /* Data encoding */
    64  #define EI_VERSION     6         /* File version */
    65  #define EI_PAD         7         /* Start of padding bytes */
    66  #define EI_NIDENT      8         /* Size of e_ident[] */
    67  
    68  /* Magic number */
    69  #define ELFMAG0        0x7f      /* e_ident[EI_MAG0] */
    70  #define ELFMAG1        'E'       /* e_ident[EI_MAG1] */
    71  #define ELFMAG2        'L'       /* e_ident[EI_MAG2] */
    72  #define ELFMAG3        'F'       /* e_ident[EI_MAG3] */
    73  
    74  /* e_ident[EI_CLASS] */
    75  #define ELFCLASSNONE   0         /* Invalid class */
    76  #define ELFCLASS32     1         /* 32-bit objects */
    77  #define ELFCLASS64     2         /* 64-bit objects */
    78  
    79  /* e_ident[EI_DATA] */
    80  #define ELFDATANONE    0         /* Invalid data encoding */
    81  #define ELFDATA2LSB    1         /* Least significant byte */
    82  #define ELFDATA2MSB    2         /* Most significant byte */
    83  
    84  /* e_type */
    85  #define ET_NONE        0         /* No file type */
    86  #define ET_REL         1         /* Relocatable file */
    87  #define ET_EXEC        2         /* Executable file */
    88  #define ET_DYN         3         /* Shared object file */
    89  #define ET_CORE        4         /* Core file */
    90  #define ET_LOPROC      0xff00    /* Processor-specific */
    91  #define ET_HIPROC      0xffff    /* Processor-specific */
    92  
    93  /* e_machine */
    94  #define ET_NONE        0         /* No machine */
    95  #define EM_M32         1         /* At&t We 32100 */
    96  #define EM_SPARC       2         /* SPARC */
    97  #define EM_386         3         /* Intel architecture */
    98  #define EM_68K         4         /* Motorola 68000 */
    99  #define EM_88K         5         /* Motorola 88000 */
   100  #define EM_860         7         /* Intel 80860 */
   101  #define EM_MIPS        8         /* MIPS RS3000 Big-Endian */
   102  #define EM_MIPS_RS4_BE 10        /* MIPS RS4000 Big-Endian */
   103  
   104  /* e_version */
   105  #define EV_NONE        0         /* Invalid version */
   106  #define EV_CURRENT     1         /* Current version */
   107  
   108  /* Program header */
   109  typedef struct {
   110      uint32_t p_type;
   111      uint32_t p_offset;
   112      uint32_t p_vaddr;
   113      uint32_t p_paddr;
   114      uint32_t p_filesz;
   115      uint32_t p_memsz;
   116      uint32_t p_flags;
   117      uint32_t p_align;
   118  } elf_program_header_t;
   119  
   120  /* p_type */
   121  #define PT_NULL        0
   122  #define PT_LOAD        1
   123  #define PT_DYNAMIC     2
   124  #define PT_INTERP      3
   125  #define PT_NOTE        4
   126  #define PT_SHLIB       5
   127  #define PT_PHDR        6
   128  #define PT_LOPROC      0x70000000
   129  #define PT_HIPROC      0x7fffffff
   130  
   131  /* multiboot magic */
   132  #define MB_MAGIC       0x2badb002
   133  
   134  #endif /* __ELF_DEFNS_H__ */
   135  
   136  
   137  
   138  /*
   139   * Local variables:
   140   * mode: C
   141   * c-set-style: "BSD"
   142   * c-basic-offset: 4
   143   * tab-width: 4
   144   * indent-tabs-mode: nil
   145   * End:
   146   */