]> gcc.gnu.org Git - gcc.git/commitdiff
libgcc: avoid mmap/munmap hooks in split-stack code on GNU/Linux
authorIan Lance Taylor <iant@golang.org>
Fri, 3 Apr 2020 21:57:18 +0000 (14:57 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 3 Apr 2020 21:58:27 +0000 (14:58 -0700)
* generic-morestack.c: On GNU/Linux use __mmap/__munmap rather
than mmap/munmap, to avoid hooks.

libgcc/ChangeLog
libgcc/generic-morestack.c

index 7548e34764033fa8e68d77d33153ef71fa9c74d6..66e57ece69c1664b3e108337716869f12251730e 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-03  Ian Lance Taylor  <iant@golang.org>
+
+       * generic-morestack.c: On GNU/Linux use __mmap/__munmap rather
+       than mmap/munmap, to avoid hooks.
+
 2020-04-03  Jim Johnston  <jjohnst@us.ibm.com>
 
        * config/s390/tpf-unwind.h (MIN_PATRANGE, MAX_PATRANGE)
index c26dba1ae4a102907d3177ebd676e23ef35ae5d4..bb9f67a7366bccd7aa29ddcef702bb13bc23dcc8 100644 (file)
@@ -53,6 +53,23 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #include "generic-morestack.h"
 
+/* Some systems use LD_PRELOAD or similar tricks to add hooks to
+   mmap/munmap.  That breaks this code, because when we call mmap
+   there is enough stack space for the system call but there is not,
+   in general, enough stack space to run a hook.  At least when using
+   glibc on GNU/Linux we can avoid the problem by calling __mmap and
+   __munmap.  */
+
+#ifdef __gnu_linux__
+
+extern void *__mmap (void *, size_t, int, int, int, off_t);
+extern int __munmap (void *, size_t);
+
+#define mmap __mmap
+#define munmap __munmap
+
+#endif /* defined(__gnu_linux__) */
+
 typedef unsigned uintptr_type __attribute__ ((mode (pointer)));
 
 /* This file contains subroutines that are used by code compiled with
This page took 0.075403 seconds and 5 git commands to generate.