From b66a9f978f270bdb48a2c8542930157aa5c9e416 Mon Sep 17 00:00:00 2001 From: Bernhard Heinloth <heinloth@cs.fau.de> Date: Fri, 23 Feb 2024 12:17:55 +0100 Subject: [PATCH] Update relocation interface --- elfo | 2 +- src/analyze_x86.hpp | 2 +- src/bean.cpp | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/elfo b/elfo index a6d1ca7..770f9ee 160000 --- a/elfo +++ b/elfo @@ -1 +1 @@ -Subproject commit a6d1ca74b98b7a74a7983db5d55711d78df31aad +Subproject commit 770f9ee1309d1c1f4f3deb2310525319781af61c diff --git a/src/analyze_x86.hpp b/src/analyze_x86.hpp index a8376d0..8875391 100644 --- a/src/analyze_x86.hpp +++ b/src/analyze_x86.hpp @@ -327,7 +327,7 @@ class AnalyzeX86 : public Analyze<C> { this->debug_stream << " \e[3m["; if (relocation->symbol_index() == 0) { // No Symbol - calculate target value and add as reference - Bean::dump_address(this->debug_stream, Relocator(*relocation).value(0), this->symbols); + Bean::dump_address(this->debug_stream, Relocator(*relocation).value(), this->symbols); } else { // Get relocation symbol const auto rel_sym = relocation->symbol(); diff --git a/src/bean.cpp b/src/bean.cpp index b9269da..ee3e184 100644 --- a/src/bean.cpp +++ b/src/bean.cpp @@ -52,7 +52,7 @@ Bean::SymbolRelocation::SymbolRelocation(const typename ELF<ELF_Def::Identificat if (is(machine).in(Elf::EM_386, Elf::EM_486) && relocation.type() == ELF<ELF_Def::Identification::ELFCLASS64>::R_386_RELATIVE) target = addend; else if (resolve_target) - target = Relocator(relocation, global_offset_table).value(0); + target = Relocator(relocation, global_offset_table).value(); } } @@ -72,7 +72,7 @@ Bean::SymbolRelocation::SymbolRelocation(const typename ELF<ELF_Def::Identificat if (machine == Elf::EM_X86_64 && is(relocation.type()).in(ELF<ELF_Def::Identification::ELFCLASS64>::R_X86_64_RELATIVE, ELF<ELF_Def::Identification::ELFCLASS64>::R_X86_64_RELATIVE64)) target = addend; else if (resolve_target) - target = Relocator(relocation, global_offset_table).value(0); + target = Relocator(relocation, global_offset_table).value(); } } @@ -250,6 +250,7 @@ TreeMap<uintptr_t, uintptr_t> Bean::map(const Bean & other, bool use_symbol_name continue; else if (const auto & map_sym = mapping.find(sym.address)) if (const auto & other_sym = other.symbols.find(map_sym->value)) + // TODO: If at least one relocation points to a skipped internal id, do not proceed for this symbol for (const auto & rel : sym.rels) if ((rel.instruction_access & Bean::SymbolRelocation::ACCESSFLAG_BRANCH) != 0 && (rel.instruction_access & Bean::SymbolRelocation::ACCESSFLAG_LOCAL) != 0) { const auto offset = rel.target - sym.address; -- GitLab