diff options
Diffstat (limited to 'view')
| -rw-r--r-- | view/elf/elfview.cpp | 15 | ||||
| -rw-r--r-- | view/elf/elfview.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp index 3a4b37fe..46039e80 100644 --- a/view/elf/elfview.cpp +++ b/view/elf/elfview.cpp @@ -3,6 +3,7 @@ #include <cxxabi.h> #endif #include <inttypes.h> +#include <cstring> #include "elfview.h" #define STRING_READ_CHUNK_SIZE 32 @@ -1471,6 +1472,20 @@ bool ElfView::Init() if (relocInfo.type == IgnoredRelocation) continue; + if ((relocInfo.symbolIndex == 0) && (m_arch && (m_arch->GetName() == "x86")) + && (relocInfo.nativeType == R_386_IRELATIVE)) + { + uint64_t addend = relocInfo.addend; + if (relocInfo.implicitAddend && (relocInfo.size > 0) && (relocInfo.size <= sizeof(addend))) + memcpy(&addend, relocInfo.relocationDataCache, relocInfo.size); + uint64_t target = addend; + if (imageBaseAdjustment != 0) + target += imageBaseAdjustment; + if (auto targetSymbol = GetSymbolByAddress(target); targetSymbol && !GetSymbolByAddress(relocInfo.address)) + DefineElfSymbol(ImportAddressSymbol, targetSymbol->GetRawName(), relocInfo.address, true, + targetSymbol->GetBinding()); + } + // Define absolute relocations with no symbol specified such as R_PPC_RELATIVE and R_ARM_IRELATIVE // Define unhandled relocations in order to detect them and avoid creating functions at invalid target addresses if ((relocInfo.symbolIndex == 0) || (relocInfo.type == UnhandledRelocation)) diff --git a/view/elf/elfview.h b/view/elf/elfview.h index b9690bef..0e8679b3 100644 --- a/view/elf/elfview.h +++ b/view/elf/elfview.h @@ -340,6 +340,9 @@ // #define ELF_SHN_MIPS_SCOMMON 0xff03 // #define ELF_SHN_MIPS_SUNDEFINED 0xff04 +// x86 ONLY +#define R_386_IRELATIVE 0x2a + // ARM ONLY #define R_ARM_TLS_DTPMOD32 0x11 #define R_ARM_TLS_DTPOFF32 0x12 |
