about summary refs log tree commit diff
path: root/sysdeps/aarch64
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/aarch64
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/aarch64')
-rw-r--r--sysdeps/aarch64/start.S14
1 files changed, 2 insertions, 12 deletions
diff --git a/sysdeps/aarch64/start.S b/sysdeps/aarch64/start.S
index 3761cbd7ee..417da8802b 100644
--- a/sysdeps/aarch64/start.S
+++ b/sysdeps/aarch64/start.S
@@ -63,26 +63,16 @@ ENTRY(_start)
 # ifdef SHARED
         adrp    x0, :got:main
 	ldr     PTR_REG (0), [x0, #:got_lo12:main]
-
-        adrp    x3, :got:__libc_csu_init
-	ldr     PTR_REG (3), [x3, #:got_lo12:__libc_csu_init]
-
-        adrp    x4, :got:__libc_csu_fini
-	ldr     PTR_REG (4), [x4, #:got_lo12:__libc_csu_fini]
 # else
 	adrp	x0, __wrap_main
 	add	x0, x0, :lo12:__wrap_main
-	adrp	x3, __libc_csu_init
-	add	x3, x3, :lo12:__libc_csu_init
-	adrp	x4, __libc_csu_fini
-	add	x4, x4, :lo12:__libc_csu_fini
 # endif
 #else
 	/* Set up the other arguments in registers */
 	MOVL (0, main)
-	MOVL (3, __libc_csu_init)
-	MOVL (4, __libc_csu_fini)
 #endif
+	mov	x3, #0		/* Used to be init.  */
+	mov	x4, #0		/* Used to be fini.  */
 
 	/* __libc_start_main (main, argc, argv, init, fini, rtld_fini,
 			      stack_end) */