diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -479,7 +479,8 @@ *TargetPtr &= 0xfff8001fU; // Immediate:15:2 goes in bits 18:5 of TBZ, TBNZ - or32le(TargetPtr, (BranchImm & 0x0FFFFFFC) << 3); + or32le(TargetPtr, (BranchImm & 0x0000FFFC) << 3); + break; } case ELF::R_AARCH64_CALL26: // fallthrough diff --git a/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/ELF_ARM64_TSTBR14.s b/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/ELF_ARM64_TSTBR14.s new file mode 100644 --- /dev/null +++ b/llvm/test/ExecutionEngine/RuntimeDyld/AArch64/ELF_ARM64_TSTBR14.s @@ -0,0 +1,14 @@ +# RUN: llvm-mc -triple=arm64-none-linux-gnu -filetype=obj -o %t %s +# RUN: llvm-rtdyld -triple=aarch64_be-none-linux-gnu -verify -check=%s %t + +.section .text.1,"ax" +.globl foo +foo: + ret + +.globl _main +_main: + tbnz x0, #1, foo + +## Branch 1 instruction back from _main +# rtdyld-check: *{4}(_main) = 0x370FFFE0