From cb7b6e9d9f5cd9438f5d24fc9c0dd0d5fcac6e3f Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Thu, 1 Mar 2018 01:44:33 +0000 Subject: [PATCH] [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. llvm-svn: 326406 --- .../RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h | 8 +++++--- .../RuntimeDyld/AArch64/MachO_ARM64_relocations.s | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h index 86acf513de3..31cedffa15b 100644 --- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h +++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOAArch64.h @@ -69,8 +69,8 @@ public: // Verify that the relocation points to a B/BL instruction. auto *p = reinterpret_cast(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(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"); diff --git a/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s b/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s index 49928dd9d8e..64c4a6dce88 100644 --- a/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s +++ b/test/ExecutionEngine/RuntimeDyld/AArch64/MachO_ARM64_relocations.s @@ -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