From 761ca139910edabca9320120b1df841001dcd504 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Thu, 11 Sep 2014 17:27:01 +0000 Subject: [PATCH] [MCJIT] Take the relocation addend into account when applying ARM MachO VANILLA and BR24 relocations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217605 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h | 3 ++- .../RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h index e29b8dc5091..dc8acfef5b7 100644 --- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h +++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h @@ -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. diff --git a/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s b/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s index d0d30271f0d..2dc776cd447 100644 --- a/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s +++ b/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s @@ -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 -- 2.34.1