[compiler-rt] r209881 - [ASan Win] DLL thunk: make each INTERFACE_FUNCTION unique to prevent ICF linker optimizations
Timur Iskhodzhanov
timurrrr at google.com
Fri May 30 02:01:19 PDT 2014
Author: timurrrr
Date: Fri May 30 04:01:17 2014
New Revision: 209881
URL: http://llvm.org/viewvc/llvm-project?rev=209881&view=rev
Log:
[ASan Win] DLL thunk: make each INTERFACE_FUNCTION unique to prevent ICF linker optimizations
Modified:
compiler-rt/trunk/lib/asan/asan_dll_thunk.cc
compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memcpy.cc
compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memset.cc
Modified: compiler-rt/trunk/lib/asan/asan_dll_thunk.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_dll_thunk.cc?rev=209881&r1=209880&r2=209881&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_dll_thunk.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_dll_thunk.cc Fri May 30 04:01:17 2014
@@ -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.
Modified: compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memcpy.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memcpy.cc?rev=209881&r1=209880&r2=209881&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memcpy.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memcpy.cc Fri May 30 04:01:17 2014
@@ -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>
Modified: compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memset.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memset.cc?rev=209881&r1=209880&r2=209881&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memset.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/dll_intercept_memset.cc Fri May 30 04:01:17 2014
@@ -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>
More information about the llvm-commits
mailing list