llvm.org GIT mirror llvm / 2ac0f38
ExecutionEngine: adjust COFF i386 tautological asserts Modify static_casts to not be tautological in some COFF i386 relocations. Patch by Alex Langford! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316169 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 3 years ago
2 changed file(s) with 9 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
143143 ? Value
144144 : Sections[RE.Sections.SectionA].getLoadAddressWithOffset(
145145 RE.Addend);
146 assert(static_cast(Result) <= INT32_MAX &&
147 "relocation overflow");
148 assert(static_cast(Result) >= INT32_MIN &&
149 "relocation underflow");
146 assert(Result <= UINT32_MAX && "relocation overflow");
150147 DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
151148 << " RelType: IMAGE_REL_I386_DIR32"
152149 << " TargetSection: " << RE.Sections.SectionA
160157 uint64_t Result =
161158 Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend) -
162159 Sections[0].getLoadAddress();
163 assert(static_cast(Result) <= INT32_MAX &&
164 "relocation overflow");
165 assert(static_cast(Result) >= INT32_MIN &&
166 "relocation underflow");
160 assert(Result <= UINT32_MAX && "relocation overflow");
167161 DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
168162 << " RelType: IMAGE_REL_I386_DIR32NB"
169163 << " TargetSection: " << RE.Sections.SectionA
177171 ? Value
178172 : Sections[RE.Sections.SectionA].getLoadAddress();
179173 Result = Result - Section.getLoadAddress() + RE.Addend - 4 - RE.Offset;
180 assert(static_cast32_t>(Result) <= INT32_MAX &&
174 assert(static_cast64_t>(Result) <= INT32_MAX &&
181175 "relocation overflow");
182 assert(static_cast32_t>(Result) >= INT32_MIN &&
176 assert(static_cast64_t>(Result) >= INT32_MIN &&
183177 "relocation underflow");
184178 DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
185179 << " RelType: IMAGE_REL_I386_REL32"
190184 }
191185 case COFF::IMAGE_REL_I386_SECTION:
192186 // 16-bit section index of the section that contains the target.
193 assert(static_cast<int32_t>(RE.SectionID) <= INT16_MAX &&
187 assert(static_cast<uint32_t>(RE.SectionID) <= UINT16_MAX &&
194188 "relocation overflow");
195 assert(static_cast(RE.SectionID) >= INT16_MIN &&
196 "relocation underflow");
197189 DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
198190 << " RelType: IMAGE_REL_I386_SECTION Value: " << RE.SectionID
199191 << '\n');
201193 break;
202194 case COFF::IMAGE_REL_I386_SECREL:
203195 // 32-bit offset of the target from the beginning of its section.
204 assert(static_cast<int32_t>(RE.Addend) <= INT32_MAX &&
196 assert(static_cast<uint64_t>(RE.Addend) <= UINT32_MAX &&
205197 "relocation overflow");
206 assert(static_cast(RE.Addend) >= INT32_MIN &&
207 "relocation underflow");
208198 DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
209199 << " RelType: IMAGE_REL_I386_SECREL Value: " << RE.Addend
210200 << '\n');
0 // RUN: llvm-mc -triple i686-windows -filetype obj -o %t.obj %s
1 // 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
1 // 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
22
33 .text
44
4040 .align 4
4141 __imp__OutputDebugStringA:
4242 .long "_OutputDebugStringA@4" // IMAGE_REL_I386_DIR32
43 # rtdyld-check: *{4}__imp__OutputDebugStringA = 0xfffffffe
43 # rtdyld-check: *{4}__imp__OutputDebugStringA = 0x7ffffffe
4444
4545 .global __imp__ExitProcess
4646 .align 4
4747 __imp__ExitProcess:
4848 .long "_ExitProcess@4" // IMAGE_REL_I386_DIR32
49 # rtdyld-check: *{4}__imp__ExitProcess = 0xffffffff
49 # rtdyld-check: *{4}__imp__ExitProcess = 0x7fffffff
5050
5151 .global relocations
5252 relocations: