PowerPC64 TLS optimization fix
authorAlan Modra <amodra@gmail.com>
Wed, 22 Jan 2020 02:32:11 +0000 (13:02 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 22 Jan 2020 06:44:08 +0000 (17:14 +1030)
When linking with --no-tls-optimize the linker doesn't generate a call
or long branch stub to __tls_get_addr in some circumstances, giving:

relocation truncated to fit: R_PPC64_REL24 against symbol `__tls_get_addr'

* elf64-ppc.c (ppc64_elf_size_stubs): Correct condition under
which __tls_get_addr calls will be eliminated.

bfd/ChangeLog
bfd/elf64-ppc.c

index 45f2499735301dbf9edb01e003549991b2e90021..894faec848de7184e91388f22469d1171c7f3466 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-22  Alan Modra  <amodra@gmail.com>
+
+       * elf64-ppc.c (ppc64_elf_size_stubs): Correct condition under
+       which __tls_get_addr calls will be eliminated.
+
 2020-01-20  Nick Clifton  <nickc@redhat.com>
 
        * po/pt.po: Updates Portuguese translation.
index 3ae294b500dbd5e35120de23ef23bb3f16c7752f..2ee9fe404cb8b68e184eaab56a79934990234a44 100644 (file)
@@ -13083,7 +13083,8 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
                      if (!get_tls_mask (&tls_mask, NULL, NULL, &local_syms,
                                         irela - 1, input_bfd))
                        goto error_ret_free_internal;
-                     if ((*tls_mask & TLS_TLS) != 0)
+                     if ((*tls_mask & TLS_TLS) != 0
+                         && (*tls_mask & (TLS_GD | TLS_LD)) == 0)
                        continue;
                    }