1 #ifndef JOS_INC_ELF_H 2 #define JOS_INC_ELF_H 3 4 #define ELF_MAGIC 0x464C457FU /* "\x7FELF" in little endian */ 5 6 struct Elf { 7 uint32_t e_magic; // must equal ELF_MAGIC 8 uint8_t e_elf[12]; 9 uint16_t e_type; 10 uint16_t e_machine; 11 uint32_t e_version; 12 uint32_t e_entry; 13 uint32_t e_phoff; 14 uint32_t e_shoff; 15 uint32_t e_flags; 16 uint16_t e_ehsize; 17 uint16_t e_phentsize; 18 uint16_t e_phnum; 19 uint16_t e_shentsize; 20 uint16_t e_shnum; 21 uint16_t e_shstrndx; 22 }; 23 24 struct Proghdr { 25 uint32_t p_type; 26 uint32_t p_offset; 27 uint32_t p_va; 28 uint32_t p_pa; 29 uint32_t p_filesz; 30 uint32_t p_memsz; 31 uint32_t p_flags; 32 uint32_t p_align; 33 }; 34 35 // Values for Proghdr::p_type 36 #define ELF_PROG_LOAD 1 37 38 // Flag bits for Proghdr::p_flags 39 #define ELF_PROG_FLAG_EXEC 1 40 #define ELF_PROG_FLAG_WRITE 2 41 #define ELF_PROG_FLAG_READ 4 42 43 #endif /* !JOS_INC_ELF_H */ 44