PPC: ensure_undef_dynamic on weak undef only in plt
authorAlan Modra <amodra@gmail.com>
Mon, 3 May 2021 00:33:06 +0000 (10:03 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 3 May 2021 06:04:17 +0000 (15:34 +0930)
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
bfd/elf32-ppc.c
bfd/elf64-ppc.c

index fc7a1b89772ecfa224313af4cbac81d4560b92f2..293fd993d8965d82f3809581f8f9c17f69393d1e 100644 (file)
@@ -1,3 +1,9 @@
+2021-05-03  Alan Modra  <amodra@gmail.com>
+
+       * 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.
+
 2021-05-03  Alan Modra  <amodra@gmail.com>
 
        PR 27755
index 830c9200b0cc3b32152264ff9f30c8ce461bc6ca..ff618e460a4ca693a1a90b535ee35fa2b6f627c1 100644 (file)
@@ -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;
-           bool dyn = !use_local_plt (info, h);
+           asection *s;
+           bool 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)
index ed72de27507f835bc789c01cffffccf7e1f32b9e..bc960bf8e9d371955d80689d121eb638d959e6f2 100644 (file)
@@ -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)
This page took 0.036687 seconds and 4 git commands to generate.