* [PATCH] powerpc: Fix ld.so address determination for PCREL mode (bug 31640)
@ 2024-04-13 14:15 Florian Weimer
2024-04-13 23:07 ` Peter Bergner
0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2024-04-13 14:15 UTC (permalink / raw)
To: libc-alpha; +Cc: Peter Bergner
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(+)
diff --git a/sysdeps/powerpc/powerpc64/dl-machine.h b/sysdeps/powerpc/powerpc64/dl-machine.h
index c6682f3445..2b6f5d2b08 100644
--- a/sysdeps/powerpc/powerpc64/dl-machine.h
+++ b/sysdeps/powerpc/powerpc64/dl-machine.h
@@ -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
base-commit: ae7468a7b0bcf22e9cd5fcae42bb9e4f65de83ee
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] powerpc: Fix ld.so address determination for PCREL mode (bug 31640)
2024-04-13 14:15 [PATCH] powerpc: Fix ld.so address determination for PCREL mode (bug 31640) Florian Weimer
@ 2024-04-13 23:07 ` Peter Bergner
0 siblings, 0 replies; 2+ messages in thread
From: Peter Bergner @ 2024-04-13 23:07 UTC (permalink / raw)
To: Florian Weimer, libc-alpha
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-04-13 23:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-13 14:15 [PATCH] powerpc: Fix ld.so address determination for PCREL mode (bug 31640) Florian Weimer
2024-04-13 23:07 ` Peter Bergner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).