[compiler-rt] 1a7a00b - [compiler-rt][interception][win] Add error messages for some errors

Alvin Wong via llvm-commits llvm-commits at lists.llvm.org
Thu May 4 07:41:46 PDT 2023


Author: Alvin Wong
Date: 2023-05-04T22:41:27+08:00
New Revision: 1a7a00bdc99fa2b2ca19ecd2d1069991b3c1006b

URL: https://github.com/llvm/llvm-project/commit/1a7a00bdc99fa2b2ca19ecd2d1069991b3c1006b
DIFF: https://github.com/llvm/llvm-project/commit/1a7a00bdc99fa2b2ca19ecd2d1069991b3c1006b.diff

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

Depends on D149002

Differential Revision: https://reviews.llvm.org/D149346

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index 7485cd463564..00c317510e42 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -270,8 +270,13 @@ static void WritePadding(uptr from, uptr size) {
 }
 
 static void WriteJumpInstruction(uptr from, uptr target) {
-  if (!DistanceIsWithin2Gig(from + kJumpInstructionLength, target))
+  if (!DistanceIsWithin2Gig(from + kJumpInstructionLength, target)) {
+    ReportError(
+        "interception_win: cannot write jmp further than 2GB away, from %p to "
+        "%p.\n",
+        (void *)from, (void *)target);
     InterceptionFailed();
+  }
   ptr
diff _t offset = target - from - kJumpInstructionLength;
   *(u8*)from = 0xE9;
   *(u32*)(from + 1) = offset;
@@ -295,6 +300,10 @@ static void WriteIndirectJumpInstruction(uptr from, uptr indirect_target) {
   int offset = indirect_target - from - kIndirectJumpInstructionLength;
   if (!DistanceIsWithin2Gig(from + kIndirectJumpInstructionLength,
                             indirect_target)) {
+    ReportError(
+        "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;


        


More information about the llvm-commits mailing list