diff options
author | Alan Modra <amodra@gmail.com> | 2022-01-24 07:58:18 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-04-10 08:33:40 +0930 |
commit | 31a9bc8c55adc2a8d6f8f795a577ba5d5eca7506 (patch) | |
tree | bc13ea619de5d93042bd2c1335af37a51e9c5baa /sysdeps/powerpc/powerpc64 | |
parent | d6efcc118e406a1cfeb309f835d7118df53419bb (diff) | |
download | glibc-31a9bc8c55adc2a8d6f8f795a577ba5d5eca7506.tar glibc-31a9bc8c55adc2a8d6f8f795a577ba5d5eca7506.tar.gz glibc-31a9bc8c55adc2a8d6f8f795a577ba5d5eca7506.tar.bz2 glibc-31a9bc8c55adc2a8d6f8f795a577ba5d5eca7506.zip |
powerpc64: Set up thread register for _dl_relocate_static_pie
libgcc ifunc resolvers that access hwcap via a field in the tcb can't
be called until the thread pointer is set up. Other ifunc resolvers
might need access to at_platform. This patch sets up a fake thread
pointer early to a copy of tcbhead_t. hwcapinfo.c already had local
variables for hwcap and at_platform, replace them with an entire
tcbhead_t. It's not that large and this way we easily ensure hwcap
and at_platform are at the same relative offsets as they are in the
real thread block.
The patch also conditionally disables part of tst-tlsifunc-static,
"bar address read from IFUNC resolver is incorrect". We can't get a
proper address for a thread variable before glibc initialises tls.
Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
Diffstat (limited to 'sysdeps/powerpc/powerpc64')
-rw-r--r-- | sysdeps/powerpc/powerpc64/dl-machine.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h index 6fab5cbe81..bb0ccd0811 100644 --- a/sysdeps/powerpc/powerpc64/dl-machine.h +++ b/sysdeps/powerpc/powerpc64/dl-machine.h @@ -559,6 +559,27 @@ elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc, #define ARCH_LA_PLTEXIT ppc64v2_gnu_pltexit #endif +#if ENABLE_STATIC_PIE && !defined SHARED && !IS_IN (rtld) +#include <libc-diag.h> +#include <tcb-offsets.h> + +/* Set up r13 for _dl_relocate_static_pie so that libgcc ifuncs that + normally access the tcb copy of hwcap will see __tcb.hwcap. */ + +static inline void __attribute__ ((always_inline)) +ppc_init_fake_thread_pointer (void) +{ + DIAG_PUSH_NEEDS_COMMENT; + /* We are playing pointer tricks. Silence gcc warning. */ + DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Warray-bounds"); + __thread_register = (char *) &__tcb.hwcap - TCB_HWCAP; + DIAG_POP_NEEDS_COMMENT; +} + +#define ELF_MACHINE_BEFORE_RTLD_RELOC(map, dynamic_info) \ + ppc_init_fake_thread_pointer (); +#endif /* ENABLE_STATIC_PIE && !defined SHARED && !IS_IN (rtld) */ + #endif /* dl_machine_h */ #ifdef RESOLVE_MAP |