e354a5
commit 758599bc9dcc5764e862bd9e1613c5d1e6efc5d3
e354a5
Author: Florian Weimer <fweimer@redhat.com>
e354a5
Date:   Wed Feb 26 15:58:23 2020 +0100
e354a5
e354a5
    elf: Apply attribute_relro to pointers in elf/dl-minimal.c
e354a5
    
e354a5
    The present code leaves the function pointers unprotected, but moves
e354a5
    some of the static functions into .data.rel.ro instead.  This causes
e354a5
    the linker to produce an allocatable, executable, writable section
e354a5
    and eventually an RWX load segment.  Not only do we really do not
e354a5
    want that, it also breaks valgrind because valgrind does not load
e354a5
    debuginfo from the mmap interceptor if all it sees are RX and RWX
e354a5
    mappings.
e354a5
    
e354a5
    Fixes commit 3a0ecccb599a6b1ad4b149dc569c0080e92d057b ("ld.so: Do not
e354a5
    export free/calloc/malloc/realloc functions [BZ #25486]").
e354a5
e354a5
diff --git a/elf/dl-minimal.c b/elf/dl-minimal.c
e354a5
index 95ea7b024044864f..4335f1bd24289b01 100644
e354a5
--- a/elf/dl-minimal.c
e354a5
+++ b/elf/dl-minimal.c
e354a5
@@ -39,16 +39,16 @@
e354a5
   implementation below.  Before the final relocation,
e354a5
   __rtld_malloc_init_real is called to replace the pointers with the
e354a5
   real implementation.  */
e354a5
-__typeof (calloc) *__rtld_calloc;
e354a5
-__typeof (free) *__rtld_free;
e354a5
-__typeof (malloc) *__rtld_malloc;
e354a5
-__typeof (realloc) *__rtld_realloc;
e354a5
+__typeof (calloc) *__rtld_calloc attribute_relro;
e354a5
+__typeof (free) *__rtld_free attribute_relro;
e354a5
+__typeof (malloc) *__rtld_malloc attribute_relro;
e354a5
+__typeof (realloc) *__rtld_realloc attribute_relro;
e354a5
 
e354a5
 /* Defined below.  */
e354a5
-static __typeof (calloc) rtld_calloc attribute_relro;
e354a5
-static __typeof (free) rtld_free attribute_relro;
e354a5
-static __typeof (malloc) rtld_malloc attribute_relro;
e354a5
-static __typeof (realloc) rtld_realloc attribute_relro;
e354a5
+static __typeof (calloc) rtld_calloc;
e354a5
+static __typeof (free) rtld_free;
e354a5
+static __typeof (malloc) rtld_malloc;
e354a5
+static __typeof (realloc) rtld_realloc;
e354a5
 
e354a5
 void
e354a5
 __rtld_malloc_init_stubs (void)