summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/RuntimeDyld/Targets
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-10-19 16:57:40 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-10-19 16:57:40 +0000
commit126115191271b732bdc01306e9ced72ff71d99bb (patch)
treeeb6ada336be96209f61af82141bd75c0bb346ff0 /llvm/lib/ExecutionEngine/RuntimeDyld/Targets
parent3c941e7ed92a5043d6e09b9885a0c66b52f7882e (diff)
downloadbcm5719-llvm-126115191271b732bdc01306e9ced72ff71d99bb.tar.gz
bcm5719-llvm-126115191271b732bdc01306e9ced72ff71d99bb.zip
ExecutionEngine: adjust COFF i386 tautological asserts
Modify static_casts to not be tautological in some COFF i386 relocations. Patch by Alex Langford! llvm-svn: 316169
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/Targets')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h22
1 files changed, 6 insertions, 16 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
index 76c8f956300..04678f22446 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
@@ -144,10 +144,7 @@ public:
? Value
: Sections[RE.Sections.SectionA].getLoadAddressWithOffset(
RE.Addend);
- assert(static_cast<int32_t>(Result) <= INT32_MAX &&
- "relocation overflow");
- assert(static_cast<int32_t>(Result) >= INT32_MIN &&
- "relocation underflow");
+ assert(Result <= UINT32_MAX && "relocation overflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_DIR32"
<< " TargetSection: " << RE.Sections.SectionA
@@ -161,10 +158,7 @@ public:
uint64_t Result =
Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend) -
Sections[0].getLoadAddress();
- assert(static_cast<int32_t>(Result) <= INT32_MAX &&
- "relocation overflow");
- assert(static_cast<int32_t>(Result) >= INT32_MIN &&
- "relocation underflow");
+ assert(Result <= UINT32_MAX && "relocation overflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_DIR32NB"
<< " TargetSection: " << RE.Sections.SectionA
@@ -178,9 +172,9 @@ public:
? Value
: Sections[RE.Sections.SectionA].getLoadAddress();
Result = Result - Section.getLoadAddress() + RE.Addend - 4 - RE.Offset;
- assert(static_cast<int32_t>(Result) <= INT32_MAX &&
+ assert(static_cast<int64_t>(Result) <= INT32_MAX &&
"relocation overflow");
- assert(static_cast<int32_t>(Result) >= INT32_MIN &&
+ assert(static_cast<int64_t>(Result) >= INT32_MIN &&
"relocation underflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_REL32"
@@ -191,10 +185,8 @@ public:
}
case COFF::IMAGE_REL_I386_SECTION:
// 16-bit section index of the section that contains the target.
- assert(static_cast<int32_t>(RE.SectionID) <= INT16_MAX &&
+ assert(static_cast<uint32_t>(RE.SectionID) <= UINT16_MAX &&
"relocation overflow");
- assert(static_cast<int32_t>(RE.SectionID) >= INT16_MIN &&
- "relocation underflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_SECTION Value: " << RE.SectionID
<< '\n');
@@ -202,10 +194,8 @@ public:
break;
case COFF::IMAGE_REL_I386_SECREL:
// 32-bit offset of the target from the beginning of its section.
- assert(static_cast<int32_t>(RE.Addend) <= INT32_MAX &&
+ assert(static_cast<uint64_t>(RE.Addend) <= UINT32_MAX &&
"relocation overflow");
- assert(static_cast<int32_t>(RE.Addend) >= INT32_MIN &&
- "relocation underflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_SECREL Value: " << RE.Addend
<< '\n');
OpenPOWER on IntegriCloud