mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:47:34 +00:00
LibELF: Short-circuit symbolication when there are no symbols
This commit is contained in:
parent
4a66de580e
commit
26fb3f7269
1 changed files with 11 additions and 1 deletions
|
@ -151,6 +151,11 @@ char* ELFLoader::symbol_ptr(const char* name)
|
||||||
|
|
||||||
String ELFLoader::symbolicate(u32 address, u32* out_offset) const
|
String ELFLoader::symbolicate(u32 address, u32* out_offset) const
|
||||||
{
|
{
|
||||||
|
if (!m_image.symbol_count()) {
|
||||||
|
if (out_offset)
|
||||||
|
*out_offset = 0;
|
||||||
|
return "??";
|
||||||
|
}
|
||||||
SortedSymbol* sorted_symbols = nullptr;
|
SortedSymbol* sorted_symbols = nullptr;
|
||||||
#ifdef KERNEL
|
#ifdef KERNEL
|
||||||
if (!m_sorted_symbols_region) {
|
if (!m_sorted_symbols_region) {
|
||||||
|
@ -183,8 +188,11 @@ String ELFLoader::symbolicate(u32 address, u32* out_offset) const
|
||||||
|
|
||||||
for (size_t i = 0; i < m_image.symbol_count(); ++i) {
|
for (size_t i = 0; i < m_image.symbol_count(); ++i) {
|
||||||
if (sorted_symbols[i].address > address) {
|
if (sorted_symbols[i].address > address) {
|
||||||
if (i == 0)
|
if (i == 0) {
|
||||||
|
if (out_offset)
|
||||||
|
*out_offset = 0;
|
||||||
return "!!";
|
return "!!";
|
||||||
|
}
|
||||||
auto& symbol = sorted_symbols[i - 1];
|
auto& symbol = sorted_symbols[i - 1];
|
||||||
if (out_offset) {
|
if (out_offset) {
|
||||||
*out_offset = address - symbol.address;
|
*out_offset = address - symbol.address;
|
||||||
|
@ -193,5 +201,7 @@ String ELFLoader::symbolicate(u32 address, u32* out_offset) const
|
||||||
return String::format("%s +%u", demangle(symbol.name).characters(), address - symbol.address);
|
return String::format("%s +%u", demangle(symbol.name).characters(), address - symbol.address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (out_offset)
|
||||||
|
*out_offset = 0;
|
||||||
return "??";
|
return "??";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue