elfstructs.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. #ifndef __XEN_PUBLIC_ELFSTRUCTS_H__
  2. #define __XEN_PUBLIC_ELFSTRUCTS_H__ 1
  3. /*
  4. * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. The name of the author may not be used to endorse or promote products
  15. * derived from this software without specific prior written permission
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. typedef uint8_t Elf_Byte;
  29. typedef uint32_t Elf32_Addr; /* Unsigned program address */
  30. typedef uint32_t Elf32_Off; /* Unsigned file offset */
  31. typedef int32_t Elf32_Sword; /* Signed large integer */
  32. typedef uint32_t Elf32_Word; /* Unsigned large integer */
  33. typedef uint16_t Elf32_Half; /* Unsigned medium integer */
  34. typedef uint64_t Elf64_Addr;
  35. typedef uint64_t Elf64_Off;
  36. typedef int32_t Elf64_Shalf;
  37. typedef int32_t Elf64_Sword;
  38. typedef uint32_t Elf64_Word;
  39. typedef int64_t Elf64_Sxword;
  40. typedef uint64_t Elf64_Xword;
  41. typedef uint32_t Elf64_Half;
  42. typedef uint16_t Elf64_Quarter;
  43. /*
  44. * e_ident[] identification indexes
  45. * See http://www.caldera.com/developers/gabi/2000-07-17/ch4.eheader.html
  46. */
  47. #define EI_MAG0 0 /* file ID */
  48. #define EI_MAG1 1 /* file ID */
  49. #define EI_MAG2 2 /* file ID */
  50. #define EI_MAG3 3 /* file ID */
  51. #define EI_CLASS 4 /* file class */
  52. #define EI_DATA 5 /* data encoding */
  53. #define EI_VERSION 6 /* ELF header version */
  54. #define EI_OSABI 7 /* OS/ABI ID */
  55. #define EI_ABIVERSION 8 /* ABI version */
  56. #define EI_PAD 9 /* start of pad bytes */
  57. #define EI_NIDENT 16 /* Size of e_ident[] */
  58. /* e_ident[] magic number */
  59. #define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
  60. #define ELFMAG1 'E' /* e_ident[EI_MAG1] */
  61. #define ELFMAG2 'L' /* e_ident[EI_MAG2] */
  62. #define ELFMAG3 'F' /* e_ident[EI_MAG3] */
  63. #define ELFMAG "\177ELF" /* magic */
  64. #define SELFMAG 4 /* size of magic */
  65. /* e_ident[] file class */
  66. #define ELFCLASSNONE 0 /* invalid */
  67. #define ELFCLASS32 1 /* 32-bit objs */
  68. #define ELFCLASS64 2 /* 64-bit objs */
  69. #define ELFCLASSNUM 3 /* number of classes */
  70. /* e_ident[] data encoding */
  71. #define ELFDATANONE 0 /* invalid */
  72. #define ELFDATA2LSB 1 /* Little-Endian */
  73. #define ELFDATA2MSB 2 /* Big-Endian */
  74. #define ELFDATANUM 3 /* number of data encode defines */
  75. /* e_ident[] Operating System/ABI */
  76. #define ELFOSABI_SYSV 0 /* UNIX System V ABI */
  77. #define ELFOSABI_HPUX 1 /* HP-UX operating system */
  78. #define ELFOSABI_NETBSD 2 /* NetBSD */
  79. #define ELFOSABI_LINUX 3 /* GNU/Linux */
  80. #define ELFOSABI_HURD 4 /* GNU/Hurd */
  81. #define ELFOSABI_86OPEN 5 /* 86Open common IA32 ABI */
  82. #define ELFOSABI_SOLARIS 6 /* Solaris */
  83. #define ELFOSABI_MONTEREY 7 /* Monterey */
  84. #define ELFOSABI_IRIX 8 /* IRIX */
  85. #define ELFOSABI_FREEBSD 9 /* FreeBSD */
  86. #define ELFOSABI_TRU64 10 /* TRU64 UNIX */
  87. #define ELFOSABI_MODESTO 11 /* Novell Modesto */
  88. #define ELFOSABI_OPENBSD 12 /* OpenBSD */
  89. #define ELFOSABI_ARM 97 /* ARM */
  90. #define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
  91. /* e_ident */
  92. #define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
  93. (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
  94. (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
  95. (ehdr).e_ident[EI_MAG3] == ELFMAG3)
  96. /* ELF Header */
  97. typedef struct elfhdr {
  98. unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
  99. Elf32_Half e_type; /* object file type */
  100. Elf32_Half e_machine; /* machine */
  101. Elf32_Word e_version; /* object file version */
  102. Elf32_Addr e_entry; /* virtual entry point */
  103. Elf32_Off e_phoff; /* program header table offset */
  104. Elf32_Off e_shoff; /* section header table offset */
  105. Elf32_Word e_flags; /* processor-specific flags */
  106. Elf32_Half e_ehsize; /* ELF header size */
  107. Elf32_Half e_phentsize; /* program header entry size */
  108. Elf32_Half e_phnum; /* number of program header entries */
  109. Elf32_Half e_shentsize; /* section header entry size */
  110. Elf32_Half e_shnum; /* number of section header entries */
  111. Elf32_Half e_shstrndx; /* section header table's "section
  112. header string table" entry offset */
  113. } Elf32_Ehdr;
  114. typedef struct {
  115. unsigned char e_ident[EI_NIDENT]; /* Id bytes */
  116. Elf64_Quarter e_type; /* file type */
  117. Elf64_Quarter e_machine; /* machine type */
  118. Elf64_Half e_version; /* version number */
  119. Elf64_Addr e_entry; /* entry point */
  120. Elf64_Off e_phoff; /* Program hdr offset */
  121. Elf64_Off e_shoff; /* Section hdr offset */
  122. Elf64_Half e_flags; /* Processor flags */
  123. Elf64_Quarter e_ehsize; /* sizeof ehdr */
  124. Elf64_Quarter e_phentsize; /* Program header entry size */
  125. Elf64_Quarter e_phnum; /* Number of program headers */
  126. Elf64_Quarter e_shentsize; /* Section header entry size */
  127. Elf64_Quarter e_shnum; /* Number of section headers */
  128. Elf64_Quarter e_shstrndx; /* String table index */
  129. } Elf64_Ehdr;
  130. /* e_type */
  131. #define ET_NONE 0 /* No file type */
  132. #define ET_REL 1 /* relocatable file */
  133. #define ET_EXEC 2 /* executable file */
  134. #define ET_DYN 3 /* shared object file */
  135. #define ET_CORE 4 /* core file */
  136. #define ET_NUM 5 /* number of types */
  137. #define ET_LOPROC 0xff00 /* reserved range for processor */
  138. #define ET_HIPROC 0xffff /* specific e_type */
  139. /* e_machine */
  140. #define EM_NONE 0 /* No Machine */
  141. #define EM_M32 1 /* AT&T WE 32100 */
  142. #define EM_SPARC 2 /* SPARC */
  143. #define EM_386 3 /* Intel 80386 */
  144. #define EM_68K 4 /* Motorola 68000 */
  145. #define EM_88K 5 /* Motorola 88000 */
  146. #define EM_486 6 /* Intel 80486 - unused? */
  147. #define EM_860 7 /* Intel 80860 */
  148. #define EM_MIPS 8 /* MIPS R3000 Big-Endian only */
  149. /*
  150. * Don't know if EM_MIPS_RS4_BE,
  151. * EM_SPARC64, EM_PARISC,
  152. * or EM_PPC are ABI compliant
  153. */
  154. #define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
  155. #define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */
  156. #define EM_PARISC 15 /* HPPA */
  157. #define EM_SPARC32PLUS 18 /* Enhanced instruction set SPARC */
  158. #define EM_PPC 20 /* PowerPC */
  159. #define EM_PPC64 21 /* PowerPC 64-bit */
  160. #define EM_ARM 40 /* Advanced RISC Machines ARM */
  161. #define EM_ALPHA 41 /* DEC ALPHA */
  162. #define EM_SPARCV9 43 /* SPARC version 9 */
  163. #define EM_ALPHA_EXP 0x9026 /* DEC ALPHA */
  164. #define EM_IA_64 50 /* Intel Merced */
  165. #define EM_X86_64 62 /* AMD x86-64 architecture */
  166. #define EM_VAX 75 /* DEC VAX */
  167. /* Version */
  168. #define EV_NONE 0 /* Invalid */
  169. #define EV_CURRENT 1 /* Current */
  170. #define EV_NUM 2 /* number of versions */
  171. /* Section Header */
  172. typedef struct {
  173. Elf32_Word sh_name; /* name - index into section header
  174. string table section */
  175. Elf32_Word sh_type; /* type */
  176. Elf32_Word sh_flags; /* flags */
  177. Elf32_Addr sh_addr; /* address */
  178. Elf32_Off sh_offset; /* file offset */
  179. Elf32_Word sh_size; /* section size */
  180. Elf32_Word sh_link; /* section header table index link */
  181. Elf32_Word sh_info; /* extra information */
  182. Elf32_Word sh_addralign; /* address alignment */
  183. Elf32_Word sh_entsize; /* section entry size */
  184. } Elf32_Shdr;
  185. typedef struct {
  186. Elf64_Half sh_name; /* section name */
  187. Elf64_Half sh_type; /* section type */
  188. Elf64_Xword sh_flags; /* section flags */
  189. Elf64_Addr sh_addr; /* virtual address */
  190. Elf64_Off sh_offset; /* file offset */
  191. Elf64_Xword sh_size; /* section size */
  192. Elf64_Half sh_link; /* link to another */
  193. Elf64_Half sh_info; /* misc info */
  194. Elf64_Xword sh_addralign; /* memory alignment */
  195. Elf64_Xword sh_entsize; /* table entry size */
  196. } Elf64_Shdr;
  197. /* Special Section Indexes */
  198. #define SHN_UNDEF 0 /* undefined */
  199. #define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
  200. #define SHN_LOPROC 0xff00 /* reserved range for processor */
  201. #define SHN_HIPROC 0xff1f /* specific section indexes */
  202. #define SHN_ABS 0xfff1 /* absolute value */
  203. #define SHN_COMMON 0xfff2 /* common symbol */
  204. #define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
  205. /* sh_type */
  206. #define SHT_NULL 0 /* inactive */
  207. #define SHT_PROGBITS 1 /* program defined information */
  208. #define SHT_SYMTAB 2 /* symbol table section */
  209. #define SHT_STRTAB 3 /* string table section */
  210. #define SHT_RELA 4 /* relocation section with addends*/
  211. #define SHT_HASH 5 /* symbol hash table section */
  212. #define SHT_DYNAMIC 6 /* dynamic section */
  213. #define SHT_NOTE 7 /* note section */
  214. #define SHT_NOBITS 8 /* no space section */
  215. #define SHT_REL 9 /* relation section without addends */
  216. #define SHT_SHLIB 10 /* reserved - purpose unknown */
  217. #define SHT_DYNSYM 11 /* dynamic symbol table section */
  218. #define SHT_NUM 12 /* number of section types */
  219. #define SHT_LOPROC 0x70000000 /* reserved range for processor */
  220. #define SHT_HIPROC 0x7fffffff /* specific section header types */
  221. #define SHT_LOUSER 0x80000000 /* reserved range for application */
  222. #define SHT_HIUSER 0xffffffff /* specific indexes */
  223. /* Section names */
  224. #define ELF_BSS ".bss" /* uninitialized data */
  225. #define ELF_DATA ".data" /* initialized data */
  226. #define ELF_DEBUG ".debug" /* debug */
  227. #define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
  228. #define ELF_DYNSTR ".dynstr" /* dynamic string table */
  229. #define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
  230. #define ELF_FINI ".fini" /* termination code */
  231. #define ELF_GOT ".got" /* global offset table */
  232. #define ELF_HASH ".hash" /* symbol hash table */
  233. #define ELF_INIT ".init" /* initialization code */
  234. #define ELF_REL_DATA ".rel.data" /* relocation data */
  235. #define ELF_REL_FINI ".rel.fini" /* relocation termination code */
  236. #define ELF_REL_INIT ".rel.init" /* relocation initialization code */
  237. #define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */
  238. #define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
  239. #define ELF_REL_TEXT ".rel.text" /* relocation code */
  240. #define ELF_RODATA ".rodata" /* read-only data */
  241. #define ELF_SHSTRTAB ".shstrtab" /* section header string table */
  242. #define ELF_STRTAB ".strtab" /* string table */
  243. #define ELF_SYMTAB ".symtab" /* symbol table */
  244. #define ELF_TEXT ".text" /* code */
  245. /* Section Attribute Flags - sh_flags */
  246. #define SHF_WRITE 0x1 /* Writable */
  247. #define SHF_ALLOC 0x2 /* occupies memory */
  248. #define SHF_EXECINSTR 0x4 /* executable */
  249. #define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
  250. /* specific section attributes */
  251. /* Symbol Table Entry */
  252. typedef struct elf32_sym {
  253. Elf32_Word st_name; /* name - index into string table */
  254. Elf32_Addr st_value; /* symbol value */
  255. Elf32_Word st_size; /* symbol size */
  256. unsigned char st_info; /* type and binding */
  257. unsigned char st_other; /* 0 - no defined meaning */
  258. Elf32_Half st_shndx; /* section header index */
  259. } Elf32_Sym;
  260. typedef struct {
  261. Elf64_Half st_name; /* Symbol name index in str table */
  262. Elf_Byte st_info; /* type / binding attrs */
  263. Elf_Byte st_other; /* unused */
  264. Elf64_Quarter st_shndx; /* section index of symbol */
  265. Elf64_Xword st_value; /* value of symbol */
  266. Elf64_Xword st_size; /* size of symbol */
  267. } Elf64_Sym;
  268. /* Symbol table index */
  269. #define STN_UNDEF 0 /* undefined */
  270. /* Extract symbol info - st_info */
  271. #define ELF32_ST_BIND(x) ((x) >> 4)
  272. #define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
  273. #define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
  274. #define ELF64_ST_BIND(x) ((x) >> 4)
  275. #define ELF64_ST_TYPE(x) (((unsigned int) x) & 0xf)
  276. #define ELF64_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
  277. /* Symbol Binding - ELF32_ST_BIND - st_info */
  278. #define STB_LOCAL 0 /* Local symbol */
  279. #define STB_GLOBAL 1 /* Global symbol */
  280. #define STB_WEAK 2 /* like global - lower precedence */
  281. #define STB_NUM 3 /* number of symbol bindings */
  282. #define STB_LOPROC 13 /* reserved range for processor */
  283. #define STB_HIPROC 15 /* specific symbol bindings */
  284. /* Symbol type - ELF32_ST_TYPE - st_info */
  285. #define STT_NOTYPE 0 /* not specified */
  286. #define STT_OBJECT 1 /* data object */
  287. #define STT_FUNC 2 /* function */
  288. #define STT_SECTION 3 /* section */
  289. #define STT_FILE 4 /* file */
  290. #define STT_NUM 5 /* number of symbol types */
  291. #define STT_LOPROC 13 /* reserved range for processor */
  292. #define STT_HIPROC 15 /* specific symbol types */
  293. /* Relocation entry with implicit addend */
  294. typedef struct {
  295. Elf32_Addr r_offset; /* offset of relocation */
  296. Elf32_Word r_info; /* symbol table index and type */
  297. } Elf32_Rel;
  298. /* Relocation entry with explicit addend */
  299. typedef struct {
  300. Elf32_Addr r_offset; /* offset of relocation */
  301. Elf32_Word r_info; /* symbol table index and type */
  302. Elf32_Sword r_addend;
  303. } Elf32_Rela;
  304. /* Extract relocation info - r_info */
  305. #define ELF32_R_SYM(i) ((i) >> 8)
  306. #define ELF32_R_TYPE(i) ((unsigned char) (i))
  307. #define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
  308. typedef struct {
  309. Elf64_Xword r_offset; /* where to do it */
  310. Elf64_Xword r_info; /* index & type of relocation */
  311. } Elf64_Rel;
  312. typedef struct {
  313. Elf64_Xword r_offset; /* where to do it */
  314. Elf64_Xword r_info; /* index & type of relocation */
  315. Elf64_Sxword r_addend; /* adjustment value */
  316. } Elf64_Rela;
  317. #define ELF64_R_SYM(info) ((info) >> 32)
  318. #define ELF64_R_TYPE(info) ((info) & 0xFFFFFFFF)
  319. #define ELF64_R_INFO(s,t) (((s) << 32) + (u_int32_t)(t))
  320. /* Program Header */
  321. typedef struct {
  322. Elf32_Word p_type; /* segment type */
  323. Elf32_Off p_offset; /* segment offset */
  324. Elf32_Addr p_vaddr; /* virtual address of segment */
  325. Elf32_Addr p_paddr; /* physical address - ignored? */
  326. Elf32_Word p_filesz; /* number of bytes in file for seg. */
  327. Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
  328. Elf32_Word p_flags; /* flags */
  329. Elf32_Word p_align; /* memory alignment */
  330. } Elf32_Phdr;
  331. typedef struct {
  332. Elf64_Half p_type; /* entry type */
  333. Elf64_Half p_flags; /* flags */
  334. Elf64_Off p_offset; /* offset */
  335. Elf64_Addr p_vaddr; /* virtual address */
  336. Elf64_Addr p_paddr; /* physical address */
  337. Elf64_Xword p_filesz; /* file size */
  338. Elf64_Xword p_memsz; /* memory size */
  339. Elf64_Xword p_align; /* memory & file alignment */
  340. } Elf64_Phdr;
  341. /* Segment types - p_type */
  342. #define PT_NULL 0 /* unused */
  343. #define PT_LOAD 1 /* loadable segment */
  344. #define PT_DYNAMIC 2 /* dynamic linking section */
  345. #define PT_INTERP 3 /* the RTLD */
  346. #define PT_NOTE 4 /* auxiliary information */
  347. #define PT_SHLIB 5 /* reserved - purpose undefined */
  348. #define PT_PHDR 6 /* program header */
  349. #define PT_NUM 7 /* Number of segment types */
  350. #define PT_LOPROC 0x70000000 /* reserved range for processor */
  351. #define PT_HIPROC 0x7fffffff /* specific segment types */
  352. /* Segment flags - p_flags */
  353. #define PF_X 0x1 /* Executable */
  354. #define PF_W 0x2 /* Writable */
  355. #define PF_R 0x4 /* Readable */
  356. #define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
  357. /* specific segment flags */
  358. /* Dynamic structure */
  359. typedef struct {
  360. Elf32_Sword d_tag; /* controls meaning of d_val */
  361. union {
  362. Elf32_Word d_val; /* Multiple meanings - see d_tag */
  363. Elf32_Addr d_ptr; /* program virtual address */
  364. } d_un;
  365. } Elf32_Dyn;
  366. typedef struct {
  367. Elf64_Xword d_tag; /* controls meaning of d_val */
  368. union {
  369. Elf64_Addr d_ptr;
  370. Elf64_Xword d_val;
  371. } d_un;
  372. } Elf64_Dyn;
  373. /* Dynamic Array Tags - d_tag */
  374. #define DT_NULL 0 /* marks end of _DYNAMIC array */
  375. #define DT_NEEDED 1 /* string table offset of needed lib */
  376. #define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
  377. #define DT_PLTGOT 3 /* address PLT/GOT */
  378. #define DT_HASH 4 /* address of symbol hash table */
  379. #define DT_STRTAB 5 /* address of string table */
  380. #define DT_SYMTAB 6 /* address of symbol table */
  381. #define DT_RELA 7 /* address of relocation table */
  382. #define DT_RELASZ 8 /* size of relocation table */
  383. #define DT_RELAENT 9 /* size of relocation entry */
  384. #define DT_STRSZ 10 /* size of string table */
  385. #define DT_SYMENT 11 /* size of symbol table entry */
  386. #define DT_INIT 12 /* address of initialization func. */
  387. #define DT_FINI 13 /* address of termination function */
  388. #define DT_SONAME 14 /* string table offset of shared obj */
  389. #define DT_RPATH 15 /* string table offset of library
  390. search path */
  391. #define DT_SYMBOLIC 16 /* start sym search in shared obj. */
  392. #define DT_REL 17 /* address of rel. tbl. w addends */
  393. #define DT_RELSZ 18 /* size of DT_REL relocation table */
  394. #define DT_RELENT 19 /* size of DT_REL relocation entry */
  395. #define DT_PLTREL 20 /* PLT referenced relocation entry */
  396. #define DT_DEBUG 21 /* bugger */
  397. #define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
  398. #define DT_JMPREL 23 /* add. of PLT's relocation entries */
  399. #define DT_BIND_NOW 24 /* Bind now regardless of env setting */
  400. #define DT_NUM 25 /* Number used. */
  401. #define DT_LOPROC 0x70000000 /* reserved range for processor */
  402. #define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
  403. /* Standard ELF hashing function */
  404. unsigned int elf_hash(const unsigned char *name);
  405. /*
  406. * Note Definitions
  407. */
  408. typedef struct {
  409. Elf32_Word namesz;
  410. Elf32_Word descsz;
  411. Elf32_Word type;
  412. } Elf32_Note;
  413. typedef struct {
  414. Elf64_Half namesz;
  415. Elf64_Half descsz;
  416. Elf64_Half type;
  417. } Elf64_Note;
  418. #if defined(ELFSIZE)
  419. #define CONCAT(x,y) __CONCAT(x,y)
  420. #define ELFNAME(x) CONCAT(elf,CONCAT(ELFSIZE,CONCAT(_,x)))
  421. #define ELFNAME2(x,y) CONCAT(x,CONCAT(_elf,CONCAT(ELFSIZE,CONCAT(_,y))))
  422. #define ELFNAMEEND(x) CONCAT(x,CONCAT(_elf,ELFSIZE))
  423. #define ELFDEFNNAME(x) CONCAT(ELF,CONCAT(ELFSIZE,CONCAT(_,x)))
  424. #endif
  425. #if defined(ELFSIZE) && (ELFSIZE == 32)
  426. #define Elf_Ehdr Elf32_Ehdr
  427. #define Elf_Phdr Elf32_Phdr
  428. #define Elf_Shdr Elf32_Shdr
  429. #define Elf_Sym Elf32_Sym
  430. #define Elf_Rel Elf32_Rel
  431. #define Elf_RelA Elf32_Rela
  432. #define Elf_Dyn Elf32_Dyn
  433. #define Elf_Word Elf32_Word
  434. #define Elf_Sword Elf32_Sword
  435. #define Elf_Addr Elf32_Addr
  436. #define Elf_Off Elf32_Off
  437. #define Elf_Nhdr Elf32_Nhdr
  438. #define Elf_Note Elf32_Note
  439. #define ELF_R_SYM ELF32_R_SYM
  440. #define ELF_R_TYPE ELF32_R_TYPE
  441. #define ELF_R_INFO ELF32_R_INFO
  442. #define ELFCLASS ELFCLASS32
  443. #define ELF_ST_BIND ELF32_ST_BIND
  444. #define ELF_ST_TYPE ELF32_ST_TYPE
  445. #define ELF_ST_INFO ELF32_ST_INFO
  446. #define AuxInfo Aux32Info
  447. #elif defined(ELFSIZE) && (ELFSIZE == 64)
  448. #define Elf_Ehdr Elf64_Ehdr
  449. #define Elf_Phdr Elf64_Phdr
  450. #define Elf_Shdr Elf64_Shdr
  451. #define Elf_Sym Elf64_Sym
  452. #define Elf_Rel Elf64_Rel
  453. #define Elf_RelA Elf64_Rela
  454. #define Elf_Dyn Elf64_Dyn
  455. #define Elf_Word Elf64_Word
  456. #define Elf_Sword Elf64_Sword
  457. #define Elf_Addr Elf64_Addr
  458. #define Elf_Off Elf64_Off
  459. #define Elf_Nhdr Elf64_Nhdr
  460. #define Elf_Note Elf64_Note
  461. #define ELF_R_SYM ELF64_R_SYM
  462. #define ELF_R_TYPE ELF64_R_TYPE
  463. #define ELF_R_INFO ELF64_R_INFO
  464. #define ELFCLASS ELFCLASS64
  465. #define ELF_ST_BIND ELF64_ST_BIND
  466. #define ELF_ST_TYPE ELF64_ST_TYPE
  467. #define ELF_ST_INFO ELF64_ST_INFO
  468. #define AuxInfo Aux64Info
  469. #endif
  470. #endif /* __XEN_PUBLIC_ELFSTRUCTS_H__ */