summaryrefslogtreecommitdiff
path: root/lib/esan
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2016-06-16 03:19:58 +0000
committerDerek Bruening <bruening@google.com>2016-06-16 03:19:58 +0000
commited4063874ac289bc42a04347853716bb8b74f9de (patch)
treefb6d5020753e0c6e1a40b557c4ce425a10965f19 /lib/esan
parent3efa8acf9ed8179a8d8030265fc71133e102519c (diff)
[esan] Use internal_mmap during initialization
Fixes another interceptor issue where an app with a static tcmalloc library that prevents our early-calloc handling from triggering yet does not have a static mmap crashes in our mmap interceptor. The solution is to call internal_mmap when REAL(mmap) is not yet set up. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272870 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/esan')
-rw-r--r--lib/esan/esan_interceptors.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/esan/esan_interceptors.cpp b/lib/esan/esan_interceptors.cpp
index 7aefeb664..188336bed 100644
--- a/lib/esan/esan_interceptors.cpp
+++ b/lib/esan/esan_interceptors.cpp
@@ -338,6 +338,12 @@ INTERCEPTOR(int, rmdir, char *path) {
INTERCEPTOR(void *, mmap, void *addr, SIZE_T sz, int prot, int flags,
int fd, OFF_T off) {
+ if (UNLIKELY(REAL(mmap) == nullptr)) {
+ // With esan init during interceptor init and a static libc preventing
+ // our early-calloc from triggering, we can end up here before our
+ // REAL pointer is set up.
+ return (void *)internal_mmap(addr, sz, prot, flags, fd, off);
+ }
void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, mmap, addr, sz, prot, flags, fd, off);
if (!fixMmapAddr(&addr, sz, flags))