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/hppa | |
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/hppa')
-rw-r--r-- | sysdeps/hppa/dl-lookupcfg.h | 2 | ||||
-rw-r--r-- | sysdeps/hppa/start.S | 26 |
2 files changed, 5 insertions, 23 deletions
diff --git a/sysdeps/hppa/dl-lookupcfg.h b/sysdeps/hppa/dl-lookupcfg.h index 29d994bfc2..a9a927f26c 100644 --- a/sysdeps/hppa/dl-lookupcfg.h +++ b/sysdeps/hppa/dl-lookupcfg.h @@ -56,7 +56,7 @@ void attribute_hidden _dl_unmap (struct link_map *map); { \ ElfW(Addr) addr; \ DL_DT_FUNCTION_ADDRESS(map, start, , addr) \ - init_t init = (init_t) addr; \ + dl_init_t init = (dl_init_t) addr; \ init (argc, argv, env); \ } diff --git a/sysdeps/hppa/start.S b/sysdeps/hppa/start.S index 2fe73c9aae..4a1877f8e8 100644 --- a/sysdeps/hppa/start.S +++ b/sysdeps/hppa/start.S @@ -36,8 +36,6 @@ .import main, code .import $global$, data .import __libc_start_main, code - .import __libc_csu_fini, code - .import __libc_csu_init, code /* Have the linker create plabel words so we get PLABEL32 relocs and not 21/14. The use of 21/14 relocs is only @@ -52,10 +50,6 @@ .word P%main .Lp__libc_start_main: .word P%__libc_start_main -.Lp__libc_csu_fini: - .word P%__libc_csu_fini -.Lp__libc_csu_init: - .word P%__libc_csu_init .text .align 4 @@ -77,8 +71,8 @@ _start: 1. r26 - Application main 2. r25 - argc 3. r24 - argv - 4. r23 - __libc_csu_init - 5. sp-52 - __libc_csu_fini + 4. r23 - init (unused) + 5. sp-52 - fini (unused) 6. sp-56 - rtld_fini 7. sp-60 - stackend */ @@ -108,14 +102,6 @@ _start: addil LT'.Lpmain, %r19 ldw RT'.Lpmain(%r1), %r26 ldw 0(%r26),%r26 - /* void (*init) (void) (4th argument) */ - addil LT'.Lp__libc_csu_init, %r19 - ldw RT'.Lp__libc_csu_init(%r1), %r23 - ldw 0(%r23), %r23 - /* void (*fini) (void) (5th argument) */ - addil LT'.Lp__libc_csu_fini, %r19 - ldw RT'.Lp__libc_csu_fini(%r1), %r22 - ldw 0(%r22), %r22 #else /* Load $global$ address into %dp */ ldil L%$global$, %dp @@ -124,13 +110,9 @@ _start: /* load main (1st argument) */ ldil LR'.Lpmain, %r26 ldw RR'.Lpmain(%r26), %r26 - /* void (*init) (void) (4th argument) */ - ldil LR'.Lp__libc_csu_init, %r23 - ldw RR'.Lp__libc_csu_init(%r23), %r23 - /* void (*fini) (void) (5th argument) */ - ldil LR'.Lp__libc_csu_fini, %r22 - ldw RR'.Lp__libc_csu_fini(%r22), %r22 #endif + ldi 0,%r23 /* Used to be init. */ + ldi 0,%r22 /* Used to be fini. */ /* Store 5th argument */ stw %r22, -52(%sp) /* void *stack_end (7th argument) */ |