+2020-09-28  Alan Modra  <amodra@gmail.com>
+
+       PR 26656
+       * elf64-ppc.c (ppc_build_one_stub, ppc_size_one_stub): Check for
+       NULL stub_entry->h before calling is_tls_get_addr.
+
 2020-09-26  Alan Modra  <amodra@gmail.com>
 
        * elf64-ppc.c (GLINK_PLTRESOLVE_SIZE): Depend on has_plt_localentry0.
 
       obfd = htab->params->stub_bfd;
       is_tga = ((stub_entry->stub_type == ppc_stub_plt_call_notoc
                 || stub_entry->stub_type == ppc_stub_plt_call_both)
+               && stub_entry->h != NULL
                && is_tls_get_addr (&stub_entry->h->elf, htab)
                && htab->params->tls_get_addr_opt);
       if (is_tga)
     case ppc_stub_plt_call_notoc:
     case ppc_stub_plt_call_both:
       lr_used = 0;
-      if (is_tls_get_addr (&stub_entry->h->elf, htab)
+      if (stub_entry->h != NULL
+         && is_tls_get_addr (&stub_entry->h->elf, htab)
          && htab->params->tls_get_addr_opt)
        {
          lr_used += 7 * 4;
        }
       if ((stub_entry->stub_type == ppc_stub_plt_call_notoc
           || stub_entry->stub_type == ppc_stub_plt_call_both)
+         && stub_entry->h != NULL
          && is_tls_get_addr (&stub_entry->h->elf, htab)
          && htab->params->tls_get_addr_opt)
        {