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