Index: external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc =================================================================== RCS file: /cvsroot/src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc,v retrieving revision 1.17 diff -u -r1.17 sanitizer_linux.cc --- external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc 23 May 2018 11:14:49 -0000 1.17 +++ external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc 25 May 2018 05:30:26 -0000 @@ -72,6 +72,7 @@ #include // For NAME_MAX #include extern char **environ; // provided by crt1 +#include #endif // SANITIZER_NETBSD #if !SANITIZER_ANDROID @@ -113,8 +114,17 @@ uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd, OFF_T offset) { #if SANITIZER_NETBSD - return internal_syscall64(SYSCALL(mmap), addr, length, prot, flags, fd, - (long)0, offset); + static uptr (*real___mmap)(void *a, uptr b, int c, int d, int e, int f, + OFF_T g) = NULL; + if (!real___mmap) { + real___mmap = (uptr(*)(void *a, uptr b, int c, int d, int e, int f, + OFF_T g))dlsym(RTLD_NEXT, "__mmap"); + if (!real___mmap) { + real___mmap = (uptr(*)(void *a, uptr b, int c, int d, int e, int f, + OFF_T g))dlsym(RTLD_DEFAULT, "__mmap"); + } + } + return (*real___mmap)(addr, length, prot, flags, fd, 0, offset); #elif SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS return internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd, offset, 0); @@ -127,7 +137,18 @@ } uptr internal_munmap(void *addr, uptr length) { +#if SANITIZER_NETBSD + static uptr (*real_munmap)(void *a, uptr b) = NULL; + if (!real_munmap) { + real_munmap = (uptr(*)(void *a, uptr b))dlsym(RTLD_NEXT, "munmap"); + if (!real_munmap) { + real_munmap = (uptr(*)(void *a, uptr b))dlsym(RTLD_DEFAULT, "munmap"); + } + } + return (*real_munmap)(addr, length); +#else return internal_syscall(SYSCALL(munmap), (uptr)addr, length); +#endif } int internal_mprotect(void *addr, uptr length, int prot) {