1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:28:11 +00:00

X86+Profiler+UserspaceEmulator: Deduplicate ELFSymbolProvider to LibX86

From a layering perspective, it's maybe a bit surprising that the
X86::SymbolProvider implementation also lives in LibX86, but since
everything depends on LibELF via LibC, and since all current
LibX86-based disassemblers want to use ELFSymbolProvider, it makes
some amount of sense to put it there.
This commit is contained in:
Nico Weber 2020-08-15 20:01:35 -04:00 committed by Andreas Kling
parent d396766058
commit fd73de684e
3 changed files with 52 additions and 34 deletions

View file

@ -32,6 +32,7 @@
#include <AK/LexicalPath.h>
#include <AK/LogStream.h>
#include <Kernel/API/Syscall.h>
#include <LibX86/ELFSymbolProvider.h>
#include <fcntl.h>
#include <serenity.h>
#include <stdio.h>
@ -157,25 +158,9 @@ bool Emulator::load_elf()
return true;
}
class ELFSymbolProvider final : public X86::SymbolProvider {
public:
ELFSymbolProvider(ELF::Loader& loader)
: m_loader(loader)
{
}
virtual String symbolicate(FlatPtr address, u32* offset = nullptr) const
{
return m_loader.symbolicate(address, offset);
}
private:
ELF::Loader& m_loader;
};
int Emulator::exec()
{
ELFSymbolProvider symbol_provider(*m_elf);
X86::ELFSymbolProvider symbol_provider(*m_elf);
bool trace = false;