[msan] intercept dlopen and clear shadow for it
authorReid Kleckner <reid@kleckner.net>
Mon, 11 Mar 2013 18:07:42 +0000 (18:07 +0000)
committerReid Kleckner <reid@kleckner.net>
Mon, 11 Mar 2013 18:07:42 +0000 (18:07 +0000)
commitc9d382b5a49feff338d730e160c35c2f29f24711
tree815c535d2ebf8c7e93d759889df7b1fffc87a156
parent06d274fdb7c82bbfdd1ff262054f5286bef930f8
[msan] intercept dlopen and clear shadow for it

Summary:
The loader does not call mmap() through the PLT because it has to
bootstrap the process before libc is present.  Hooking dlopen() isn't
enough either because the loader runs module initializers before
returning, and they could run arbitrary msan instrumented code.

If msandr is present, then we can intercept the mmaps from dlopen at the
syscall layer and clear the shadow there.  If msandr is missing, we
clear the shadow after dlopen() and hope any initializers are trivial.

Reviewers: eugenis

CC: kcc, llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D509

llvm-svn: 176818
compiler-rt/lib/msan/msan.cc
compiler-rt/lib/msan/msan.h
compiler-rt/lib/msan/msan_interceptors.cc
compiler-rt/lib/msan/msan_interface_internal.h
compiler-rt/lib/msan/msan_linux.cc
compiler-rt/lib/msan/tests/CMakeLists.txt
compiler-rt/lib/msan/tests/msan_loadable.cc [new file with mode: 0644]
compiler-rt/lib/msan/tests/msan_test.cc
compiler-rt/lib/msandr/msandr.cc