[PATCH] [ASan] Move ASan runtime library self-checks to a more appropriate place.
Yury Gribov
tetra2005 at gmail.com
Wed Jun 3 07:11:48 PDT 2015
Hi samsonov, kcc, dvyukov,
This moves ASan runtime library checking to after flag parsing thus reducing copy-paste and also respecting ASAN_OPTIONS (e.g. log_path) when reporting errors.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D10212
Files:
lib/asan/asan_linux.cc
lib/asan/asan_rtl.cc
Index: lib/asan/asan_linux.cc
===================================================================
--- lib/asan/asan_linux.cc
+++ lib/asan/asan_linux.cc
@@ -113,6 +113,9 @@
}
void AsanCheckDynamicRTPrereqs() {
+ if (!ASAN_DYNAMIC)
+ return;
+
// Ensure that dynamic RT is the first DSO in the list
const char *first_dso_name = 0;
dl_iterate_phdr(FindFirstDSOCallback, &first_dso_name);
Index: lib/asan/asan_rtl.cc
===================================================================
--- lib/asan/asan_rtl.cc
+++ lib/asan/asan_rtl.cc
@@ -367,6 +367,9 @@
// initialization steps look at flags().
InitializeFlags();
+ AsanCheckIncompatibleRT();
+ AsanCheckDynamicRTPrereqs();
+
SetCanPoisonMemory(flags()->poison_heap);
SetMallocContextSize(common_flags()->malloc_context_size);
@@ -514,13 +517,11 @@
#if ASAN_DYNAMIC
// Initialize runtime in case it's LD_PRELOAD-ed into unsanitized executable
-// (and thus normal initializer from .preinit_array haven't run).
+// (and thus normal initializers from .preinit_array or modules haven't run).
class AsanInitializer {
public: // NOLINT
AsanInitializer() {
- AsanCheckIncompatibleRT();
- AsanCheckDynamicRTPrereqs();
AsanInitFromRtl();
}
};
@@ -572,7 +573,6 @@
// Initialize as requested from instrumented application code.
// We use this call as a trigger to wake up ASan from deactivated state.
void __asan_init() {
- AsanCheckIncompatibleRT();
AsanActivate();
AsanInitInternal();
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10212.27036.patch
Type: text/x-patch
Size: 1499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150603/b2f77b9b/attachment.bin>
More information about the llvm-commits
mailing list