Skip to content

Commit 1a7a00b

Browse files
committed
[compiler-rt][interception][win] Add error messages for some errors
Depends on D149002 Differential Revision: https://reviews.llvm.org/D149346
1 parent 0716888 commit 1a7a00b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

compiler-rt/lib/interception/interception_win.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,13 @@ static void WritePadding(uptr from, uptr size) {
270270
}
271271

272272
static void WriteJumpInstruction(uptr from, uptr target) {
273-
if (!DistanceIsWithin2Gig(from + kJumpInstructionLength, target))
273+
if (!DistanceIsWithin2Gig(from + kJumpInstructionLength, target)) {
274+
ReportError(
275+
"interception_win: cannot write jmp further than 2GB away, from %p to "
276+
"%p.\n",
277+
(void *)from, (void *)target);
274278
InterceptionFailed();
279+
}
275280
ptrdiff_t offset = target - from - kJumpInstructionLength;
276281
*(u8*)from = 0xE9;
277282
*(u32*)(from + 1) = offset;
@@ -295,6 +300,10 @@ static void WriteIndirectJumpInstruction(uptr from, uptr indirect_target) {
295300
int offset = indirect_target - from - kIndirectJumpInstructionLength;
296301
if (!DistanceIsWithin2Gig(from + kIndirectJumpInstructionLength,
297302
indirect_target)) {
303+
ReportError(
304+
"interception_win: cannot write indirect jmp with target further than "
305+
"2GB away, from %p to %p.\n",
306+
(void *)from, (void *)indirect_target);
298307
InterceptionFailed();
299308
}
300309
*(u16*)from = 0x25FF;

0 commit comments

Comments
 (0)