Index: ELF/Arch/AArch64.cpp =================================================================== --- ELF/Arch/AArch64.cpp +++ ELF/Arch/AArch64.cpp @@ -232,8 +232,13 @@ checkInt<21>(Loc, Val, Type); write32AArch64Addr(Loc, Val); break; - case R_AARCH64_CALL26: case R_AARCH64_JUMP26: + // When patching instructions we may use a branch immediate to overwrite a + // potentially non-branch instruction so write the full branch instruction + // opcode (0 001 | 01 imm26). + write32le(Loc, 0x14000000); + // Fallthrough + case R_AARCH64_CALL26: checkInt<28>(Loc, Val, Type); or32le(Loc, (Val & 0x0FFFFFFC) >> 2); break;