PPC: undefweak dynamic relocs
authorAlan Modra <amodra@gmail.com>
Mon, 3 May 2021 02:58:46 +0000 (12:28 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 3 May 2021 06:04:17 +0000 (15:34 +0930)
This makes the default for ppc to keep dynamic relocs on undefweak
symbols when the code won't cause DT_TEXTREL (for instance when -fPIE
or -fPIC).  If ld is given -z dynamic-undefined-weak then dynamic
relocations will be created for non-PIC at the expense of possibly
causing DT_TEXTREL to be set on ppc32.  Note that DT_TEXTREL and GNU
indirect functions are incompatible.

* elf32-ppc.c (allocate_dynrelocs): Keep dyn_relocs for undefweak
symbols when -z dynamic-undefined-weak or when there are no
dynamic relocs in read-only sections and -z nodynamic-undefined-weak
is not given.
* elf64-ppc.c (allocate_dynrelocs): Likewise.

bfd/ChangeLog
bfd/elf32-ppc.c
bfd/elf64-ppc.c

index 293fd993d8965d82f3809581f8f9c17f69393d1e..cdcf5d7616748e9c5c0a3c8855f5d0d2b0186a77 100644 (file)
@@ -1,3 +1,11 @@
+2021-05-03  Alan Modra  <amodra@gmail.com>
+
+       * elf32-ppc.c (allocate_dynrelocs): Keep dyn_relocs for undefweak
+       symbols when -z dynamic-undefined-weak or when there are no
+       dynamic relocs in read-only sections and -z nodynamic-undefined-weak
+       is not given.
+       * elf64-ppc.c (allocate_dynrelocs): Likewise.
+
 2021-05-03  Alan Modra  <amodra@gmail.com>
 
        * elf32-ppc.c (allocate_dynrelocs): Call ensure_undef_dynamic for
index ff618e460a4ca693a1a90b535ee35fa2b6f627c1..34a6b3fd837cc82dd27fe5da3ce76a8852f6aad3 100644 (file)
@@ -5245,7 +5245,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       /* For the non-pic case, discard space for relocs against
         symbols which turn out to need copy relocs or are not
         dynamic.  */
-      if (h->dynamic_adjusted
+      if ((h->dynamic_adjusted
+          || (h->ref_regular
+              && h->root.type == bfd_link_hash_undefweak
+              && (info->dynamic_undefined_weak > 0
+                  || !_bfd_elf_readonly_dynrelocs (h))))
          && !h->def_regular
          && !ELF_COMMON_DEF_P (h)
          && !(h->protected_def
index bc960bf8e9d371955d80689d121eb638d959e6f2..a4a05302a6ad17d1a8f918dae34203903808c149 100644 (file)
@@ -9808,7 +9808,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
         relocs against symbols which are not dynamic.  */
       else if (h->type != STT_GNU_IFUNC)
        {
-         if (h->dynamic_adjusted
+         if ((h->dynamic_adjusted
+              || (h->ref_regular
+                  && h->root.type == bfd_link_hash_undefweak
+                  && (info->dynamic_undefined_weak > 0
+                      || !_bfd_elf_readonly_dynrelocs (h))))
              && !h->def_regular
              && !ELF_COMMON_DEF_P (h))
            {
This page took 0.033418 seconds and 4 git commands to generate.