Index: lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp +++ lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp @@ -173,9 +173,11 @@ } /// \brief R_AARCH64_CONDBR19 -static void relocR_AARCH64_CONDBR19(uint8_t *location, uint64_t P, uint64_t S, - int64_t A) { +static std::error_code relocR_AARCH64_CONDBR19(uint8_t *location, uint64_t P, + uint64_t S, int64_t A) { int32_t result = (int32_t)((S + A) - P); + if (!isInt<20>(result)) + return make_out_of_range_reloc_error(); result &= 0x01FFFFC; result <<= 3; DEBUG(llvm::dbgs() << "\t\tHandle " << LLVM_FUNCTION_NAME << " -"; @@ -184,6 +186,7 @@ llvm::dbgs() << " P: " << Twine::utohexstr(P); llvm::dbgs() << " result: " << Twine::utohexstr(result) << "\n"); write32le(location, result | read32le(location)); + return std::error_code(); } /// \brief R_AARCH64_LDST8_ABS_LO12_NC - S + A @@ -426,9 +429,8 @@ case R_AARCH64_JUMP26: return relocJump26(location, relocVAddress, targetVAddress, ref.addend()); case R_AARCH64_CONDBR19: - relocR_AARCH64_CONDBR19(location, relocVAddress, targetVAddress, - ref.addend()); - break; + return relocR_AARCH64_CONDBR19(location, relocVAddress, targetVAddress, + ref.addend()); case R_AARCH64_ADR_GOT_PAGE: return relocR_AARCH64_ADR_GOT_PAGE(location, relocVAddress, targetVAddress, ref.addend());