[ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=159
authorAlexander Potapenko <glider@google.com>
Fri, 15 Feb 2013 16:10:49 +0000 (16:10 +0000)
committerAlexander Potapenko <glider@google.com>
Fri, 15 Feb 2013 16:10:49 +0000 (16:10 +0000)
commit3182c3e441c6c63a3b0647d3f16ac735e54f3f5a
tree41a48342d746540ef927daf5468ff13da637935d
parentbe2eced483a9b844db0dee61612da5ecc7c3eb28
[ASan] Fix https://code.google.com/p/address-sanitizer/issues/detail?id=159
MaybeReexec() does now a tricky job to manage DYLD_INSERT_LIBRARIES in a safe way.

Because we're using library interposition, it's critical for an instrumented app
to be executed with the runtime library present in DYLD_INSERT_LIBRARIES list.
Therefore if it's initially missing in that list, we append the runtime library name
to the value of DYLD_INSERT_LIBRARIES and then exec() ourselves.

On the other hand, some of the apps exec()ed by our program may not want to have
ASan runtime library preloaded, so we remove the runtime library from the
DYLD_INSERT_LIBRARIES if it's already there.

Users may want to preload other libraries using DYLD_INSERT_LIBRARIES, so we preserve those.

llvm-svn: 175276
compiler-rt/lib/asan/asan_mac.cc
compiler-rt/lib/asan/lit_tests/Darwin/unset-insert-libraries-on-exec.cc [new file with mode: 0644]