SHA256
1
0
forked from pool/binutils
binutils/ppc-ensure-undef-dynamic-weak-undefined.patch
Michael Matz dfa67a8b85 Accepting request 891347 from home:Andreas_Schwab:bison
- ppc-ensure-undef-dynamic-weak-undefined.patch: PPC: ensure_undef_dynamic
  on weak undef only in plt
- ppc-use-local-plt.patch: PowerPC use_local_plt (prerequisite for above
  patch)

OBS-URL: https://build.opensuse.org/request/show/891347
OBS-URL: https://build.opensuse.org/package/show/devel:gcc/binutils?expand=0&rev=361
2021-05-10 12:35:45 +00:00

63 lines
1.9 KiB
Diff

From b293661219c36e72acb80502a86b51160bb88cfd Mon Sep 17 00:00:00 2001
From: Alan Modra <amodra@gmail.com>
Date: Mon, 3 May 2021 10:03:06 +0930
Subject: [PATCH] PPC: ensure_undef_dynamic on weak undef only in plt
It's slightly weird to have a call to a weak function not protected by
a test of that function being non-NULL, but the non-NULL test might be
covered by a test of another function. For example:
if (func1)
{
func1 ();
func2 ();
}
where func2 is known to exist if func1 exists.
* elf32-ppc.c (allocate_dynrelocs): Call ensure_undef_dynamic for
weak undefined symols that only appear on PLT relocs.
* elf64-ppc.c (allocate_dynrelocs): Likewise.
---
bfd/ChangeLog | 6 ++++++
bfd/elf32-ppc.c | 9 +++++++--
bfd/elf64-ppc.c | 3 +++
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 830c9200b0c..ff618e460a4 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -5296,9 +5296,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
for (ent = h->plt.plist; ent != NULL; ent = ent->next)
if (ent->plt.refcount > 0)
{
- asection *s = htab->elf.splt;
- bfd_boolean dyn = !use_local_plt (info, h);
+ asection *s;
+ bfd_boolean dyn;
+ if (!ensure_undef_dynamic (info, h))
+ return FALSE;
+
+ dyn = !use_local_plt (info, h);
+ s = htab->elf.splt;
if (!dyn)
{
if (h->type == STT_GNU_IFUNC)
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index ed72de27507..bc960bf8e9d 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -9855,6 +9855,9 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
for (pent = h->plt.plist; pent != NULL; pent = pent->next)
if (pent->plt.refcount > 0)
{
+ if (!ensure_undef_dynamic (info, h))
+ return FALSE;
+
if (use_local_plt (info, h))
{
if (h->type == STT_GNU_IFUNC)
--
2.31.1