elf.h 755 B

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