1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

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
This commit is contained in:
Saleem Abdulrasool 2017-10-19 16:57:40 +00:00
parent d6a686e827
commit 87d4446c55
2 changed files with 9 additions and 19 deletions

View File

@ -144,10 +144,7 @@ public:
? Value ? Value
: Sections[RE.Sections.SectionA].getLoadAddressWithOffset( : Sections[RE.Sections.SectionA].getLoadAddressWithOffset(
RE.Addend); RE.Addend);
assert(static_cast<int32_t>(Result) <= INT32_MAX && assert(Result <= UINT32_MAX && "relocation overflow");
"relocation overflow");
assert(static_cast<int32_t>(Result) >= INT32_MIN &&
"relocation underflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_DIR32" << " RelType: IMAGE_REL_I386_DIR32"
<< " TargetSection: " << RE.Sections.SectionA << " TargetSection: " << RE.Sections.SectionA
@ -161,10 +158,7 @@ public:
uint64_t Result = uint64_t Result =
Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend) - Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend) -
Sections[0].getLoadAddress(); Sections[0].getLoadAddress();
assert(static_cast<int32_t>(Result) <= INT32_MAX && assert(Result <= UINT32_MAX && "relocation overflow");
"relocation overflow");
assert(static_cast<int32_t>(Result) >= INT32_MIN &&
"relocation underflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_DIR32NB" << " RelType: IMAGE_REL_I386_DIR32NB"
<< " TargetSection: " << RE.Sections.SectionA << " TargetSection: " << RE.Sections.SectionA
@ -178,9 +172,9 @@ public:
? Value ? Value
: Sections[RE.Sections.SectionA].getLoadAddress(); : Sections[RE.Sections.SectionA].getLoadAddress();
Result = Result - Section.getLoadAddress() + RE.Addend - 4 - RE.Offset; 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"); "relocation overflow");
assert(static_cast<int32_t>(Result) >= INT32_MIN && assert(static_cast<int64_t>(Result) >= INT32_MIN &&
"relocation underflow"); "relocation underflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_REL32" << " RelType: IMAGE_REL_I386_REL32"
@ -191,10 +185,8 @@ public:
} }
case COFF::IMAGE_REL_I386_SECTION: case COFF::IMAGE_REL_I386_SECTION:
// 16-bit section index of the section that contains the target. // 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"); "relocation overflow");
assert(static_cast<int32_t>(RE.SectionID) >= INT16_MIN &&
"relocation underflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_SECTION Value: " << RE.SectionID << " RelType: IMAGE_REL_I386_SECTION Value: " << RE.SectionID
<< '\n'); << '\n');
@ -202,10 +194,8 @@ public:
break; break;
case COFF::IMAGE_REL_I386_SECREL: case COFF::IMAGE_REL_I386_SECREL:
// 32-bit offset of the target from the beginning of its section. // 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"); "relocation overflow");
assert(static_cast<int32_t>(RE.Addend) >= INT32_MIN &&
"relocation underflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_SECREL Value: " << RE.Addend << " RelType: IMAGE_REL_I386_SECREL Value: " << RE.Addend
<< '\n'); << '\n');

View File

@ -1,5 +1,5 @@
// RUN: llvm-mc -triple i686-windows -filetype obj -o %t.obj %s // RUN: llvm-mc -triple i686-windows -filetype obj -o %t.obj %s
// RUN: llvm-rtdyld -triple i686-windows -dummy-extern _printf=0xfffffffd -dummy-extern _OutputDebugStringA@4=0xfffffffe -dummy-extern _ExitProcess@4=0xffffffff -verify -check=%s %t.obj // RUN: llvm-rtdyld -triple i686-windows -dummy-extern _printf=0x7ffffffd -dummy-extern _OutputDebugStringA@4=0x7ffffffe -dummy-extern _ExitProcess@4=0x7fffffff -verify -check=%s %t.obj
.text .text
@ -41,13 +41,13 @@ rel4:
.align 4 .align 4
__imp__OutputDebugStringA: __imp__OutputDebugStringA:
.long "_OutputDebugStringA@4" // IMAGE_REL_I386_DIR32 .long "_OutputDebugStringA@4" // IMAGE_REL_I386_DIR32
# rtdyld-check: *{4}__imp__OutputDebugStringA = 0xfffffffe # rtdyld-check: *{4}__imp__OutputDebugStringA = 0x7ffffffe
.global __imp__ExitProcess .global __imp__ExitProcess
.align 4 .align 4
__imp__ExitProcess: __imp__ExitProcess:
.long "_ExitProcess@4" // IMAGE_REL_I386_DIR32 .long "_ExitProcess@4" // IMAGE_REL_I386_DIR32
# rtdyld-check: *{4}__imp__ExitProcess = 0xffffffff # rtdyld-check: *{4}__imp__ExitProcess = 0x7fffffff
.global relocations .global relocations
relocations: relocations: