From: Timur Iskhodzhanov Date: Fri, 30 May 2014 09:01:17 +0000 (+0000) Subject: [ASan Win] DLL thunk: make each INTERFACE_FUNCTION unique to prevent ICF linker optim... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5bed4206c8bf6604aef3146e9613194f6b6bf2ee;p=platform%2Fupstream%2Fllvm.git [ASan Win] DLL thunk: make each INTERFACE_FUNCTION unique to prevent ICF linker optimizations llvm-svn: 209881 --- diff --git a/compiler-rt/lib/asan/asan_dll_thunk.cc b/compiler-rt/lib/asan/asan_dll_thunk.cc index 2dc4144..15482ba 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 cb22098..befeca6 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 #include 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 01ffbce..b5bc1e7 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 #include