about summary refs log tree commit diff
path: root/sysdeps/microblaze
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-02-25 12:10:57 +0100
committerFlorian Weimer <fweimer@redhat.com>2021-02-25 12:13:02 +0100
commit035c012e32c11e84d64905efaf55e74f704d3668 (patch)
tree7b08a9e9cbd8e4dd2e420cd6b7c204aeb5d61ccc /sysdeps/microblaze
parenta79328c745219dcb395070cdcd3be065a8347f24 (diff)
downloadglibc-035c012e32c11e84d64905efaf55e74f704d3668.tar.gz
glibc-035c012e32c11e84d64905efaf55e74f704d3668.tar.xz
glibc-035c012e32c11e84d64905efaf55e74f704d3668.zip
Reduce the statically linked startup code [BZ #23323]
It turns out the startup code in csu/elf-init.c has a perfect pair of
ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, "return-to-csu: A
New Method to Bypass 64-bit Linux ASLR").  These functions are not
needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY
are already processed by the dynamic linker.  However, the dynamic
linker skipped the main program for some reason.  For maximum
backwards compatibility, this is not changed, and instead, the main
map is consulted from __libc_start_main if the init function argument
is a NULL pointer.

For statically linked binaries, the old approach based on linker
symbols is still used because there is nothing else available.

A new symbol version __libc_start_main@@GLIBC_2.34 is introduced because
new binaries running on an old libc would not run their ELF
constructors, leading to difficult-to-debug issues.
Diffstat (limited to 'sysdeps/microblaze')
-rw-r--r--sysdeps/microblaze/start.S8
1 files changed, 4 insertions, 4 deletions
diff --git a/sysdeps/microblaze/start.S b/sysdeps/microblaze/start.S
index dcb202a63b..6589bd4dc7 100644
--- a/sysdeps/microblaze/start.S
+++ b/sysdeps/microblaze/start.S
@@ -63,14 +63,14 @@ _start:
     mfs     r20,rpc
     addik   r20,r20,_GLOBAL_OFFSET_TABLE_+8
     lwi     r5,r20,main@GOT
-    lwi     r8,r20,__libc_csu_init@GOT
-    lwi     r9,r20,__libc_csu_fini@GOT
+    addk    r8,r0,r0		/* Used to be init.  */
+    addk    r9,r0,r0		/* Used to be fini.  */
     brid    __libc_start_main@PLT
     addk    r10,r0,r0
 #else
     addik   r5,r0,main
-    addik   r8,r0,__libc_csu_init
-    addik   r9,r0,__libc_csu_fini
+    addk    r8,r0,r0		/* Used to be init.  */
+    addk    r9,r0,r0		/* Used to be fini.  */
     brid    __libc_start_main
     addk    r10,r0,r0
 #endif