Move internal elf macros to a private header
[lttng-ust.git] / include / lttng / ust-elf.h
CommitLineData
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
14struct 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
30struct 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
39struct 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
52struct lttng_ust_elf_nhdr {
53 uint32_t n_namesz;
54 uint32_t n_descsz;
55 uint32_t n_type;
56};
57
58struct 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
70struct lttng_ust_elf *lttng_ust_elf_create(const char *path);
71void lttng_ust_elf_destroy(struct lttng_ust_elf *elf);
f5eb039d 72uint8_t lttng_ust_elf_is_pic(struct lttng_ust_elf *elf);
8e2aed3f
AB
73int lttng_ust_elf_get_memsz(struct lttng_ust_elf *elf, uint64_t *memsz);
74int lttng_ust_elf_get_build_id(struct lttng_ust_elf *elf, uint8_t **build_id,
75 size_t *length, int *found);
76int 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 */
This page took 0.027722 seconds and 4 git commands to generate.