elf.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * Definitions needed for accessing Irix ELF headers
  3. */
  4. typedef struct {
  5. uchar ident[16]; /* ident bytes */
  6. ushort type; /* file type */
  7. ushort machine; /* target machine */
  8. int version; /* file version */
  9. ulong elfentry; /* start address */
  10. ulong phoff; /* phdr file offset */
  11. ulong shoff; /* shdr file offset */
  12. int flags; /* file flags */
  13. ushort ehsize; /* sizeof ehdr */
  14. ushort phentsize; /* sizeof phdr */
  15. ushort phnum; /* number phdrs */
  16. ushort shentsize; /* sizeof shdr */
  17. ushort shnum; /* number shdrs */
  18. ushort shstrndx; /* shdr string index */
  19. } Ehdr;
  20. typedef struct {
  21. int type; /* entry type */
  22. ulong offset; /* file offset */
  23. ulong vaddr; /* virtual address */
  24. ulong paddr; /* physical address */
  25. int filesz; /* file size */
  26. ulong memsz; /* memory size */
  27. int flags; /* entry flags */
  28. int align; /* memory/file alignment */
  29. } Phdr;
  30. typedef struct {
  31. ulong name; /* section name */
  32. ulong type; /* SHT_... */
  33. ulong flags; /* SHF_... */
  34. ulong addr; /* virtual address */
  35. ulong offset; /* file offset */
  36. ulong size; /* section size */
  37. ulong link; /* misc info */
  38. ulong info; /* misc info */
  39. ulong addralign; /* memory alignment */
  40. ulong entsize; /* entry size if table */
  41. } Shdr;
  42. enum {
  43. /* Ehdr codes */
  44. MAG0 = 0, /* ident[] indexes */
  45. MAG1 = 1,
  46. MAG2 = 2,
  47. MAG3 = 3,
  48. CLASS = 4,
  49. DATA = 5,
  50. VERSION = 6,
  51. ELFCLASSNONE = 0, /* ident[CLASS] */
  52. ELFCLASS32 = 1,
  53. ELFCLASS64 = 2,
  54. ELFCLASSNUM = 3,
  55. ELFDATANONE = 0, /* ident[DATA] */
  56. ELFDATA2LSB = 1,
  57. ELFDATA2MSB = 2,
  58. ELFDATANUM = 3,
  59. NOETYPE = 0, /* type */
  60. REL = 1,
  61. EXEC = 2,
  62. DYN = 3,
  63. CORE = 4,
  64. NONE = 0, /* machine */
  65. M32 = 1, /* AT&T WE 32100 */
  66. SPARC = 2, /* Sun SPARC */
  67. I386 = 3, /* Intel 80386 */
  68. M68K = 4, /* Motorola 68000 */
  69. M88K = 5, /* Motorola 88000 */
  70. I486 = 6, /* Intel 80486 */
  71. I860 = 7, /* Intel i860 */
  72. MIPS = 8, /* Mips R2000 */
  73. S370 = 9, /* Amdhal */
  74. POWER = 20, /* PowerPC */
  75. SPARC64 = 18, /* Sun SPARC v9 */
  76. AMD64 = 62, /* Amd64 */
  77. NO_VERSION = 0, /* version, ident[VERSION] */
  78. CURRENT = 1,
  79. /* Phdr Codes */
  80. NOPTYPE = 0, /* type */
  81. LOAD = 1,
  82. DYNAMIC = 2,
  83. INTERP = 3,
  84. NOTE = 4,
  85. SHLIB = 5,
  86. PHDR = 6,
  87. R = 0x4, /* flags */
  88. W = 0x2,
  89. X = 0x1,
  90. };
  91. #define ELF_MAG ((0x7f<<24) | ('E'<<16) | ('L'<<8) | 'F')