summaryrefslogtreecommitdiff
path: root/lib/interception
diff options
context:
space:
mode:
authorEtienne Bergeron <etienneb@google.com>2016-07-15 17:26:33 +0000
committerEtienne Bergeron <etienneb@google.com>2016-07-15 17:26:33 +0000
commit3b792239023d2c56f94485d1d8a8a550276e05ea (patch)
tree0387bea6120ea279dcf00d2001de31a2f883c521 /lib/interception
parent69d7486b23a20f021f4a36ff5e93a4e6fccde2df (diff)
[compiler-rt] Fix incorrect handling of indirect load.
Summary: Indirect load are relative offset from RIP. The current trampoline implementation is incorrectly copying these instructions which make some unittests crashing. This patch is not fixing the unittests but it's fixing the crashes. The functions are no longer hooked. Patches will come soon to fix these unittests. Reviewers: rnk Subscribers: llvm-commits, wang0109, chrisha Differential Revision: https://reviews.llvm.org/D22410 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275584 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/interception')
-rw-r--r--lib/interception/interception_win.cc18
1 files changed, 3 insertions, 15 deletions
diff --git a/lib/interception/interception_win.cc b/lib/interception/interception_win.cc
index b42164d55..8977d59ac 100644
--- a/lib/interception/interception_win.cc
+++ b/lib/interception/interception_win.cc
@@ -410,6 +410,7 @@ static size_t GetInstructionSize(uptr address) {
case 0xb8: // b8 XX XX XX XX : mov eax, XX XX XX XX
case 0xB9: // b9 XX XX XX XX : mov ecx, XX XX XX XX
+ case 0xA1: // A1 XX XX XX XX : mov eax, dword ptr ds:[XXXXXXXX]
return 5;
// Cannot overwrite control-instruction. Return 0 to indicate failure.
@@ -452,11 +453,6 @@ static size_t GetInstructionSize(uptr address) {
}
#if SANITIZER_WINDOWS64
- switch (*(u8*)address) {
- case 0xA1: // A1 XX XX XX XX XX XX XX XX :
- // movabs eax, dword ptr ds:[XXXXXXXX]
- return 8;
- }
switch (*(u16*)address) {
case 0x5040: // push rax
case 0x5140: // push rcx
@@ -504,12 +500,7 @@ static size_t GetInstructionSize(uptr address) {
// mov rax, QWORD PTR [rip + XXXXXXXX]
case 0x25ff48: // 48 ff 25 XX XX XX XX :
// rex.W jmp QWORD PTR [rip + XXXXXXXX]
- // Instructions having offset relative to 'rip' cannot be copied.
- return 0;
-
- case 0x2444c7: // C7 44 24 XX YY YY YY YY
- // mov dword ptr [rsp + XX], YYYYYYYY
- return 8;
+ return 7;
}
switch (*(u32*)(address)) {
@@ -521,10 +512,7 @@ static size_t GetInstructionSize(uptr address) {
}
#else
- switch (*(u8*)address) {
- case 0xA1: // A1 XX XX XX XX : mov eax, dword ptr ds:[XXXXXXXX]
- return 5;
- }
+
switch (*(u16*)address) {
case 0x458B: // 8B 45 XX : mov eax, dword ptr [ebp + XX]
case 0x5D8B: // 8B 5D XX : mov ebx, dword ptr [ebp + XX]