mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:57:44 +00:00
Kernel+LibELF: Stop doing ELF symbolication in the kernel
Now that the CrashDaemon symbolicates crashes in userspace, let's take this one step further and stop trying to symbolicate userspace programs in the kernel at all.
This commit is contained in:
parent
edf01803cd
commit
d7ad082afa
7 changed files with 11 additions and 98 deletions
|
@ -151,22 +151,6 @@ Optional<Image::Symbol> Loader::find_symbol(u32 address, u32* out_offset) const
|
|||
return {};
|
||||
|
||||
SortedSymbol* sorted_symbols = nullptr;
|
||||
# ifdef KERNEL
|
||||
if (!m_sorted_symbols_region) {
|
||||
m_sorted_symbols_region = MM.allocate_kernel_region(PAGE_ROUND_UP(m_symbol_count * sizeof(SortedSymbol)), "Sorted symbols", Kernel::Region::Access::Read | Kernel::Region::Access::Write);
|
||||
sorted_symbols = (SortedSymbol*)m_sorted_symbols_region->vaddr().as_ptr();
|
||||
size_t index = 0;
|
||||
m_image.for_each_symbol([&](auto& symbol) {
|
||||
sorted_symbols[index++] = { symbol.value(), symbol.name() };
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
quick_sort(sorted_symbols, sorted_symbols + m_symbol_count, [](auto& a, auto& b) {
|
||||
return a.address < b.address;
|
||||
});
|
||||
} else {
|
||||
sorted_symbols = (SortedSymbol*)m_sorted_symbols_region->vaddr().as_ptr();
|
||||
}
|
||||
# else
|
||||
if (m_sorted_symbols.is_empty()) {
|
||||
m_sorted_symbols.ensure_capacity(m_symbol_count);
|
||||
m_image.for_each_symbol([this](auto& symbol) {
|
||||
|
@ -178,7 +162,6 @@ Optional<Image::Symbol> Loader::find_symbol(u32 address, u32* out_offset) const
|
|||
});
|
||||
}
|
||||
sorted_symbols = m_sorted_symbols.data();
|
||||
# endif
|
||||
|
||||
for (size_t i = 0; i < m_symbol_count; ++i) {
|
||||
if (sorted_symbols[i].address > address) {
|
||||
|
@ -192,7 +175,6 @@ Optional<Image::Symbol> Loader::find_symbol(u32 address, u32* out_offset) const
|
|||
}
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
String Loader::symbolicate(u32 address, u32* out_offset) const
|
||||
{
|
||||
|
@ -202,22 +184,7 @@ String Loader::symbolicate(u32 address, u32* out_offset) const
|
|||
return "??";
|
||||
}
|
||||
SortedSymbol* sorted_symbols = nullptr;
|
||||
#ifdef KERNEL
|
||||
if (!m_sorted_symbols_region) {
|
||||
m_sorted_symbols_region = MM.allocate_kernel_region(PAGE_ROUND_UP(m_symbol_count * sizeof(SortedSymbol)), "Sorted symbols", Kernel::Region::Access::Read | Kernel::Region::Access::Write);
|
||||
sorted_symbols = (SortedSymbol*)m_sorted_symbols_region->vaddr().as_ptr();
|
||||
size_t index = 0;
|
||||
m_image.for_each_symbol([&](auto& symbol) {
|
||||
sorted_symbols[index++] = { symbol.value(), symbol.name() };
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
quick_sort(sorted_symbols, sorted_symbols + m_symbol_count, [](auto& a, auto& b) {
|
||||
return a.address < b.address;
|
||||
});
|
||||
} else {
|
||||
sorted_symbols = (SortedSymbol*)m_sorted_symbols_region->vaddr().as_ptr();
|
||||
}
|
||||
#else
|
||||
|
||||
if (m_sorted_symbols.is_empty()) {
|
||||
m_sorted_symbols.ensure_capacity(m_symbol_count);
|
||||
m_image.for_each_symbol([this](auto& symbol) {
|
||||
|
@ -229,7 +196,6 @@ String Loader::symbolicate(u32 address, u32* out_offset) const
|
|||
});
|
||||
}
|
||||
sorted_symbols = m_sorted_symbols.data();
|
||||
#endif
|
||||
|
||||
for (size_t i = 0; i < m_symbol_count; ++i) {
|
||||
if (sorted_symbols[i].address > address) {
|
||||
|
@ -240,14 +206,10 @@ String Loader::symbolicate(u32 address, u32* out_offset) const
|
|||
}
|
||||
auto& symbol = sorted_symbols[i - 1];
|
||||
|
||||
#ifdef KERNEL
|
||||
auto demangled_name = demangle(symbol.name);
|
||||
#else
|
||||
auto& demangled_name = symbol.demangled_name;
|
||||
if (demangled_name.is_null()) {
|
||||
demangled_name = demangle(symbol.name);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (out_offset) {
|
||||
*out_offset = address - symbol.address;
|
||||
|
@ -261,4 +223,6 @@ String Loader::symbolicate(u32 address, u32* out_offset) const
|
|||
return "??";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // end namespace ELF
|
||||
|
|
|
@ -87,9 +87,8 @@ private:
|
|||
Optional<Image::Symbol> symbol;
|
||||
#endif
|
||||
};
|
||||
#ifdef KERNEL
|
||||
mutable OwnPtr<Kernel::Region> m_sorted_symbols_region;
|
||||
#else
|
||||
|
||||
#ifndef KERNEL
|
||||
mutable Vector<SortedSymbol> m_sorted_symbols;
|
||||
#endif
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue