diff options
| author | Timur Iskhodzhanov <timurrrr@google.com> | 2014-05-30 09:01:17 +0000 |
|---|---|---|
| committer | Timur Iskhodzhanov <timurrrr@google.com> | 2014-05-30 09:01:17 +0000 |
| commit | 5bed4206c8bf6604aef3146e9613194f6b6bf2ee (patch) | |
| tree | 3306ccfca8f25cfc111dbac654808a5c7a5a6d6e | |
| parent | ce6538c38dd70a15552152f21045cf5b0beb61d5 (diff) | |
| download | bcm5719-llvm-5bed4206c8bf6604aef3146e9613194f6b6bf2ee.tar.gz bcm5719-llvm-5bed4206c8bf6604aef3146e9613194f6b6bf2ee.zip | |
[ASan Win] DLL thunk: make each INTERFACE_FUNCTION unique to prevent ICF linker optimizations
llvm-svn: 209881
| -rw-r--r-- | compiler-rt/lib/asan/asan_dll_thunk.cc | 5 | ||||
| -rw-r--r-- | compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cc | 4 | ||||
| -rw-r--r-- | compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cc | 4 |
3 files changed, 12 insertions, 1 deletions
diff --git a/compiler-rt/lib/asan/asan_dll_thunk.cc b/compiler-rt/lib/asan/asan_dll_thunk.cc index 2dc41447158..15482ba8ca3 100644 --- a/compiler-rt/lib/asan/asan_dll_thunk.cc +++ b/compiler-rt/lib/asan/asan_dll_thunk.cc @@ -74,7 +74,10 @@ struct FunctionInterceptor<0> { // Special case of hooks -- ASan own interface functions. Those are only called // after __asan_init, thus an empty implementation is sufficient. #define INTERFACE_FUNCTION(name) \ - extern "C" void name() { __debugbreak(); } \ + extern "C" void name() { \ + volatile int prevent_icf = (__LINE__ << 8); (void)prevent_icf; \ + __debugbreak(); \ + } \ INTERCEPT_WHEN_POSSIBLE(#name, name) // INTERCEPT_HOOKS must be used after the last INTERCEPT_WHEN_POSSIBLE. diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cc b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cc index cb220983924..befeca67efd 100644 --- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cc +++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memcpy.cc @@ -2,6 +2,10 @@ // RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll // RUN: not %run %t %t.dll 2>&1 | FileCheck %s +// Test that it works correctly even with ICF enabled. +// RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll -link /OPT:REF /OPT:ICF +// RUN: not %run %t %t.dll 2>&1 | FileCheck %s + #include <stdio.h> #include <string.h> diff --git a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cc b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cc index 01ffbcea30e..b5bc1e74178 100644 --- a/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cc +++ b/compiler-rt/test/asan/TestCases/Windows/dll_intercept_memset.cc @@ -2,6 +2,10 @@ // RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll // RUN: not %run %t %t.dll 2>&1 | FileCheck %s +// Test that it works correctly even with ICF enabled. +// RUN: %clang_cl_asan -LD -O0 %s -Fe%t.dll -link /OPT:REF /OPT:ICF +// RUN: not %run %t %t.dll 2>&1 | FileCheck %s + #include <stdio.h> #include <string.h> |

