elf.h (925B)
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 uint magic; // must equal ELF_MAGIC 8 uchar elf[12]; 9 ushort type; 10 ushort machine; 11 uint version; 12 uintp entry; 13 uintp phoff; 14 uintp shoff; 15 uint flags; 16 ushort ehsize; 17 ushort phentsize; 18 ushort phnum; 19 ushort shentsize; 20 ushort shnum; 21 ushort shstrndx; 22 }; 23 24 // Program section header 25 #if X64 26 struct proghdr { 27 uint32 type; 28 uint32 flags; 29 uint64 off; 30 uint64 vaddr; 31 uint64 paddr; 32 uint64 filesz; 33 uint64 memsz; 34 uint64 align; 35 }; 36 #else 37 struct proghdr { 38 uint type; 39 uint off; 40 uint vaddr; 41 uint paddr; 42 uint filesz; 43 uint memsz; 44 uint flags; 45 uint align; 46 }; 47 #endif 48 49 // Values for Proghdr type 50 #define ELF_PROG_LOAD 1 51 52 // Flag bits for Proghdr flags 53 #define ELF_PROG_FLAG_EXEC 1 54 #define ELF_PROG_FLAG_WRITE 2 55 #define ELF_PROG_FLAG_READ 4