[llvm] r247336 - [RuntimeDyld] Support non-zero addends for the MachO X86_64 SUBTRACTOR reloc.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 10 14:05:59 PDT 2015
Author: lhames
Date: Thu Sep 10 16:05:58 2015
New Revision: 247336
URL: http://llvm.org/viewvc/llvm-project?rev=247336&view=rev
Log:
[RuntimeDyld] Support non-zero addends for the MachO X86_64 SUBTRACTOR reloc.
This functionality was accidentally left out of r247119.
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h
llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h?rev=247336&r1=247335&r2=247336&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOX86_64.h Thu Sep 10 16:05:58 2015
@@ -154,12 +154,17 @@ private:
unsigned Size = Obj.getAnyRelocationLength(RE);
uint64_t Offset = RelI->getOffset();
+ uint8_t *LocalAddress = Sections[SectionID].Address + Offset;
+ unsigned NumBytes = 1 << Size;
+
ErrorOr<StringRef> SubtrahendNameOrErr = RelI->getSymbol()->getName();
if (auto EC = SubtrahendNameOrErr.getError())
report_fatal_error(EC.message());
auto SubtrahendI = GlobalSymbolTable.find(*SubtrahendNameOrErr);
unsigned SectionBID = SubtrahendI->second.getSectionID();
uint64_t SectionBOffset = SubtrahendI->second.getOffset();
+ int64_t Addend =
+ SignExtend64(readBytesUnaligned(LocalAddress, NumBytes), NumBytes * 8);
++RelI;
ErrorOr<StringRef> MinuendNameOrErr = RelI->getSymbol()->getName();
@@ -169,8 +174,7 @@ private:
unsigned SectionAID = MinuendI->second.getSectionID();
uint64_t SectionAOffset = MinuendI->second.getOffset();
- uint64_t Addend = SectionAOffset - SectionBOffset;
- RelocationEntry R(SectionID, Offset, MachO::X86_64_RELOC_SUBTRACTOR, Addend,
+ RelocationEntry R(SectionID, Offset, MachO::X86_64_RELOC_SUBTRACTOR, (uint64_t)Addend,
SectionAID, SectionAOffset, SectionBID, SectionBOffset,
false, Size);
Modified: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s?rev=247336&r1=247335&r2=247336&view=diff
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s (original)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s Thu Sep 10 16:05:58 2015
@@ -58,9 +58,9 @@ z2:
.quad ds2
# Test subtractor relocations.
-# rtdyld-check: *{8}z3 = z4 - z5
+# rtdyld-check: *{8}z3 = z4 - z5 + 4
z3:
- .quad z4 - z5
+ .quad z4 - z5 + 4
.section __DATA,_tmp1
z4:
More information about the llvm-commits
mailing list