summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/interception/interception_win.cc
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2014-01-29 02:00:58 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2014-01-29 02:00:58 +0000
commit50672ac9cbf987696a2a27a4d144f2a4f9683b66 (patch)
tree03ef5181b4e4c9f9bf19aaf9d382eeec06442bd5 /compiler-rt/lib/interception/interception_win.cc
parent92d64d2d565b3c86686751d192c2c6e18c8b54f5 (diff)
downloadbcm5719-llvm-50672ac9cbf987696a2a27a4d144f2a4f9683b66.tar.gz
bcm5719-llvm-50672ac9cbf987696a2a27a4d144f2a4f9683b66.zip
Add support for more instruction prefixes so we can intercept functions in the VS2013 RTL
llvm-svn: 200366
Diffstat (limited to 'compiler-rt/lib/interception/interception_win.cc')
-rw-r--r--compiler-rt/lib/interception/interception_win.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/compiler-rt/lib/interception/interception_win.cc b/compiler-rt/lib/interception/interception_win.cc
index abbab24970c..2331da55c4f 100644
--- a/compiler-rt/lib/interception/interception_win.cc
+++ b/compiler-rt/lib/interception/interception_win.cc
@@ -89,11 +89,22 @@ bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func) {
size_t head = 0;
while (head < 5) {
switch (old_bytes[head]) {
+ case '\x51': // push ecx
+ case '\x52': // push edx
+ case '\x53': // push ebx
+ case '\x54': // push esp
case '\x55': // push ebp
case '\x56': // push esi
case '\x57': // push edi
+ case '\x5D': // pop ebp
head++;
continue;
+ case '\x6A': // 6A XX = push XX
+ head += 2;
+ continue;
+ case '\xE9': // E9 XX YY ZZ WW = jmp WWZZYYXX
+ head += 5;
+ continue;
}
switch (*(unsigned short*)(old_bytes + head)) { // NOLINT
case 0xFF8B: // 8B FF = mov edi, edi
@@ -101,23 +112,34 @@ bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func) {
case 0xC033: // 33 C0 = xor eax, eax
head += 2;
continue;
+ case 0x458B: // 8B 45 XX = mov eax, dword ptr [ebp+XXh]
+ case 0x5D8B: // 8B 5D XX = mov ebx, dword ptr [ebp+XXh]
case 0xEC83: // 83 EC XX = sub esp, XX
head += 3;
continue;
case 0xC1F7: // F7 C1 XX YY ZZ WW = test ecx, WWZZYYXX
head += 6;
continue;
+ case 0x3D83: // 83 3D XX YY ZZ WW TT = cmp TT, WWZZYYXX
+ head += 7;
+ continue;
}
switch (0x00FFFFFF & *(unsigned int*)(old_bytes + head)) {
case 0x24448A: // 8A 44 24 XX = mov eal, dword ptr [esp+XXh]
case 0x244C8B: // 8B 4C 24 XX = mov ecx, dword ptr [esp+XXh]
case 0x24548B: // 8B 54 24 XX = mov edx, dword ptr [esp+XXh]
+ case 0x24748B: // 8B 74 24 XX = mov esi, dword ptr [esp+XXh]
case 0x247C8B: // 8B 7C 24 XX = mov edi, dword ptr [esp+XXh]
head += 4;
continue;
}
// Unknown instruction!
+ // FIXME: Unknown instruction failures might happen when we add a new
+ // interceptor or a new compiler version. In either case, they should result
+ // in visible and readable error messages. However, merely calling abort()
+ // or __debugbreak() leads to an infinite recursion in CheckFailed.
+ // Do we have a good way to abort with an error message here?
return false;
}
OpenPOWER on IntegriCloud