[PATCH] [PATCH 11/13] ELF/AARCH64: Add overflow check for R_AARCH64_CONDBR19
Adhemerval Zanella
adhemerval.zanella at linaro.org
Tue Mar 31 10:57:44 PDT 2015
http://reviews.llvm.org/D8737
Files:
lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp
Index: lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp
===================================================================
--- lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp
+++ lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp
@@ -173,17 +173,20 @@
}
/// \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 << " -";
llvm::dbgs() << " S: " << Twine::utohexstr(S);
llvm::dbgs() << " A: " << Twine::utohexstr(A);
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());
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D8737.22983.patch
Type: text/x-patch
Size: 1778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150331/7717fb9f/attachment.bin>
More information about the llvm-commits
mailing list