Commit | Line | Data |
---|---|---|
8e2aed3f | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: LGPL-2.1-or-later |
8e2aed3f | 3 | * |
c0c0989a | 4 | * Copyright (C) 2015 Antoine Busque <abusque@efficios.com> |
8e2aed3f AB |
5 | */ |
6 | ||
c0c0989a MJ |
7 | #ifndef _LTTNG_UST_ELF_H |
8 | #define _LTTNG_UST_ELF_H | |
9 | ||
8e2aed3f AB |
10 | #include <stdlib.h> |
11 | #include <stdint.h> | |
12 | #include <stdio.h> | |
8e2aed3f AB |
13 | |
14 | struct lttng_ust_elf_ehdr { | |
15 | uint16_t e_type; | |
16 | uint16_t e_machine; | |
17 | uint32_t e_version; | |
18 | uint64_t e_entry; | |
19 | uint64_t e_phoff; | |
20 | uint64_t e_shoff; | |
21 | uint32_t e_flags; | |
22 | uint16_t e_ehsize; | |
23 | uint16_t e_phentsize; | |
24 | uint16_t e_phnum; | |
25 | uint16_t e_shentsize; | |
26 | uint16_t e_shnum; | |
27 | uint16_t e_shstrndx; | |
28 | }; | |
29 | ||
30 | struct lttng_ust_elf_phdr { | |
31 | uint32_t p_type; | |
32 | uint64_t p_offset; | |
33 | uint64_t p_filesz; | |
34 | uint64_t p_memsz; | |
35 | uint64_t p_align; | |
e1f0c569 | 36 | uint64_t p_vaddr; |
8e2aed3f AB |
37 | }; |
38 | ||
39 | struct lttng_ust_elf_shdr { | |
40 | uint32_t sh_name; | |
41 | uint32_t sh_type; | |
42 | uint64_t sh_flags; | |
43 | uint64_t sh_addr; | |
44 | uint64_t sh_offset; | |
45 | uint64_t sh_size; | |
46 | uint32_t sh_link; | |
47 | uint32_t sh_info; | |
48 | uint64_t sh_addralign; | |
49 | uint64_t sh_entsize; | |
50 | }; | |
51 | ||
52 | struct lttng_ust_elf_nhdr { | |
53 | uint32_t n_namesz; | |
54 | uint32_t n_descsz; | |
55 | uint32_t n_type; | |
56 | }; | |
57 | ||
58 | struct lttng_ust_elf { | |
59 | /* Offset in bytes to start of section names string table. */ | |
f5a6717a | 60 | off_t section_names_offset; |
8e2aed3f | 61 | /* Size in bytes of section names string table. */ |
f5a6717a | 62 | size_t section_names_size; |
8e2aed3f | 63 | char *path; |
405be658 | 64 | int fd; |
8e2aed3f AB |
65 | struct lttng_ust_elf_ehdr *ehdr; |
66 | uint8_t bitness; | |
67 | uint8_t endianness; | |
68 | }; | |
69 | ||
8e2aed3f AB |
70 | struct lttng_ust_elf *lttng_ust_elf_create(const char *path); |
71 | void lttng_ust_elf_destroy(struct lttng_ust_elf *elf); | |
f5eb039d | 72 | uint8_t lttng_ust_elf_is_pic(struct lttng_ust_elf *elf); |
8e2aed3f AB |
73 | int lttng_ust_elf_get_memsz(struct lttng_ust_elf *elf, uint64_t *memsz); |
74 | int lttng_ust_elf_get_build_id(struct lttng_ust_elf *elf, uint8_t **build_id, | |
75 | size_t *length, int *found); | |
76 | int lttng_ust_elf_get_debug_link(struct lttng_ust_elf *elf, char **filename, | |
77 | uint32_t *crc, int *found); | |
78 | ||
79 | #endif /* _LTTNG_UST_ELF_H */ |