From 1bab71bba6b2777ebe84313dcf22ec7d4edcd1d7 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Thu, 4 Jul 2024 16:50:04 +0800 Subject: Account for rebasing when processing ELF_STT_FUNC entries. Fix https://github.com/Vector35/binaryninja-api/issues/5685 --- view/elf/elfview.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'view/elf/elfview.cpp') diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp index c61a5697..bcfcad7e 100644 --- a/view/elf/elfview.cpp +++ b/view/elf/elfview.cpp @@ -1152,13 +1152,14 @@ bool ElfView::Init() Ref sym = GetSymbolByAddress(gotEntry); if (entry.value && sym && (sym->GetType() == ImportAddressSymbol)) { - Ref targetPlatform = platform->GetAssociatedPlatformByAddress(entry.value); - Ref func = AddFunctionForAnalysis(targetPlatform, entry.value); + uint64_t adjustedAddress = entry.value + imageBaseAdjustment; + Ref targetPlatform = platform->GetAssociatedPlatformByAddress(adjustedAddress); + Ref func = AddFunctionForAnalysis(targetPlatform, adjustedAddress); if (func) { Ref funcSym = new Symbol(ImportedFunctionSymbol, sym->GetShortName(), sym->GetFullName(), sym->GetRawName(), - entry.value, NoBinding, sym->GetNameSpace(), sym->GetOrdinal()); + adjustedAddress, NoBinding, sym->GetNameSpace(), sym->GetOrdinal()); DefineAutoSymbol(funcSym); func->ApplyImportedTypes(funcSym); } -- cgit v1.3.1