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