about summary refs log tree commit diff
path: root/csu/Makefile
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 /csu/Makefile
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 'csu/Makefile')
-rw-r--r--csu/Makefile10
1 files changed, 1 insertions, 9 deletions
diff --git a/csu/Makefile b/csu/Makefile
index c9385df2e9..e587434be8 100644
--- a/csu/Makefile
+++ b/csu/Makefile
@@ -27,10 +27,9 @@ subdir := csu
 include ../Makeconfig
 
 routines = init-first libc-start $(libc-init) sysdep version check_fds \
-	   libc-tls elf-init dso_handle
+	   libc-tls dso_handle
 aux	 = errno
 elide-routines.os = libc-tls
-static-only-routines = elf-init
 csu-dummies = $(filter-out $(start-installed-name),crt1.o Mcrt1.o)
 extra-objs = start.o \
 	     $(start-installed-name) g$(start-installed-name) $(csu-dummies) \
@@ -59,13 +58,6 @@ CFLAGS-.os += $(no-stack-protector)
 # but it does not matter for this source file.
 CFLAGS-static-reloc.os += $(stack-protector)
 
-# This file is not actually part of the startup code in the nonshared
-# case and statically linked into applications.  See
-# <https://sourceware.org/bugzilla/show_bug.cgi?id=23323>,
-# <https://sourceware.org/ml/libc-alpha/2018-06/msg00717.html>.
-# Also see the note above regarding STACK_PROTECTOR_LEVEL.
-CFLAGS-elf-init.oS += $(stack-protector)
-
 ifeq (yes,$(build-shared))
 extra-objs += S$(start-installed-name) gmon-start.os
 ifneq ($(start-installed-name),$(static-start-installed-name))