Linux: Resolve backtrace symbols directly from .symtab instead of .dynsym (#385)

This commit is contained in:
goeiecool9999 2022-10-20 13:12:16 +02:00 committed by GitHub
parent 271a4e4719
commit 9df1325d14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 182 additions and 16 deletions

View file

@ -0,0 +1,32 @@
#pragma once
#include <memory>
#include <elf.h>
class ELFSymbolTable
{
public:
std::string_view OffsetToSymbol(uint64 ptr, uint64& fromStart) const;
ELFSymbolTable();
~ELFSymbolTable();
private:
uint8* mappedExecutable = nullptr;
size_t mappedExecutableSize = 0;
Elf64_Ehdr* header = nullptr;
Elf64_Shdr* shTable = nullptr;
char* shStrTable = nullptr;
Elf64_Sym* symTable = nullptr;
uint64 symTableLen = 0;
char* strTable = nullptr;
uint16 FindSection(int type, const std::string_view& name);
void* SectionPointer (uint16 index);
void* SectionPointer(const Elf64_Shdr& section);
// ownership of mapped memory, cannot copy.
ELFSymbolTable(const ELFSymbolTable&) = delete;
};