github.com/jspc/eggos@v0.5.1-0.20221028160421-556c75c878a5/boot/elf.h (about)

     1  // Format of an ELF executable file
     2  
     3  #define ELF_MAGIC 0x464C457FU // "\x7FELF" in little endian
     4  
     5  // File header
     6  struct elfhdr
     7  {
     8    uint32 magic; // must equal ELF_MAGIC
     9    uint8 elf[12];
    10    uint16 type;
    11    uint16 machine;
    12    uint32 version;
    13    uint64 entry;
    14    uint64 phoff;
    15    uint64 shoff;
    16    uint32 flags;
    17    uint16 ehsize;
    18    uint16 phentsize;
    19    uint16 phnum;
    20    uint16 shentsize;
    21    uint16 shnum;
    22    uint16 shstrndx;
    23  };
    24  
    25  // Program section header
    26  struct proghdr
    27  {
    28    uint32 type;
    29    uint32 flags;
    30    uint64 off;
    31    uint64 vaddr;
    32    uint64 paddr;
    33    uint64 filesz;
    34    uint64 memsz;
    35    uint64 align;
    36  };
    37  
    38  // Values for Proghdr type
    39  #define ELF_PROG_LOAD 1
    40  
    41  // Flag bits for Proghdr flags
    42  #define ELF_PROG_FLAG_EXEC 1
    43  #define ELF_PROG_FLAG_WRITE 2
    44  #define ELF_PROG_FLAG_READ 4