From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Cc: Peter Bergner <bergner@linux.ibm.com>
Subject: [PATCH] powerpc: Fix ld.so address determination for PCREL mode (bug 31640)
Date: Sat, 13 Apr 2024 16:15:41 +0200 [thread overview]
Message-ID: <87edb92vsi.fsf@oldenburg.str.redhat.com> (raw)
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
next reply other threads:[~2024-04-13 14:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-13 14:15 Florian Weimer [this message]
2024-04-13 23:07 ` [PATCH] powerpc: Fix ld.so address determination for PCREL mode (bug 31640) Peter Bergner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/libc/involved.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87edb92vsi.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=bergner@linux.ibm.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).