131085bb4Srsc // Format of an ELF executable file 2dfcc5b99Srtm 3f5527388Srsc #define ELF_MAGIC 0x464C457FU // "\x7FELF" in little endian 455e95b16Srtm 531085bb4Srsc // File header 6b5f17007Srsc struct elfhdr { 729270816Srtm uint magic; // must equal ELF_MAGIC 829270816Srtm uchar elf[12]; 929270816Srtm ushort type; 1029270816Srtm ushort machine; 1129270816Srtm uint version; 1229270816Srtm uint entry; 1329270816Srtm uint phoff; 1429270816Srtm uint shoff; 1529270816Srtm uint flags; 1629270816Srtm ushort ehsize; 1729270816Srtm ushort phentsize; 1829270816Srtm ushort phnum; 1929270816Srtm ushort shentsize; 2029270816Srtm ushort shnum; 2129270816Srtm ushort shstrndx; 2255e95b16Srtm }; 2355e95b16Srtm 2431085bb4Srsc // Program section header 25b5f17007Srsc struct proghdr { 2629270816Srtm uint type; 27*fa81545fSFrans Kaashoek uint off; 28*fa81545fSFrans Kaashoek uint vaddr; 29*fa81545fSFrans Kaashoek uint paddr; 3029270816Srtm uint filesz; 3129270816Srtm uint memsz; 3229270816Srtm uint flags; 3329270816Srtm uint align; 3455e95b16Srtm }; 3555e95b16Srtm 36ef2bd07aSrsc // Values for Proghdr type 3755e95b16Srtm #define ELF_PROG_LOAD 1 3855e95b16Srtm 39ef2bd07aSrsc // Flag bits for Proghdr flags 4055e95b16Srtm #define ELF_PROG_FLAG_EXEC 1 4155e95b16Srtm #define ELF_PROG_FLAG_WRITE 2 4255e95b16Srtm #define ELF_PROG_FLAG_READ 4 43