1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef _ELF_HELPER_H
6#define _ELF_HELPER_H
7#include <inttypes.h>
8#include <libelf.h>
9#include <gelf.h>
10#include "dwarf/dwarf++.hh"
11#include "elf/elf++.hh"
12
13class SymbolFile {
14public:
15 SymbolFile(uintptr_t base, const char* filename, bool use_dwarf = false);
16 ~SymbolFile(void);
17 bool get_sym_address(const char *symname, unsigned long *addr, elf::stt type);
18
19 bool m_valid;
20 bool m_searched;
21private:
22 uintptr_t m_base;
23
24 elf::elf m_elf;
25 dwarf::dwarf m_dwarf;
26 elf::elf m_elf2; // debug file in /lib/.build-id/xx/xxxx.debug
27
28 // for .symtab + .dynsym
29 elf::symtab m_dynsym;
30 elf::symtab m_symtab;
31};
32
33#endif /*#ifndef _ELF_HELPER_H*/
34