elf.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. enum {
  10. Ehdr32sz = 52,
  11. Phdr32sz = 32,
  12. Shdr32sz = 40,
  13. Ehdr64sz = 64,
  14. Phdr64sz = 56,
  15. Shdr64sz = 64,
  16. };
  17. /* from /sys/src/libmach/elf.h */
  18. enum {
  19. /* Ehdr codes */
  20. MAG0 = 0, /* ident[] indexes */
  21. MAG1 = 1,
  22. MAG2 = 2,
  23. MAG3 = 3,
  24. CLASS = 4,
  25. DATA = 5,
  26. VERSION = 6,
  27. ELFCLASSNONE = 0, /* ident[CLASS] */
  28. ELFCLASS32 = 1,
  29. ELFCLASS64 = 2,
  30. ELFCLASSNUM = 3,
  31. ELFDATANONE = 0, /* ident[DATA] */
  32. ELFDATA2LSB = 1,
  33. ELFDATA2MSB = 2,
  34. ELFDATANUM = 3,
  35. NOETYPE = 0, /* type */
  36. REL = 1,
  37. EXEC = 2,
  38. DYN = 3,
  39. CORE = 4,
  40. NONE = 0, /* machine */
  41. M32 = 1, /* AT&T WE 32100 */
  42. SPARC = 2, /* Sun SPARC */
  43. I386 = 3, /* Intel 80386 */
  44. M68K = 4, /* Motorola 68000 */
  45. M88K = 5, /* Motorola 88000 */
  46. I486 = 6, /* Intel 80486 */
  47. I860 = 7, /* Intel i860 */
  48. MIPS = 8, /* Mips R2000 */
  49. S370 = 9, /* Amdhal */
  50. MIPSR4K = 10, /* Mips R4000 */
  51. SPARC64 = 18, /* Sun SPARC v9 */
  52. POWER = 20, /* PowerPC */
  53. POWER64 = 21, /* PowerPC64 */
  54. ARM = 40, /* ARM */
  55. AMD64 = 62, /* Amd64 */
  56. ARM64 = 183, /* ARM64 */
  57. NO_VERSION = 0, /* version, ident[VERSION] */
  58. CURRENT = 1,
  59. /* Phdr Codes */
  60. NOPTYPE = 0, /* type */
  61. PT_LOAD = 1,
  62. DYNAMIC = 2,
  63. INTERP = 3,
  64. NOTE = 4,
  65. SHLIB = 5,
  66. PHDR = 6,
  67. R = 0x4, /* flags */
  68. W = 0x2,
  69. X = 0x1,
  70. /* Shdr Codes */
  71. Progbits = 1, /* section types */
  72. Strtab = 3,
  73. Nobits = 8,
  74. Swrite = 1, /* section attributes (flags) */
  75. Salloc = 2,
  76. Sexec = 4,
  77. };
  78. typedef void (*Putl)(long);
  79. void elf32(int mach, int bo, int addpsects, void (*putpsects)(Putl));
  80. void elf32phdr(void (*putl)(long), uint32_t type, uint32_t off,
  81. uint32_t vaddr,
  82. uint32_t paddr, uint32_t filesz, uint32_t memsz, uint32_t prots,
  83. uint32_t align);
  84. void elf32shdr(void (*putl)(long), uint32_t name, uint32_t type,
  85. uint32_t flags,
  86. uint32_t vaddr, uint32_t off, uint32_t sectsz, uint32_t link,
  87. uint32_t addnl,
  88. uint32_t align, uint32_t entsz);
  89. void elf64(int mach, int bo, int addpsects, void (*putpsects)(Putl));
  90. void elf64phdr(void (*putl)(long), void (*putll)(vlong), uint32_t type,
  91. uvlong off, uvlong vaddr, uvlong paddr, uvlong filesz, uvlong memsz,
  92. uint32_t prots, uvlong align);
  93. void elf64shdr(void (*putl)(long), void (*putll)(vlong), uint32_t name,
  94. uint32_t type, uvlong flags, uvlong vaddr, uvlong off,
  95. uvlong sectsz,
  96. uint32_t link, uint32_t addnl, uvlong align, uvlong entsz);