diff options
author | Daniel Bertalan <dani@danielbertalan.dev> | 2023-05-30 15:36:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-06-01 09:04:20 +0200 |
commit | 23be1c5482253662a21be1e9e3a07cc59ec25766 (patch) | |
tree | 6d63513a8a43d10703703a732631b89cc463b9f7 /Userland | |
parent | fb11645a9b409e7a25a86ad20a7cdebe7df56f52 (diff) | |
download | serenity-23be1c5482253662a21be1e9e3a07cc59ec25766.zip |
LibELF: Ignore `$x`/`$d` special symbols when symbolicating AArch64 ELF
Similarly, ignore STT_SECTION symbols, which show up as the empty
string.
This change makes AArch64 backtraces symbolicate correctly.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibELF/Image.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Userland/Libraries/LibELF/Image.cpp b/Userland/Libraries/LibELF/Image.cpp index bd66b3f165..895c768923 100644 --- a/Userland/Libraries/LibELF/Image.cpp +++ b/Userland/Libraries/LibELF/Image.cpp @@ -421,7 +421,16 @@ Optional<Image::Symbol> Image::find_symbol(FlatPtr address, u32* out_offset) con NEVER_INLINE void Image::sort_symbols() const { m_sorted_symbols.ensure_capacity(symbol_count()); - for_each_symbol([this](auto const& symbol) { + bool const is_aarch64 = header().e_machine == EM_AARCH64; + for_each_symbol([this, is_aarch64](auto const& symbol) { + // The AArch64 ABI marks the boundaries of literal pools in a function with $x/$d. + // https://github.com/ARM-software/abi-aa/blob/2023q1-release/aaelf64/aaelf64.rst#mapping-symbols + // Skip them so we don't accidentally print these instead of function names. + if (is_aarch64 && (symbol.name().starts_with("$x"sv) || symbol.name().starts_with("$d"sv))) + return; + // STT_SECTION has the same address as the first function in the section, but shows up as the empty string. + if (symbol.type() == STT_SECTION) + return; m_sorted_symbols.append({ symbol.value(), symbol.name(), {}, symbol }); }); quick_sort(m_sorted_symbols, [](auto& a, auto& b) { |