diff options
author | Timur Iskhodzhanov <timurrrr@google.com> | 2014-08-15 12:56:52 +0000 |
---|---|---|
committer | Timur Iskhodzhanov <timurrrr@google.com> | 2014-08-15 12:56:52 +0000 |
commit | f6cc004ee6490760c7b304ce740eb2fa3e553577 (patch) | |
tree | fa015413ff134debb21543cb0c29ccf89acb2872 | |
parent | b77dd3bbb65e41fc833a633036003cc84b11b213 (diff) |
[ASan/Win] Remove old, unused and non-functional code that will be re-written soon
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@215707 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/asan_malloc_win.cc | 29 | ||||
-rw-r--r-- | lib/interception/interception_win.cc | 14 | ||||
-rw-r--r-- | lib/interception/interception_win.h | 2 |
3 files changed, 1 insertions, 44 deletions
diff --git a/lib/asan/asan_malloc_win.cc b/lib/asan/asan_malloc_win.cc index b6d20d895..0e313c44b 100644 --- a/lib/asan/asan_malloc_win.cc +++ b/lib/asan/asan_malloc_win.cc @@ -133,37 +133,10 @@ int _CrtSetReportMode(int, int) { } } // extern "C" -using __interception::GetRealFunctionAddress; - -// We don't want to include "windows.h" in this file to avoid extra attributes -// set on malloc/free etc (e.g. dllimport), so declare a few things manually: -extern "C" int __stdcall VirtualProtect(void* addr, size_t size, - DWORD prot, DWORD *old_prot); -const int PAGE_EXECUTE_READWRITE = 0x40; - namespace __asan { void ReplaceSystemMalloc() { #if defined(_DLL) -# ifdef _WIN64 -# error ReplaceSystemMalloc was not tested on x64 -# endif - char *crt_malloc; - if (GetRealFunctionAddress("malloc", (void**)&crt_malloc)) { - // Replace malloc in the CRT dll with a jump to our malloc. - DWORD old_prot, unused; - CHECK(VirtualProtect(crt_malloc, 16, PAGE_EXECUTE_READWRITE, &old_prot)); - REAL(memset)(crt_malloc, 0xCC /* int 3 */, 16); // just in case. - - ptrdiff_t jmp_offset = (char*)malloc - (char*)crt_malloc - 5; - crt_malloc[0] = 0xE9; // jmp, should be followed by an offset. - REAL(memcpy)(crt_malloc + 1, &jmp_offset, sizeof(jmp_offset)); - - CHECK(VirtualProtect(crt_malloc, 16, old_prot, &unused)); - - // FYI: FlushInstructionCache is needed on Itanium etc but not on x86/x64. - } - - // FIXME: investigate whether anything else is needed. +# error MD CRT is not yet supported, see PR20214. #endif } } // namespace __asan diff --git a/lib/interception/interception_win.cc b/lib/interception/interception_win.cc index 261157fc7..a20939c77 100644 --- a/lib/interception/interception_win.cc +++ b/lib/interception/interception_win.cc @@ -19,20 +19,6 @@ namespace __interception { -bool GetRealFunctionAddress(const char *func_name, uptr *func_addr) { - const char *DLLS[] = { - "msvcr80.dll", - "msvcr90.dll", - "kernel32.dll", - NULL - }; - *func_addr = 0; - for (size_t i = 0; *func_addr == 0 && DLLS[i]; ++i) { - *func_addr = (uptr)GetProcAddress(GetModuleHandleA(DLLS[i]), func_name); - } - return (*func_addr != 0); -} - // FIXME: internal_str* and internal_mem* functions should be moved from the // ASan sources into interception/. diff --git a/lib/interception/interception_win.h b/lib/interception/interception_win.h index f2727c924..10534c004 100644 --- a/lib/interception/interception_win.h +++ b/lib/interception/interception_win.h @@ -22,8 +22,6 @@ #define INTERCEPTION_WIN_H namespace __interception { -// returns true if a function with the given name was found. -bool GetRealFunctionAddress(const char *func_name, uptr *func_addr); // returns true if the old function existed, false on failure. bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func); |