diff options
author | Denis Protivensky <dprotivensky@accesssoftek.com> | 2015-05-08 12:34:43 +0000 |
---|---|---|
committer | Denis Protivensky <dprotivensky@accesssoftek.com> | 2015-05-08 12:34:43 +0000 |
commit | a0cffffcfab362d9a3c192b8b73ae3da098e8ac5 (patch) | |
tree | 47bd6fa154831819f2d67b95044aa322b35c0490 /lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp | |
parent | 159a49e5d6bd0f7a53732ee511830835f65fdae9 (diff) | |
download | bcm5719-llvm-a0cffffcfab362d9a3c192b8b73ae3da098e8ac5.tar.gz bcm5719-llvm-a0cffffcfab362d9a3c192b8b73ae3da098e8ac5.zip |
[ARM] Check overflow of R_ARM_THM_CALL/JUMP24
llvm-svn: 236839
Diffstat (limited to 'lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp')
-rw-r--r-- | lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp b/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp index 0c8d3591d3c..665fcdd7213 100644 --- a/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp +++ b/lld/lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp @@ -200,6 +200,10 @@ static std::error_code relocR_ARM_PREL31(uint8_t *location, uint64_t P, /// \brief Relocate B/BL instructions. useJs defines whether J1 & J2 are used static std::error_code relocR_ARM_THM_B_L(uint8_t *location, uint32_t result, bool useJs) { + if ((useJs && !llvm::isInt<25>((int32_t)result)) || + (!useJs && !llvm::isInt<23>((int32_t)result))) + return make_out_of_range_reloc_error(); + result = (result & 0x01FFFFFE) >> 1; const uint16_t imm10 = (result >> 11) & 0x3FF; |