[compiler-rt] r212699 - [ASan/Win] Don't hardcode ASan runtime version in ASan dll thunk
Timur Iskhodzhanov
timurrrr at google.com
Thu Jul 10 03:33:49 PDT 2014
Author: timurrrr
Date: Thu Jul 10 05:33:48 2014
New Revision: 212699
URL: http://llvm.org/viewvc/llvm-project?rev=212699&view=rev
Log:
[ASan/Win] Don't hardcode ASan runtime version in ASan dll thunk
Reviewed at http://reviews.llvm.org/D4459
Added:
compiler-rt/trunk/lib/asan/asan_init_version.h
Modified:
compiler-rt/trunk/lib/asan/asan_dll_thunk.cc
compiler-rt/trunk/lib/asan/asan_interface_internal.h
compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
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=212699&r1=212698&r2=212699&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_dll_thunk.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_dll_thunk.cc Thu Jul 10 05:33:48 2014
@@ -20,6 +20,7 @@
// Using #ifdef rather than relying on Makefiles etc.
// simplifies the build procedure.
#ifdef ASAN_DLL_THUNK
+#include "asan_init_version.h"
#include "sanitizer_common/sanitizer_interception.h"
// ---------- Function interception helper functions and macros ----------- {{{1
@@ -203,13 +204,13 @@ extern "C" {
// Manually wrap __asan_init as we need to initialize
// __asan_option_detect_stack_use_after_return afterwards.
- void __asan_init_v4() {
+ void __asan_init() {
typedef void (*fntype)();
static fntype fn = 0;
- // __asan_init_v4 is expected to be called by only one thread.
+ // __asan_init is expected to be called by only one thread.
if (fn) return;
- fn = (fntype)getRealProcAddressOrDie("__asan_init_v4");
+ fn = (fntype)getRealProcAddressOrDie(__asan_init_name);
fn();
__asan_option_detect_stack_use_after_return =
(__asan_should_detect_stack_use_after_return() != 0);
@@ -339,7 +340,7 @@ void InterceptHooks() {
// In DLLs, the callbacks are expected to return 0,
// otherwise CRT initialization fails.
static int call_asan_init() {
- __asan_init_v4();
+ __asan_init();
return 0;
}
#pragma section(".CRT$XIB", long, read) // NOLINT
Added: compiler-rt/trunk/lib/asan/asan_init_version.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_init_version.h?rev=212699&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_init_version.h (added)
+++ compiler-rt/trunk/lib/asan/asan_init_version.h Thu Jul 10 05:33:48 2014
@@ -0,0 +1,37 @@
+//===-- asan_init_version.h -------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// This header defines a versioned __asan_init function to be called at the
+// startup of the instrumented program.
+//===----------------------------------------------------------------------===//
+#ifndef ASAN_INIT_VERSION_H
+#define ASAN_INIT_VERSION_H
+
+#include "sanitizer_common/sanitizer_internal_defs.h"
+
+extern "C" {
+ // This function should be called at the very beginning of the process,
+ // before any instrumented code is executed and before any call to malloc.
+ // Every time the ASan ABI changes we also change the version number in this
+ // name. Objects build with incompatible ASan ABI version
+ // will not link with run-time.
+ // Changes between ABI versions:
+ // v1=>v2: added 'module_name' to __asan_global
+ // v2=>v3: stack frame description (created by the compiler)
+ // contains the function PC as the 3-rd field (see
+ // DescribeAddressIfStack).
+ // v3=>v4: added '__asan_global_source_location' to __asan_global.
+ SANITIZER_INTERFACE_ATTRIBUTE void __asan_init_v4();
+ #define __asan_init __asan_init_v4
+ #define __asan_init_name "__asan_init_v4"
+}
+
+#endif // ASAN_INIT_VERSION_H
Modified: compiler-rt/trunk/lib/asan/asan_interface_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interface_internal.h?rev=212699&r1=212698&r2=212699&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interface_internal.h (original)
+++ compiler-rt/trunk/lib/asan/asan_interface_internal.h Thu Jul 10 05:33:48 2014
@@ -17,23 +17,11 @@
#include "sanitizer_common/sanitizer_internal_defs.h"
+#include "asan_init_version.h"
+
using __sanitizer::uptr;
extern "C" {
- // This function should be called at the very beginning of the process,
- // before any instrumented code is executed and before any call to malloc.
- // Every time the asan ABI changes we also change the version number in this
- // name. Objects build with incompatible asan ABI version
- // will not link with run-time.
- // Changes between ABI versions:
- // v1=>v2: added 'module_name' to __asan_global
- // v2=>v3: stack frame description (created by the compiler)
- // contains the function PC as the 3-rd field (see
- // DescribeAddressIfStack).
- // v3=>v4: added '__asan_global_source_location' to __asan_global.
- SANITIZER_INTERFACE_ATTRIBUTE void __asan_init_v4();
- #define __asan_init __asan_init_v4
-
// This structure is used to describe the source location of a place where
// global was defined.
struct __asan_global_source_location {
Modified: compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c?rev=212699&r1=212698&r2=212699&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c Thu Jul 10 05:33:48 2014
@@ -16,6 +16,7 @@
// RUN: | grep -v "__asan_on_error" > %t.symbols
// RUN: cat %p/../../../../lib/asan/asan_interface_internal.h \
+// RUN: %p/../../../../lib/asan/asan_init_version.h \
// RUN: | sed "s/\/\/.*//" | sed "s/typedef.*//" \
// RUN: | grep -v "OPTIONAL" \
// RUN: | grep "__asan_.*(" | sed "s/.* __asan_/__asan_/;s/(.*//" \
Modified: compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c?rev=212699&r1=212698&r2=212699&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c Thu Jul 10 05:33:48 2014
@@ -9,6 +9,7 @@
// RUN: | grep -v "__asan_stack_" \
// RUN: | grep -v "__asan_on_error" > %t.symbols
// RUN: cat %p/../../../../lib/asan/asan_interface_internal.h \
+// RUN: %p/../../../../lib/asan/asan_init_version.h \
// RUN: | sed "s/\/\/.*//" | sed "s/typedef.*//" \
// RUN: | grep -v "OPTIONAL" \
// RUN: | grep "__asan_.*(" | sed "s/.* __asan_/__asan_/;s/(.*//" \
More information about the llvm-commits
mailing list