[llvm] r326406 - [RuntimeDyld][MachO] Fix assertion in encodeAddend, add missing directive to

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 17:44:34 PST 2018


Author: lhames
Date: Wed Feb 28 17:44:33 2018
New Revision: 326406

URL: http://llvm.org/viewvc/llvm-project?rev=326406&view=rev
Log:
[RuntimeDyld][MachO] Fix assertion in encodeAddend, add missing directive to
test case.

r326290 fixed the assertion for decodeAddend, but not encodeAddend. The
regression test failed to catch this because it was missing the
subsections_via_symbols flag, so the desired relocation was not applied.

This patch also fixes the formatting of the assertion from r326290.


Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
    llvm/trunk/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h?rev=326406&r1=326405&r2=326406&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h Wed Feb 28 17:44:33 2018
@@ -69,8 +69,8 @@ public:
       // Verify that the relocation points to a B/BL instruction.
       auto *p = reinterpret_cast<support::aligned_ulittle32_t *>(LocalAddress);
       assert(((*p & 0xFC000000) == 0x14000000 ||
-	      (*p & 0xFC000000) == 0x94000000)
-	     && "Expected branch instruction.");
+              (*p & 0xFC000000) == 0x94000000) &&
+             "Expected branch instruction.");
 
       // Get the 26 bit addend encoded in the branch instruction and sign-extend
       // to 64 bit. The lower 2 bits are always zeros and are therefore implicit
@@ -166,7 +166,9 @@ public:
     case MachO::ARM64_RELOC_BRANCH26: {
       auto *p = reinterpret_cast<support::aligned_ulittle32_t *>(LocalAddress);
       // Verify that the relocation points to the expected branch instruction.
-      assert((*p & 0xFC000000) == 0x14000000 && "Expected branch instruction.");
+      assert(((*p & 0xFC000000) == 0x14000000 ||
+              (*p & 0xFC000000) == 0x94000000) &&
+             "Expected branch instruction.");
 
       // Verify addend value.
       assert((Addend & 0x3) == 0 && "Branch target is not aligned");

Modified: llvm/trunk/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s?rev=326406&r1=326405&r2=326406&view=diff
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s (original)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s Wed Feb 28 17:44:33 2018
@@ -90,3 +90,5 @@ _ptr:
 # rtdyld-check: *{8}_subtractor_result = _test_branch_reloc - _foo
 _subtractor_result:
     .quad _test_branch_reloc - _foo
+
+.subsections_via_symbols
\ No newline at end of file




More information about the llvm-commits mailing list