diff options
author | Andreas Kling <kling@serenityos.org> | 2020-12-25 02:14:56 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-25 02:14:56 +0100 |
commit | 1e4c01064351d2f8ce3d55a173c5022d2601ad40 (patch) | |
tree | 07397a8f13d69ea15a191a0a16e58cedd35d8a10 /Userland/disasm.cpp | |
parent | 7551a66f738ccd5f3f78e25493b46479ad50851d (diff) | |
download | serenity-1e4c01064351d2f8ce3d55a173c5022d2601ad40.zip |
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.
Diffstat (limited to 'Userland/disasm.cpp')
-rw-r--r-- | Userland/disasm.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Userland/disasm.cpp b/Userland/disasm.cpp index 6d3a82d047..4189499000 100644 --- a/Userland/disasm.cpp +++ b/Userland/disasm.cpp @@ -29,7 +29,7 @@ #include <AK/QuickSort.h> #include <AK/Vector.h> #include <LibCore/ArgsParser.h> -#include <LibELF/Loader.h> +#include <LibELF/Image.h> #include <LibX86/Disassembler.h> #include <LibX86/ELFSymbolProvider.h> #include <stdio.h> @@ -70,14 +70,13 @@ int main(int argc, char** argv) size_t asm_size = file.size(); size_t file_offset = 0; Vector<Symbol>::Iterator current_symbol = symbols.begin(); - RefPtr<ELF::Loader> elf; OwnPtr<X86::ELFSymbolProvider> symbol_provider; // nullptr for non-ELF disassembly. + OwnPtr<ELF::Image> elf; if (asm_size >= 4 && strncmp((const char*)asm_data, "\u007fELF", 4) == 0) { - NonnullRefPtr<ELF::Loader> elf_loader = ELF::Loader::create(asm_data, asm_size); - if (elf_loader->image().is_valid()) { - elf = elf_loader; + elf = make<ELF::Image>(asm_data, asm_size); + if (elf->is_valid()) { symbol_provider = make<X86::ELFSymbolProvider>(*elf); - elf->image().for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) { + elf->for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) { // FIXME: Disassemble all SHT_PROGBITS sections, not just .text. if (section.name() != ".text") return IterationDecision::Continue; @@ -86,9 +85,9 @@ int main(int argc, char** argv) file_offset = section.address(); return IterationDecision::Break; }); - symbols.ensure_capacity(elf->image().symbol_count() + 1); + symbols.ensure_capacity(elf->symbol_count() + 1); symbols.append({ 0, 0, StringView() }); // Sentinel. - elf->image().for_each_symbol([&](const ELF::Image::Symbol& symbol) { + elf->for_each_symbol([&](const ELF::Image::Symbol& symbol) { symbols.append({ symbol.value(), symbol.size(), symbol.name() }); return IterationDecision::Continue; }); |