[compiler-rt] r275489 - [compiler-rt] Add more assembly patterns for interception

Etienne Bergeron via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 14 15:14:34 PDT 2016


Author: etienneb
Date: Thu Jul 14 17:14:33 2016
New Revision: 275489

URL: http://llvm.org/viewvc/llvm-project?rev=275489&view=rev
Log:
[compiler-rt] Add more assembly patterns for interception

Summary:
These patterns are encounter when using instrumented DLL.

Without this patch, asan lit test are crashing when trying to hook
on RaiseException function.

Reviewers: rnk

Subscribers: llvm-commits, wang0109, chrisha

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

Modified:
    compiler-rt/trunk/lib/interception/interception_win.cc

Modified: compiler-rt/trunk/lib/interception/interception_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/interception/interception_win.cc?rev=275489&r1=275488&r2=275489&view=diff
==============================================================================
--- compiler-rt/trunk/lib/interception/interception_win.cc (original)
+++ compiler-rt/trunk/lib/interception/interception_win.cc Thu Jul 14 17:14:33 2016
@@ -385,6 +385,11 @@ static uptr AllocateMemoryForTrampoline(
 
 // Returns 0 on error.
 static size_t GetInstructionSize(uptr address) {
+  switch (*(u64*)address) {
+    case 0x90909090909006EB:  // stub: jmp over 6 x nop.
+      return 8;
+  }
+
   switch (*(u8*)address) {
     case 0x90:  // 90 : nop
       return 1;
@@ -499,7 +504,8 @@ static size_t GetInstructionSize(uptr ad
   }
 
   switch (*(u32*)(address)) {
-    case 0x24448b48:  // 48 8b 44 24 XX : mov rax, qword ptr [rsp + XX]
+    case 0x24448b48:  // 48 8b 44 24 XX : mov rax, QWORD ptr [rsp + XX]
+    case 0x246c8948:  // 48 89 6C 24 XX : mov QWORD ptr [rsp + XX], rbp
     case 0x245c8948:  // 48 89 5c 24 XX : mov QWORD PTR [rsp + XX], rbx
     case 0x24748948:  // 48 89 74 24 XX : mov QWORD PTR [rsp + XX], rsi
       return 5;




More information about the llvm-commits mailing list