diff options
| author | Kostya Serebryany <kcc@google.com> | 2011-12-14 00:19:03 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2011-12-14 00:19:03 +0000 |
| commit | 9bd5208965839495dc463203c23330d599e541d1 (patch) | |
| tree | e863632f6758d0a65a6e50479d3c401484e3232d | |
| parent | e85da735537011f48660e1cee798a0b37a8e82e3 (diff) | |
| download | bcm5719-llvm-9bd5208965839495dc463203c23330d599e541d1.tar.gz bcm5719-llvm-9bd5208965839495dc463203c23330d599e541d1.zip | |
[asan] insert __asan_init into ".preinit_array" section. Linux-only.
llvm-svn: 146529
| -rw-r--r-- | compiler-rt/lib/asan/Makefile.old | 2 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/compiler-rt/lib/asan/Makefile.old b/compiler-rt/lib/asan/Makefile.old index 6d3aaf73a00..32829db0747 100644 --- a/compiler-rt/lib/asan/Makefile.old +++ b/compiler-rt/lib/asan/Makefile.old @@ -287,8 +287,6 @@ lib: $(LIBASAN_A) $(LIBASAN_A): $(BIN) $(LIBASAN_OBJ) $(MAKEFILE) mkdir -p $(LIBASAN_INST_DIR) ar ru $@ $(LIBASAN_OBJ) - $(CXX) -shared $(CFLAGS) $(LIBASAN_OBJ) $(LD_FLAGS) -o $(BIN)/libasan$(SUFF).so - TEST_OBJECTS_COMMON=\ $(BIN)/asan_test$(SUFF).o \ diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 3ea28754ad9..570dd4e5d5a 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -774,3 +774,11 @@ void __asan_init() { Report("AddressSanitizer Init done\n"); } } + +#ifdef __linux__ +// On Linux, we force __asan_init to be called before anyone else +// by placing it into .preinit_array section. +// FIXME: do we have anything like this on Mac? +__attribute__((section(".preinit_array"))) + typeof(__asan_init) *__asan_preinit =__asan_init; +#endif |

