xref: /haiku/src/tools/elfsymbolpatcher/Elf.h (revision 78058cf6d5c26d1a66584d0033c6fff5f3fd60d5)
1*78058cf6SKacper Kasper /*
2*78058cf6SKacper Kasper  * Copyright 2002-2016 Haiku, Inc. All rights reserved.
3*78058cf6SKacper Kasper  * Distributed under the terms of the MIT License.
4*78058cf6SKacper Kasper  */
5*78058cf6SKacper Kasper #ifndef SYMBOLPATCHER_ELF_H
6*78058cf6SKacper Kasper #define SYMBOLPATCHER_ELF_H
7e79e4e7cSIngo Weinhold 
8e79e4e7cSIngo Weinhold 
9*78058cf6SKacper Kasper #include <elf.h>
10e79e4e7cSIngo Weinhold 
11*78058cf6SKacper Kasper /* Relocation types. */
12*78058cf6SKacper Kasper #define R_X86_64_NONE				0	/* No relocation. */
13*78058cf6SKacper Kasper #define R_X86_64_GLOB_DAT			6	/* Create GOT entry. */
14*78058cf6SKacper Kasper #define R_X86_64_JUMP_SLOT			7	/* Create PLT entry. */
15e79e4e7cSIngo Weinhold 
16e79e4e7cSIngo Weinhold #define R_386_NONE		0
17*78058cf6SKacper Kasper #define R_386_GLOB_DAT	6	/* set GOT entry to data address */
18*78058cf6SKacper Kasper #define R_386_JMP_SLOT	7	/* set GOT entry to code address */
19e79e4e7cSIngo Weinhold 
20*78058cf6SKacper Kasper #ifdef B_HAIKU_64_BIT
21*78058cf6SKacper Kasper typedef Elf64_Ehdr Elf_Ehdr;
22*78058cf6SKacper Kasper typedef Elf64_Shdr Elf_Shdr;
23*78058cf6SKacper Kasper typedef Elf64_Sym Elf_Sym;
24*78058cf6SKacper Kasper typedef Elf64_Rel Elf_Rel;
25*78058cf6SKacper Kasper typedef Elf64_Addr Elf_Addr;
26*78058cf6SKacper Kasper typedef Elf64_Word Elf_Word;
27*78058cf6SKacper Kasper #define ELFCLASS ELFCLASS64
28*78058cf6SKacper Kasper #define ELF_ST_BIND ELF64_ST_BIND
29*78058cf6SKacper Kasper #define ELF_ST_TYPE ELF64_ST_TYPE
30*78058cf6SKacper Kasper #define ELF_R_SYM ELF64_R_SYM
31*78058cf6SKacper Kasper #define ELF_R_TYPE ELF64_R_TYPE
32*78058cf6SKacper Kasper #define R_NONE R_X86_64_NONE
33*78058cf6SKacper Kasper #define R_GLOB_DAT R_X86_64_GLOB_DAT
34*78058cf6SKacper Kasper #define R_JUMP_SLOT R_X86_64_JUMP_SLOT
35*78058cf6SKacper Kasper #else
36*78058cf6SKacper Kasper typedef Elf32_Ehdr Elf_Ehdr;
37*78058cf6SKacper Kasper typedef Elf32_Shdr Elf_Shdr;
38*78058cf6SKacper Kasper typedef Elf32_Sym Elf_Sym;
39*78058cf6SKacper Kasper typedef Elf32_Rel Elf_Rel;
40*78058cf6SKacper Kasper typedef Elf32_Addr Elf_Addr;
41*78058cf6SKacper Kasper typedef Elf32_Word Elf_Word;
42*78058cf6SKacper Kasper #define ELFCLASS ELFCLASS32
43*78058cf6SKacper Kasper #define ELF_ST_BIND ELF32_ST_BIND
44*78058cf6SKacper Kasper #define ELF_ST_TYPE ELF32_ST_TYPE
45*78058cf6SKacper Kasper #define ELF_R_SYM ELF32_R_SYM
46*78058cf6SKacper Kasper #define ELF_R_TYPE ELF32_R_TYPE
47*78058cf6SKacper Kasper #define R_NONE R_386_NONE
48*78058cf6SKacper Kasper #define R_GLOB_DAT R_386_GLOB_DAT
49*78058cf6SKacper Kasper #define R_JUMP_SLOT R_386_JMP_SLOT
50*78058cf6SKacper Kasper #endif
51e79e4e7cSIngo Weinhold 
52e79e4e7cSIngo Weinhold 
53*78058cf6SKacper Kasper #endif	/* SYMBOLPATCHER_ELF_H */
54