diff options
author | Florian Weimer <fweimer@redhat.com> | 2021-02-25 12:10:57 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2021-02-25 12:13:02 +0100 |
commit | 035c012e32c11e84d64905efaf55e74f704d3668 (patch) | |
tree | 7b08a9e9cbd8e4dd2e420cd6b7c204aeb5d61ccc /sysdeps/sparc | |
parent | a79328c745219dcb395070cdcd3be065a8347f24 (diff) | |
download | glibc-035c012e32c11e84d64905efaf55e74f704d3668.tar glibc-035c012e32c11e84d64905efaf55e74f704d3668.tar.gz glibc-035c012e32c11e84d64905efaf55e74f704d3668.tar.bz2 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/sparc')
-rw-r--r-- | sysdeps/sparc/sparc32/start.S | 12 | ||||
-rw-r--r-- | sysdeps/sparc/sparc64/start.S | 12 |
2 files changed, 4 insertions, 20 deletions
diff --git a/sysdeps/sparc/sparc32/start.S b/sysdeps/sparc/sparc32/start.S index 45ca77da3e..00bf898fb9 100644 --- a/sysdeps/sparc/sparc32/start.S +++ b/sysdeps/sparc/sparc32/start.S @@ -59,22 +59,14 @@ _start: /* Load the addresses of the user entry points. */ #ifndef PIC sethi %hi(main), %o0 - sethi %hi(__libc_csu_init), %o3 - sethi %hi(__libc_csu_fini), %o4 or %o0, %lo(main), %o0 - or %o3, %lo(__libc_csu_init), %o3 - or %o4, %lo(__libc_csu_fini), %o4 #else sethi %gdop_hix22(main), %o0 - sethi %gdop_hix22(__libc_csu_init), %o3 - sethi %gdop_hix22(__libc_csu_fini), %o4 xor %o0, %gdop_lox10(main), %o0 - xor %o3, %gdop_lox10(__libc_csu_init), %o3 - xor %o4, %gdop_lox10(__libc_csu_fini), %o4 ld [%l7 + %o0], %o0, %gdop(main) - ld [%l7 + %o3], %o3, %gdop(__libc_csu_init) - ld [%l7 + %o4], %o4, %gdop(__libc_csu_fini) #endif + mov 0, %o3 /* Used to be init. */ + mov 0, %o4 /* Used to be fini. */ /* When starting a binary via the dynamic linker, %g1 contains the address of the shared library termination function, which will be diff --git a/sysdeps/sparc/sparc64/start.S b/sysdeps/sparc/sparc64/start.S index 210fbaff90..8520717eba 100644 --- a/sysdeps/sparc/sparc64/start.S +++ b/sysdeps/sparc/sparc64/start.S @@ -60,22 +60,14 @@ _start: /* Load the addresses of the user entry points. */ #ifndef PIC sethi %hi(main), %o0 - sethi %hi(__libc_csu_init), %o3 - sethi %hi(__libc_csu_fini), %o4 or %o0, %lo(main), %o0 - or %o3, %lo(__libc_csu_init), %o3 - or %o4, %lo(__libc_csu_fini), %o4 #else sethi %gdop_hix22(main), %o0 - sethi %gdop_hix22(__libc_csu_init), %o3 - sethi %gdop_hix22(__libc_csu_fini), %o4 xor %o0, %gdop_lox10(main), %o0 - xor %o3, %gdop_lox10(__libc_csu_init), %o3 - xor %o4, %gdop_lox10(__libc_csu_fini), %o4 ldx [%l7 + %o0], %o0, %gdop(main) - ldx [%l7 + %o3], %o3, %gdop(__libc_csu_init) - ldx [%l7 + %o4], %o4, %gdop(__libc_csu_fini) #endif + mov 0, %o3 /* Used to be init. */ + mov 0, %o4 /* Used to be fini. */ /* When starting a binary via the dynamic linker, %g1 contains the address of the shared library termination function, which will be |