[PATCH] D149346: [compiler-rt][interception][win] Add error messages for some errors

Alvin Wong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 27 07:13:14 PDT 2023


alvinhochun created this revision.
alvinhochun added a reviewer: vitalybuka.
Herald added subscribers: Enna1, dberris.
Herald added a project: All.
alvinhochun requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Depends on D149002 <https://reviews.llvm.org/D149002>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149346

Files:
  compiler-rt/lib/interception/interception_win.cpp


Index: compiler-rt/lib/interception/interception_win.cpp
===================================================================
--- compiler-rt/lib/interception/interception_win.cpp
+++ compiler-rt/lib/interception/interception_win.cpp
@@ -253,8 +253,11 @@
 }
 
 static void WriteJumpInstruction(uptr from, uptr target) {
-  if (!DistanceIsWithin2Gig(from + kJumpInstructionLength, target))
+  if (!DistanceIsWithin2Gig(from + kJumpInstructionLength, target)) {
+    Report("interception_win: cannot write jmp further than 2GB away, from %p "
+           "to %p.\n", (void*)from, (void*)target);
     InterceptionFailed();
+  }
   ptrdiff_t offset = target - from - kJumpInstructionLength;
   *(u8*)from = 0xE9;
   *(u32*)(from + 1) = offset;
@@ -278,6 +281,9 @@
   int offset = indirect_target - from - kIndirectJumpInstructionLength;
   if (!DistanceIsWithin2Gig(from + kIndirectJumpInstructionLength,
                             indirect_target)) {
+    Report("interception_win: cannot write indirect jmp with target further "
+           "than 2GB away, from %p to %p.\n", (void*)from,
+           (void*)indirect_target);
     InterceptionFailed();
   }
   *(u16*)from = 0x25FF;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149346.517549.patch
Type: text/x-patch
Size: 1183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230427/4529a6d4/attachment.bin>


More information about the llvm-commits mailing list