[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.

llvm-svn: 272870
This commit is contained in:
Derek Bruening 2016-06-16 03:19:58 +00:00
parent ceda65bdc4
commit 91c88e6558
1 changed files with 6 additions and 0 deletions

View File

@ -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))