powerpc: Fix ld.so address determination for PCREL mode (bug 31640)
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
This seems to have stopped working with some GCC 14 versions,
which clobber r2. With other compilers, the kernel-provided
r2 value is still available at this point.
---
sysdeps/powerpc/powerpc64/dl-machine.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
base-commit: ae7468a7b0bcf22e9cd5fcae42bb9e4f65de83ee
Comments
On 4/13/24 9:15 AM, Florian Weimer wrote:
> This seems to have stopped working with some GCC 14 versions,
> which clobber r2. With other compilers, the kernel-provided
> r2 value is still available at this point.
With PCREL, r2 is just another volatile/caller saved register.
That said, it wasn't until GCC commit 1bbb169fe6f9 where we
actually started using it. Thanks for finding and fixing this!
LGTM
Reviewed-by: Peter Bergner <bergner@linux.ibm.com>
Peter
@@ -78,6 +78,7 @@ elf_host_tolerates_class (const Elf64_Ehdr *ehdr)
static inline Elf64_Addr
elf_machine_load_address (void) __attribute__ ((const));
+#ifndef __PCREL__
static inline Elf64_Addr
elf_machine_load_address (void)
{
@@ -105,6 +106,24 @@ elf_machine_dynamic (void)
/* Then subtract off the load address offset. */
return runtime_dynamic - elf_machine_load_address() ;
}
+#else /* __PCREL__ */
+/* In PCREL mode, r2 may have been clobbered. Rely on relative
+ relocations instead. */
+
+static inline ElfW(Addr)
+elf_machine_load_address (void)
+{
+ extern const ElfW(Ehdr) __ehdr_start attribute_hidden;
+ return (ElfW(Addr)) &__ehdr_start;
+}
+
+static inline ElfW(Addr)
+elf_machine_dynamic (void)
+{
+ extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
+ return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
+}
+#endif /* __PCREL__ */
/* The PLT uses Elf64_Rela relocs. */
#define elf_machine_relplt elf_machine_rela