summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-05-15 20:32:25 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-05-15 20:32:25 +0000
commitdd9eafb6dbbf423b347a1cce121ae7181ea34619 (patch)
tree55722713ef9ea9575656d7cbd38c80bc0df838ea /llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
parent9441094249645a0c0bca1db670d0b3d38aaa48db (diff)
downloadbcm5719-llvm-dd9eafb6dbbf423b347a1cce121ae7181ea34619.tar.gz
bcm5719-llvm-dd9eafb6dbbf423b347a1cce121ae7181ea34619.zip
[RuntimeDyld] Use isInt to assert that a relocation didn't overflow
isInt is a little easier to read, let's use that more consistently. Incidentally, this also silences a warning for shifting a negative number. This fixes PR23532. llvm-svn: 237476
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
index 52db2c0f62a..04b5e4fde18 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
@@ -249,7 +249,7 @@ void RuntimeDyldELF::resolveX86_64Relocation(const SectionEntry &Section,
case ELF::R_X86_64_PC32: {
uint64_t FinalAddress = Section.LoadAddress + Offset;
int64_t RealOffset = Value + Addend - FinalAddress;
- assert(RealOffset <= INT32_MAX && RealOffset >= INT32_MIN);
+ assert(isInt<32>(RealOffset));
int32_t TruncOffset = (RealOffset & 0xFFFFFFFF);
support::ulittle32_t::ref(Section.Address + Offset) = TruncOffset;
break;
@@ -322,8 +322,7 @@ void RuntimeDyldELF::resolveAArch64Relocation(const SectionEntry &Section,
uint64_t BranchImm = Value + Addend - FinalAddress;
// "Check that -2^27 <= result < 2^27".
- assert(-(1LL << 27) <= static_cast<int64_t>(BranchImm) &&
- static_cast<int64_t>(BranchImm) < (1LL << 27));
+ assert(isInt<28>(BranchImm));
// AArch64 code is emitted with .rela relocations. The data already in any
// bits affected by the relocation on entry is garbage.
@@ -386,9 +385,7 @@ void RuntimeDyldELF::resolveAArch64Relocation(const SectionEntry &Section,
((Value + Addend) & ~0xfffULL) - (FinalAddress & ~0xfffULL);
// Check that -2^32 <= X < 2^32
- assert(static_cast<int64_t>(Result) >= (-1LL << 32) &&
- static_cast<int64_t>(Result) < (1LL << 32) &&
- "overflow check failed for relocation");
+ assert(isInt<33>(Result) && "overflow check failed for relocation");
// AArch64 code is emitted with .rela relocations. The data already in any
// bits affected by the relocation on entry is garbage.
OpenPOWER on IntegriCloud