Linux Perf
genelf.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __GENELF_H__
3 #define __GENELF_H__
4 
5 /* genelf.c */
6 int jit_write_elf(int fd, uint64_t code_addr, const char *sym,
7  const void *code, int csize, void *debug, int nr_debug_entries,
8  void *unwinding, uint64_t unwinding_header_size, uint64_t unwinding_size);
9 #ifdef HAVE_DWARF_SUPPORT
10 /* genelf_debug.c */
11 int jit_add_debug_info(Elf *e, uint64_t code_addr, void *debug, int nr_debug_entries);
12 #endif
13 
14 #if defined(__arm__)
15 #define GEN_ELF_ARCH EM_ARM
16 #define GEN_ELF_CLASS ELFCLASS32
17 #elif defined(__aarch64__)
18 #define GEN_ELF_ARCH EM_AARCH64
19 #define GEN_ELF_CLASS ELFCLASS64
20 #elif defined(__x86_64__)
21 #define GEN_ELF_ARCH EM_X86_64
22 #define GEN_ELF_CLASS ELFCLASS64
23 #elif defined(__i386__)
24 #define GEN_ELF_ARCH EM_386
25 #define GEN_ELF_CLASS ELFCLASS32
26 #elif defined(__powerpc64__)
27 #define GEN_ELF_ARCH EM_PPC64
28 #define GEN_ELF_CLASS ELFCLASS64
29 #elif defined(__powerpc__)
30 #define GEN_ELF_ARCH EM_PPC
31 #define GEN_ELF_CLASS ELFCLASS32
32 #else
33 #error "unsupported architecture"
34 #endif
35 
36 #if __BYTE_ORDER == __BIG_ENDIAN
37 #define GEN_ELF_ENDIAN ELFDATA2MSB
38 #else
39 #define GEN_ELF_ENDIAN ELFDATA2LSB
40 #endif
41 
42 #if GEN_ELF_CLASS == ELFCLASS64
43 #define elf_newehdr elf64_newehdr
44 #define elf_getshdr elf64_getshdr
45 #define Elf_Ehdr Elf64_Ehdr
46 #define Elf_Shdr Elf64_Shdr
47 #define Elf_Sym Elf64_Sym
48 #define ELF_ST_TYPE(a) ELF64_ST_TYPE(a)
49 #define ELF_ST_BIND(a) ELF64_ST_BIND(a)
50 #define ELF_ST_VIS(a) ELF64_ST_VISIBILITY(a)
51 #else
52 #define elf_newehdr elf32_newehdr
53 #define elf_getshdr elf32_getshdr
54 #define Elf_Ehdr Elf32_Ehdr
55 #define Elf_Shdr Elf32_Shdr
56 #define Elf_Sym Elf32_Sym
57 #define ELF_ST_TYPE(a) ELF32_ST_TYPE(a)
58 #define ELF_ST_BIND(a) ELF32_ST_BIND(a)
59 #define ELF_ST_VIS(a) ELF32_ST_VISIBILITY(a)
60 #endif
61 
62 /* The .text section is directly after the ELF header */
63 #define GEN_ELF_TEXT_OFFSET sizeof(Elf_Ehdr)
64 
65 #endif
int jit_write_elf(int fd, uint64_t code_addr, const char *sym, const void *code, int csize, void *debug, int nr_debug_entries, void *unwinding, uint64_t unwinding_header_size, uint64_t unwinding_size)
int fd
Definition: genelf.c:63
int jit_add_debug_info(Elf *e, uint64_t code_addr, void *debug, int nr_debug_entries)
Definition: genelf_debug.c:486
static int sym(yyscan_t scanner, int type, int config)