[sanitizer] Add 'strip_env' flag to enable/disable removing sanitizer dylib from...
authorKuba Mracek <mracek@apple.com>
Wed, 29 Nov 2017 21:42:48 +0000 (21:42 +0000)
committerKuba Mracek <mracek@apple.com>
Wed, 29 Nov 2017 21:42:48 +0000 (21:42 +0000)
commitceea5466eb029dcbbca998241ff98ed25afb5fcf
treebdf8cbc682fdf8d3b7ae963344712fbf324ea75c
parent7383b8e4fe6b115dafe3ad787af2074ade1def91
[sanitizer] Add 'strip_env' flag to enable/disable removing sanitizer dylib from DYLD_INSERT_LIBRARIES

On macOS, we usually don't require launching the target with DYLD_INSERT_LIBRARIES anymore. However, it is still necessary when running a target that is not instrumented (and e.g. dlopen's an instrument library later). In any case, ASan and TSan currently remove themselves from the DYLD_INSERT_LIBRARIES environment variable to avoid passing it onto children. This works well e.g. when instrumenting a shell. A problem arises when the target is a non-instrumented shim (e.g. "xcrun") that either re-execs or launches a child that is supposed to get DYLD_INSERT_LIBRARIES propagated. To support this mode, this patch introduces 'strip_env' flag that can be used to keep DYLD_INSERT_LIBRARIES untouched.

Differential Revision: https://reviews.llvm.org/D39991

llvm-svn: 319365
compiler-rt/lib/sanitizer_common/sanitizer_flags.inc
compiler-rt/lib/sanitizer_common/sanitizer_mac.cc
compiler-rt/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cc