diff options
| author | Alexander Taylor <alex@vector35.com> | 2026-01-24 01:24:25 -0500 |
|---|---|---|
| committer | Alexander Taylor <alex@vector35.com> | 2026-03-06 12:06:14 -0500 |
| commit | 770e9c0c75a943cd4d47ba3cb3be936d09a6c86f (patch) | |
| tree | e76573c8e0b27ddf7c172c1606f1e27319b271e4 | |
| parent | 0f3abc6256f004dfb2010083a9e52600053e7523 (diff) | |
Implement DTPOFF64 and DTPMOD64 relocations.
Finally closes #5463.
| -rw-r--r-- | arch/x86/arch_x86.cpp | 25 | ||||
| -rw-r--r-- | view/elf/elfview.cpp | 12 | ||||
| -rw-r--r-- | view/elf/elfview.h | 4 |
3 files changed, 40 insertions, 1 deletions
diff --git a/arch/x86/arch_x86.cpp b/arch/x86/arch_x86.cpp index f639040e..af3f4901 100644 --- a/arch/x86/arch_x86.cpp +++ b/arch/x86/arch_x86.cpp @@ -4416,6 +4416,16 @@ public: memcpy(dest, (uint8_t*)&write, sizeof(uint64_t)); return true; } + case R_X86_64_DTPMOD64: { + uint64_t write = 0; + memcpy(dest, (uint8_t*)&write, sizeof(uint64_t)); + return true; + } + case R_X86_64_DTPOFF64: { + uint64_t write = reloc->GetTarget() + info.addend; + memcpy(dest, (uint8_t*)&write, sizeof(uint64_t)); + return true; + } default: return RelocationHandler::ApplyRelocation(view, arch, reloc, dest, len); } @@ -4509,6 +4519,21 @@ public: reloc.size = 8; reloc.truncateSize = 8; break; + case R_X86_64_DTPMOD64: + reloc.pcRelative = false; + reloc.baseRelative = false; + reloc.hasSign = false; + reloc.size = 8; + reloc.truncateSize = 8; + reloc.symbolIndex = 0; + break; + case R_X86_64_DTPOFF64: + reloc.pcRelative = false; + reloc.baseRelative = false; + reloc.hasSign = false; + reloc.size = 8; + reloc.truncateSize = 8; + break; case R_X86_64_GOTOFF64: case R_X86_64_GOT64: case R_X86_64_GOTPLT64: diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp index 2df24a5a..58e82efc 100644 --- a/view/elf/elfview.cpp +++ b/view/elf/elfview.cpp @@ -1480,6 +1480,13 @@ bool ElfView::Init() else if(reloc.relocType == R_ARM_TLS_DTPMOD32) tlsModuleStarts.push_back(reloc.offset); } + else if (m_arch && (m_arch->GetName() == "x86_64")) + { + if (reloc.relocType == R_X86_64_DTPOFF64) + tlsOffsets.push_back(reloc.offset); + else if (reloc.relocType == R_X86_64_DTPMOD64) + tlsModuleStarts.push_back(reloc.offset); + } } if (relocHandler->GetRelocationInfo(this, m_arch, m_relocationInfo)) @@ -2496,10 +2503,13 @@ bool ElfView::Init() } // Add type, data variables for TLS entries + size_t tlsModuleEntrySize = 4; + if (m_arch && (m_arch->GetAddressSize() == 8)) + tlsModuleEntrySize = 8; for (auto offset : tlsModuleStarts) { /* All module ID's are set to 0. */ - DefineDataVariable(offset, Type::IntegerType(4, false)->WithConfidence(BN_FULL_CONFIDENCE)); + DefineDataVariable(offset, Type::IntegerType(tlsModuleEntrySize, false)->WithConfidence(BN_FULL_CONFIDENCE)); } for (auto offset : tlsOffsets) { diff --git a/view/elf/elfview.h b/view/elf/elfview.h index 0e8679b3..f81fa832 100644 --- a/view/elf/elfview.h +++ b/view/elf/elfview.h @@ -343,6 +343,10 @@ // x86 ONLY #define R_386_IRELATIVE 0x2a +// x86-64 ONLY +#define R_X86_64_DTPMOD64 0x10 +#define R_X86_64_DTPOFF64 0x11 + // ARM ONLY #define R_ARM_TLS_DTPMOD32 0x11 #define R_ARM_TLS_DTPOFF32 0x12 |
