[RFC,3/3] dl-sysdep: disable remaining calls to sbrk()

Message ID 20201004130938.64575-4-toiwoton@gmail.com
State Superseded
Headers
Series Improved ALSR |

Commit Message

Topi Miettinen Oct. 4, 2020, 1:09 p.m. UTC
  Since sbrk() is not used for memory allocations, there's no need to
initialize the break anymore.

RFC: how to do this properly? Removing frob_brk() entirely causes
build to break with strange link problems.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
---
 elf/dl-sysdep.c                     | 2 ++
 sysdeps/unix/sysv/linux/dl-sysdep.c | 2 ++
 2 files changed, 4 insertions(+)
  

Patch

diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index 854570821c..200cea3ca7 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -234,6 +234,7 @@  _dl_sysdep_start (void **start_argptr,
   if (GLRO(dl_platform) != NULL)
     GLRO(dl_platformlen) = strlen (GLRO(dl_platform));
 
+#if 0
   if (__sbrk (0) == _end)
     /* The dynamic linker was run as a program, and so the initial break
        starts just after our bss, at &_end.  The malloc in dl-minimal.c
@@ -242,6 +243,7 @@  _dl_sysdep_start (void **start_argptr,
        will see this new value and not clobber our data.  */
     __sbrk (GLRO(dl_pagesize)
 	    - ((_end - (char *) 0) & (GLRO(dl_pagesize) - 1)));
+#endif
 
   /* If this is a SUID program we make sure that FDs 0, 1, and 2 are
      allocated.  If necessary we are doing it ourself.  If it is not
diff --git a/sysdeps/unix/sysv/linux/dl-sysdep.c b/sysdeps/unix/sysv/linux/dl-sysdep.c
index 90c9b1db2d..d2f64b1137 100644
--- a/sysdeps/unix/sysv/linux/dl-sysdep.c
+++ b/sysdeps/unix/sysv/linux/dl-sysdep.c
@@ -33,7 +33,9 @@ 
 static inline void
 frob_brk (void)
 {
+#if 0
   __brk (0);			/* Initialize the break.  */
+#endif
 }
 
 # include <elf/dl-sysdep.c>