diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-10-31 16:58:44 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-10-31 16:58:44 +0000 |
| commit | 13322c6edab73d18473120d12d5cf4ca9f71c179 (patch) | |
| tree | 9ff15b383f61eb876cb27a32e69761f70bbc861e /compiler-rt/lib | |
| parent | d41dbadacd42596900ad5f29fcca6ae11a55c0b5 (diff) | |
| download | bcm5719-llvm-13322c6edab73d18473120d12d5cf4ca9f71c179.tar.gz bcm5719-llvm-13322c6edab73d18473120d12d5cf4ca9f71c179.zip | |
[msan] Intercept dlerror.
llvm-svn: 193760
Diffstat (limited to 'compiler-rt/lib')
| -rw-r--r-- | compiler-rt/lib/msan/lit_tests/dlerror.cc | 14 | ||||
| -rw-r--r-- | compiler-rt/lib/msan/msan_interceptors.cc | 8 |
2 files changed, 22 insertions, 0 deletions
diff --git a/compiler-rt/lib/msan/lit_tests/dlerror.cc b/compiler-rt/lib/msan/lit_tests/dlerror.cc new file mode 100644 index 00000000000..281b3164fd7 --- /dev/null +++ b/compiler-rt/lib/msan/lit_tests/dlerror.cc @@ -0,0 +1,14 @@ +// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t + +#include <assert.h> +#include <dlfcn.h> +#include <stdio.h> +#include <string.h> + +int main(void) { + void *p = dlopen("/bad/file/name", RTLD_NOW); + assert(!p); + char *s = dlerror(); + printf("%s, %zu\n", s, strlen(s)); + return 0; +} diff --git a/compiler-rt/lib/msan/msan_interceptors.cc b/compiler-rt/lib/msan/msan_interceptors.cc index 8c867c3bcde..b96e4b3fcc7 100644 --- a/compiler-rt/lib/msan/msan_interceptors.cc +++ b/compiler-rt/lib/msan/msan_interceptors.cc @@ -896,6 +896,13 @@ INTERCEPTOR(int, dladdr, void *addr, dlinfo *info) { return res; } +INTERCEPTOR(char *, dlerror) { + ENSURE_MSAN_INITED(); + char *res = REAL(dlerror)(); + if (res != 0) __msan_unpoison(res, REAL(strlen)(res) + 1); + return res; +} + // dlopen() ultimately calls mmap() down inside the loader, which generally // doesn't participate in dynamic symbol resolution. Therefore we won't // intercept its calls to mmap, and we have to hook it here. The loader @@ -1497,6 +1504,7 @@ void InitializeInterceptors() { INTERCEPT_FUNCTION(recv); INTERCEPT_FUNCTION(recvfrom); INTERCEPT_FUNCTION(dladdr); + INTERCEPT_FUNCTION(dlerror); INTERCEPT_FUNCTION(dlopen); INTERCEPT_FUNCTION(dl_iterate_phdr); INTERCEPT_FUNCTION(getrusage); |

