[PATCH] D57339: [compiler rt] Win64 GetInstructionSize additional register MOV + stack alignment AND
Matthew G McGovern via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 7 13:51:25 PST 2019
mcgov updated this revision to Diff 185863.
mcgov added a comment.
Herald added a project: LLVM.
Added tests for interception of new functions (just in case).
Repository:
rCRT Compiler Runtime
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57339/new/
https://reviews.llvm.org/D57339
Files:
lib/interception/interception_win.cc
lib/interception/tests/interception_win_test.cc
Index: lib/interception/tests/interception_win_test.cc
===================================================================
--- lib/interception/tests/interception_win_test.cc
+++ lib/interception/tests/interception_win_test.cc
@@ -208,6 +208,24 @@
0x90, 0x90, 0x90, 0x90,
};
+const u8 kPatchableCode6[] = {
+ 0x48, 0x89, 0x54, 0x24, 0xBB, // mov QWORD PTR [rsp + 0xBB], rdx
+ 0x33, 0xC9, // xor ecx,ecx
+ 0xC3, // ret
+};
+
+const u8 kPatchableCode7[] = {
+ 0x4c, 0x89, 0x4c, 0x24, 0xBB, // mov QWORD PTR [rsp + 0xBB], r9
+ 0x33, 0xC9, // xor ecx,ecx
+ 0xC3, // ret
+};
+
+const u8 kPatchableCode8[] = {
+ 0x4c, 0x89, 0x44, 0x24, 0xBB, // mov QWORD PTR [rsp + 0xBB], r8
+ 0x33, 0xC9, // xor ecx,ecx
+ 0xC3, // ret
+};
+
// A buffer holding the dynamically generated code under test.
u8* ActiveCode;
const size_t ActiveCodeLength = 4096;
@@ -507,7 +525,6 @@
#endif
EXPECT_TRUE(TestFunctionPatching(kPatchableCode4, override));
EXPECT_TRUE(TestFunctionPatching(kPatchableCode5, override));
-
#if SANITIZER_WINDOWS64
EXPECT_TRUE(TestFunctionPatching(kLoadGlobalCode, override));
#endif
@@ -572,7 +589,11 @@
EXPECT_FALSE(TestFunctionPatching(kPatchableCode2, override, prefix));
EXPECT_FALSE(TestFunctionPatching(kPatchableCode3, override, prefix));
EXPECT_FALSE(TestFunctionPatching(kPatchableCode4, override, prefix));
-
+#ifdef _WIN64
+ EXPECT_TRUE(TestFunctionPatching(kPatchableCode6, override, prefix));
+ EXPECT_TRUE(TestFunctionPatching(kPatchableCode7, override, prefix));
+ EXPECT_TRUE(TestFunctionPatching(kPatchableCode8, override, prefix));
+#endif
EXPECT_FALSE(TestFunctionPatching(kUnpatchableCode1, override, prefix));
EXPECT_TRUE(TestFunctionPatching(kUnpatchableCode2, override, prefix));
EXPECT_FALSE(TestFunctionPatching(kUnpatchableCode3, override, prefix));
Index: lib/interception/interception_win.cc
===================================================================
--- lib/interception/interception_win.cc
+++ lib/interception/interception_win.cc
@@ -523,6 +523,7 @@
case 0xd18b48: // 48 8b d1 : mov rdx, rcx
case 0xdc8b4c: // 4c 8b dc : mov r11, rsp
case 0xd18b4c: // 4c 8b d1 : mov r10, rcx
+ case 0xE0E483: // 83 E4 E0 : and esp, 0xFFFFFFE0
return 3;
case 0xec8348: // 48 83 ec XX : sub rsp, XX
@@ -554,7 +555,9 @@
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
case 0x244C8948: // 48 89 4C 24 XX : mov QWORD PTR [rsp + XX], rcx
-
+ case 0x24548948: // 48 89 54 24 XX : mov QWORD PTR [rsp + XX], rdx
+ case 0x244c894c: // 4c 89 4c 24 XX : mov QWORD PTR [rsp + XX], r9
+ case 0x2444894c: // 4c 89 44 24 XX : mov QWORD PTR [rsp + XX], r8
return 5;
case 0x24648348: // 48 83 64 24 XX : and QWORD PTR [rsp + XX], YY
return 6;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57339.185863.patch
Type: text/x-patch
Size: 3030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190207/d2bfd0fc/attachment.bin>
More information about the llvm-commits
mailing list