From 9c290613915b866cda3128f8d400cf0141185159 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Tue, 13 May 2014 22:09:07 +0000 Subject: [RuntimeDyld] Fix handling of i386 PC-rel external relocations. This fixes several more i386 MCJIT regression test failures. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208735 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/ExecutionEngine') diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index df7f04cdf8..66456a990b 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -546,6 +546,17 @@ relocation_iterator RuntimeDyldMachO::processRelocationRef( Value.Addend = Addend; } } + + // Addends for external, PC-rel relocations on i386 point back to the zero + // offset. Calculate the final offset from the relocation target instead. + // This allows us to use the same logic for both external and internal + // relocations in resolveI386RelocationRef. + if (Arch == Triple::x86 && IsPCRel) { + uint64_t RelocAddr = 0; + RelI->getAddress(RelocAddr); + Value.Addend += RelocAddr + 4; + } + } else { SectionRef Sec = MachO->getRelocationSection(RE); bool IsCode = false; -- cgit v1.2.3