[llvm] r217605 - [MCJIT] Take the relocation addend into account when applying ARM MachO VANILLA

Lang Hames lhames at gmail.com
Thu Sep 11 10:27:01 PDT 2014


Author: lhames
Date: Thu Sep 11 12:27:01 2014
New Revision: 217605

URL: http://llvm.org/viewvc/llvm-project?rev=217605&view=rev
Log:
[MCJIT] Take the relocation addend into account when applying ARM MachO VANILLA
and BR24 relocations.

<rdar://problem/18296496>


Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h
    llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h?rev=217605&r1=217604&r2=217605&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h Thu Sep 11 12:27:01 2014
@@ -101,12 +101,13 @@ public:
     default:
       llvm_unreachable("Invalid relocation type!");
     case MachO::ARM_RELOC_VANILLA:
-      writeBytesUnaligned(Value, LocalAddress, 1 << RE.Size);
+      writeBytesUnaligned(Value + RE.Addend, LocalAddress, 1 << RE.Size);
       break;
     case MachO::ARM_RELOC_BR24: {
       // Mask the value into the target address. We know instructions are
       // 32-bit aligned, so we can do it all at once.
       uint32_t *p = (uint32_t *)LocalAddress;
+      Value += RE.Addend;
       // The low two bits of the value are not encoded.
       Value >>= 2;
       // Mask the value to 24 bits.

Modified: llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s?rev=217605&r1=217604&r2=217605&view=diff
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s (original)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s Thu Sep 11 12:27:01 2014
@@ -34,6 +34,9 @@ insn3:
 foo:
 	bx	lr
 
+# Add 'aaa' to the common symbols to make sure 'baz' isn't at the start of the
+# section. This ensures that we test VANILLA relocation addends correctly.
+        .comm   aaa, 4, 2
         .comm   baz, 4, 2
 
 .subsections_via_symbols





More information about the llvm-commits mailing list