mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 17:35:08 +00:00
LibELF: Remove ELF::Loader and move everyone to ELF::Image
This commit gets rid of ELF::Loader entirely since its very ambiguous purpose was actually to load executables for the kernel, and that is now handled by the kernel itself. This patch includes some drive-by cleanup in LibDebug and CrashDaemon enabled by the fact that we no longer need to keep the ref-counted ELF::Loader around.
This commit is contained in:
parent
7551a66f73
commit
1e4c010643
24 changed files with 178 additions and 318 deletions
|
@ -28,7 +28,7 @@
|
|||
#include <AK/MappedFile.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibDebug/DebugSession.h>
|
||||
#include <LibELF/Loader.h>
|
||||
#include <LibELF/Image.h>
|
||||
#include <LibX86/Disassembler.h>
|
||||
#include <LibX86/ELFSymbolProvider.h>
|
||||
#include <ctype.h>
|
||||
|
@ -44,25 +44,27 @@ DisassemblyModel::DisassemblyModel(const Debug::DebugSession& debug_session, con
|
|||
return;
|
||||
}
|
||||
|
||||
RefPtr<ELF::Loader> elf_loader;
|
||||
OwnPtr<ELF::Image> kernel_elf;
|
||||
const ELF::Image* elf = nullptr;
|
||||
|
||||
if (containing_function.value().address_low >= 0xc0000000) {
|
||||
auto kernel_file = make<MappedFile>("/boot/Kernel");
|
||||
if (!kernel_file->is_valid())
|
||||
return;
|
||||
elf_loader = ELF::Loader::create((const u8*)kernel_file->data(), kernel_file->size());
|
||||
kernel_elf = make<ELF::Image>((const u8*)kernel_file->data(), kernel_file->size());
|
||||
elf = kernel_elf.ptr();
|
||||
} else {
|
||||
elf_loader = debug_session.elf();
|
||||
elf = &debug_session.elf();
|
||||
}
|
||||
|
||||
auto symbol = elf_loader->find_symbol(containing_function.value().address_low);
|
||||
auto symbol = elf->find_symbol(containing_function.value().address_low);
|
||||
if (!symbol.has_value())
|
||||
return;
|
||||
ASSERT(symbol.has_value());
|
||||
|
||||
auto view = symbol.value().raw_data();
|
||||
|
||||
X86::ELFSymbolProvider symbol_provider(*elf_loader);
|
||||
X86::ELFSymbolProvider symbol_provider(*elf);
|
||||
X86::SimpleInstructionStream stream((const u8*)view.characters_without_null_termination(), view.length());
|
||||
X86::Disassembler disassembler(stream);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue