Merge tag 'iommu-updates-v4.6' of git://git.kernel.org/pub/scm/linux/kernel/git/joro...
[cascardo/linux.git] / tools / perf / util / genelf.h
1 #ifndef __GENELF_H__
2 #define __GENELF_H__
3
4 /* genelf.c */
5 extern int jit_write_elf(int fd, uint64_t code_addr, const char *sym,
6                          const void *code, int csize,
7                          void *debug, int nr_debug_entries);
8 /* genelf_debug.c */
9 extern int jit_add_debug_info(Elf *e, uint64_t code_addr,
10                               void *debug, int nr_debug_entries);
11
12 #if   defined(__arm__)
13 #define GEN_ELF_ARCH    EM_ARM
14 #define GEN_ELF_ENDIAN  ELFDATA2LSB
15 #define GEN_ELF_CLASS   ELFCLASS32
16 #elif defined(__aarch64__)
17 #define GEN_ELF_ARCH    EM_AARCH64
18 #define GEN_ELF_ENDIAN  ELFDATA2LSB
19 #define GEN_ELF_CLASS   ELFCLASS64
20 #elif defined(__x86_64__)
21 #define GEN_ELF_ARCH    EM_X86_64
22 #define GEN_ELF_ENDIAN  ELFDATA2LSB
23 #define GEN_ELF_CLASS   ELFCLASS64
24 #elif defined(__i386__)
25 #define GEN_ELF_ARCH    EM_386
26 #define GEN_ELF_ENDIAN  ELFDATA2LSB
27 #define GEN_ELF_CLASS   ELFCLASS32
28 #elif defined(__ppcle__)
29 #define GEN_ELF_ARCH    EM_PPC
30 #define GEN_ELF_ENDIAN  ELFDATA2LSB
31 #define GEN_ELF_CLASS   ELFCLASS64
32 #elif defined(__powerpc__)
33 #define GEN_ELF_ARCH    EM_PPC64
34 #define GEN_ELF_ENDIAN  ELFDATA2MSB
35 #define GEN_ELF_CLASS   ELFCLASS64
36 #elif defined(__powerpcle__)
37 #define GEN_ELF_ARCH    EM_PPC64
38 #define GEN_ELF_ENDIAN  ELFDATA2LSB
39 #define GEN_ELF_CLASS   ELFCLASS64
40 #else
41 #error "unsupported architecture"
42 #endif
43
44 #if GEN_ELF_CLASS == ELFCLASS64
45 #define elf_newehdr     elf64_newehdr
46 #define elf_getshdr     elf64_getshdr
47 #define Elf_Ehdr        Elf64_Ehdr
48 #define Elf_Shdr        Elf64_Shdr
49 #define Elf_Sym         Elf64_Sym
50 #define ELF_ST_TYPE(a)  ELF64_ST_TYPE(a)
51 #define ELF_ST_BIND(a)  ELF64_ST_BIND(a)
52 #define ELF_ST_VIS(a)   ELF64_ST_VISIBILITY(a)
53 #else
54 #define elf_newehdr     elf32_newehdr
55 #define elf_getshdr     elf32_getshdr
56 #define Elf_Ehdr        Elf32_Ehdr
57 #define Elf_Shdr        Elf32_Shdr
58 #define Elf_Sym         Elf32_Sym
59 #define ELF_ST_TYPE(a)  ELF32_ST_TYPE(a)
60 #define ELF_ST_BIND(a)  ELF32_ST_BIND(a)
61 #define ELF_ST_VIS(a)   ELF32_ST_VISIBILITY(a)
62 #endif
63
64 /* The .text section is directly after the ELF header */
65 #define GEN_ELF_TEXT_OFFSET sizeof(Elf_Ehdr)
66
67 #endif