Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf64-ppc.c
index a2cc373b9f29e19e981c9b598a0ae5ff9f0652aa..7f4f7b6b86f42d6a5ca501c3cc4eebcd3ae7570e 100644 (file)
@@ -3919,6 +3919,9 @@ struct map_stub
   /* Whether to emit a copy of register save/restore functions in this
      group.  */
   int needs_save_res;
+  /* The offset of the __tls_get_addr_opt plt stub bctrl in this group,
+     or -1u if no such stub with bctrl exists.  */
+  unsigned int tls_get_addr_opt_bctrl;
 };
 
 struct ppc_stub_hash_entry {
@@ -4010,6 +4013,10 @@ struct ppc_link_hash_entry
      with non-standard calling convention.  */
   unsigned int save_res:1;
 
+  /* Set if a duplicate symbol with non-zero localentry is detected,
+     even when the duplicate symbol does not provide a definition.  */
+  unsigned int non_zero_localentry:1;
+
   /* Contexts in which symbol is used in the GOT (or TOC).
      TLS_GD .. TLS_EXPLICIT bits are or'd into the mask as the
      corresponding relocs are encountered during check_relocs.
@@ -4118,6 +4125,9 @@ struct ppc_link_hash_table
   unsigned int local_ifunc_resolver:1;
   unsigned int maybe_local_ifunc_resolver:1;
 
+  /* Whether plt calls for ELFv2 localentry:0 funcs have been optimized.  */
+  unsigned int has_plt_localentry0:1;
+
   /* Incremented every time we size stubs.  */
   unsigned int stub_iteration;
 
@@ -5005,7 +5015,7 @@ ppc64_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
                                  bfd_boolean definition,
                                  bfd_boolean dynamic)
 {
-  if (definition && !dynamic)
+  if (definition && (!dynamic || !h->def_regular))
     h->other = ((isym->st_other & ~ELF_ST_VISIBILITY (-1))
                | ELF_ST_VISIBILITY (h->other));
 }
@@ -5015,7 +5025,7 @@ ppc64_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
 
 static bfd_boolean
 ppc64_elf_merge_symbol (struct elf_link_hash_entry *h,
-                       const Elf_Internal_Sym *isym ATTRIBUTE_UNUSED,
+                       const Elf_Internal_Sym *isym,
                        asection **psec ATTRIBUTE_UNUSED,
                        bfd_boolean newdef ATTRIBUTE_UNUSED,
                        bfd_boolean olddef ATTRIBUTE_UNUSED,
@@ -5023,6 +5033,8 @@ ppc64_elf_merge_symbol (struct elf_link_hash_entry *h,
                        const asection *oldsec ATTRIBUTE_UNUSED)
 {
   ((struct ppc_link_hash_entry *) h)->fake = 0;
+  if ((STO_PPC64_LOCAL_MASK & isym->st_other) != 0)
+    ((struct ppc_link_hash_entry *) h)->non_zero_localentry = 1;
   return TRUE;
 }
 
@@ -5118,7 +5130,7 @@ add_symbol_adjust (struct ppc_link_hash_entry *eh, struct bfd_link_info *info)
 
       /* Propagate reference flags from entry symbol to function
         descriptor symbol.  */
-      fdh->elf.root.non_ir_ref |= eh->elf.root.non_ir_ref;
+      fdh->elf.root.non_ir_ref_regular |= eh->elf.root.non_ir_ref_regular;
       fdh->elf.root.non_ir_ref_dynamic |= eh->elf.root.non_ir_ref_dynamic;
       fdh->elf.ref_regular |= eh->elf.ref_regular;
       fdh->elf.ref_regular_nonweak |= eh->elf.ref_regular_nonweak;
@@ -5423,9 +5435,9 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
          /* PR15323, ref flags aren't set for references in the same
             object.  */
-         h->root.non_ir_ref = 1;
+         h->root.non_ir_ref_regular = 1;
          if (eh->is_func && eh->oh != NULL)
-           eh->oh->elf.root.non_ir_ref = 1;
+           eh->oh->elf.root.non_ir_ref_regular = 1;
 
          if (h == htab->elf.hgot)
            sec->has_toc_reloc = 1;
@@ -6318,6 +6330,22 @@ ppc64_elf_maybe_function_sym (const asymbol *sym, asection *sec,
   return size;
 }
 
+/* Return true if symbol is a strong function defined in an ELFv2
+   object with st_other localentry bits of zero, ie. its local entry
+   point coincides with its global entry point.  */
+
+static bfd_boolean
+is_elfv2_localentry0 (struct elf_link_hash_entry *h)
+{
+  return (h != NULL
+         && h->type == STT_FUNC
+         && h->root.type == bfd_link_hash_defined
+         && (STO_PPC64_LOCAL_MASK & h->other) == 0
+         && !((struct ppc_link_hash_entry *) h)->non_zero_localentry
+         && is_ppc64_elf (h->root.u.def.section->owner)
+         && abiversion (h->root.u.def.section->owner) >= 2);
+}
+
 /* Return true if symbol is defined in a regular object file.  */
 
 static bfd_boolean
@@ -8328,6 +8356,29 @@ ppc64_elf_tls_setup (struct bfd_link_info *info)
   else if (!htab->do_multi_toc)
     htab->params->no_multi_toc = 1;
 
+  /* Default to --no-plt-localentry, as this option can cause problems
+     with symbol interposition.  For example, glibc libpthread.so and
+     libc.so duplicate many pthread symbols, with a fallback
+     implementation in libc.so.  In some cases the fallback does more
+     work than the pthread implementation.  __pthread_condattr_destroy
+     is one such symbol: the libpthread.so implementation is
+     localentry:0 while the libc.so implementation is localentry:8.
+     An app that "cleverly" uses dlopen to only load necessary
+     libraries at runtime may omit loading libpthread.so when not
+     running multi-threaded, which then results in the libc.so
+     fallback symbols being used and ld.so complaining.  Now there
+     are workarounds in ld (see non_zero_localentry) to detect the
+     pthread situation, but that may not be the only case where
+     --plt-localentry can cause trouble.  */
+  if (htab->params->plt_localentry0 < 0)
+    htab->params->plt_localentry0 = 0;
+  if (htab->params->plt_localentry0
+      && elf_link_hash_lookup (&htab->elf, "GLIBC_2.26",
+                              FALSE, FALSE, FALSE) == NULL)
+    info->callbacks->einfo
+      (_("%P: warning: --plt-localentry is especially dangerous without "
+        "ld.so support to detect ABI violations.\n"));
+
   htab->tls_get_addr = ((struct ppc_link_hash_entry *)
                        elf_link_hash_lookup (&htab->elf, ".__tls_get_addr",
                                              FALSE, FALSE, TRUE));
@@ -8881,7 +8932,7 @@ ppc64_elf_tls_optimize (struct bfd_link_info *info)
    the values of any global symbols in a toc section that has been
    edited.  Globals in toc sections should be a rarity, so this function
    sets a flag if any are found in toc sections other than the one just
-   edited, so that futher hash table traversals can be avoided.  */
+   edited, so that further hash table traversals can be avoided.  */
 
 struct adjust_toc_info
 {
@@ -9377,7 +9428,7 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
 
       /* Merge the used and skip arrays.  Assume that TOC
         doublewords not appearing as either used or unused belong
-        to to an entry more than one doubleword in size.  */
+        to an entry more than one doubleword in size.  */
       for (drop = skip, keep = used, last = 0, some_unused = 0;
           drop < skip + (toc->size + 7) / 8;
           ++drop, ++keep)
@@ -10548,7 +10599,12 @@ plt_stub_size (struct ppc_link_hash_table *htab,
       && (stub_entry->h == htab->tls_get_addr_fd
          || stub_entry->h == htab->tls_get_addr)
       && htab->params->tls_get_addr_opt)
-    size += 13 * 4;
+    {
+      size += 7 * 4;
+      if (ALWAYS_EMIT_R2SAVE
+         || stub_entry->stub_type == ppc_stub_plt_call_r2save)
+       size += 6 * 4;
+    }
   return size;
 }
 
@@ -10775,11 +10831,17 @@ build_tls_get_addr_stub (struct ppc_link_hash_table *htab,
   bfd_put_32 (obfd, ADD_R3_R12_R13, p),                p += 4;
   bfd_put_32 (obfd, BEQLR, p),                 p += 4;
   bfd_put_32 (obfd, MR_R3_R0, p),              p += 4;
+  if (r != NULL)
+    r[0].r_offset += 7 * 4;
+  if (!ALWAYS_EMIT_R2SAVE
+      && stub_entry->stub_type != ppc_stub_plt_call_r2save)
+    return build_plt_stub (htab, stub_entry, p, offset, r);
+
   bfd_put_32 (obfd, MFLR_R11, p),              p += 4;
   bfd_put_32 (obfd, STD_R11_0R1 + STK_LINKER (htab), p), p += 4;
 
   if (r != NULL)
-    r[0].r_offset += 9 * 4;
+    r[0].r_offset += 2 * 4;
   p = build_plt_stub (htab, stub_entry, p, offset, r);
   bfd_put_32 (obfd, BCTRL, p - 4);
 
@@ -11352,6 +11414,15 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
              - htab->sec_info[stub_entry->group->link_sec->id].toc_off);
 
       size = plt_stub_size (htab, stub_entry, off);
+      if (stub_entry->h != NULL
+         && (stub_entry->h == htab->tls_get_addr_fd
+             || stub_entry->h == htab->tls_get_addr)
+         && htab->params->tls_get_addr_opt
+         && (ALWAYS_EMIT_R2SAVE
+             || stub_entry->stub_type == ppc_stub_plt_call_r2save))
+       stub_entry->group->tls_get_addr_opt_bctrl
+         = stub_entry->group->stub_sec->size + size - 5 * 4;
+
       if (htab->params->plt_stub_align)
        size += plt_stub_pad (htab, stub_entry, off);
       if (info->emitrelocations)
@@ -12218,6 +12289,7 @@ group_sections (struct bfd_link_info *info,
          group->link_sec = curr;
          group->stub_sec = NULL;
          group->needs_save_res = 0;
+         group->tls_get_addr_opt_bctrl = -1u;
          group->next = htab->group;
          htab->group = group;
          do
@@ -12268,6 +12340,27 @@ static const unsigned char glink_eh_frame_cie[] =
   DW_CFA_def_cfa, 1, 0                 /* def_cfa: r1 offset 0.  */
 };
 
+static size_t
+stub_eh_frame_size (struct map_stub *group, size_t align)
+{
+  size_t this_size = 17;
+  if (group->tls_get_addr_opt_bctrl != -1u)
+    {
+      unsigned int to_bctrl = group->tls_get_addr_opt_bctrl / 4;
+      if (to_bctrl < 64)
+       this_size += 1;
+      else if (to_bctrl < 256)
+       this_size += 2;
+      else if (to_bctrl < 65536)
+       this_size += 3;
+      else
+       this_size += 5;
+      this_size += 6;
+    }
+  this_size = (this_size + align - 1) & -align;
+  return this_size;
+}
+
 /* Stripping output sections is normally done before dynamic section
    symbols have been allocated.  This function is called later, and
    handles cases like htab->brlt which is mapped to its own output
@@ -12370,7 +12463,6 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
       bfd *input_bfd;
       unsigned int bfd_indx;
       struct map_stub *group;
-      asection *stub_sec;
 
       htab->stub_iteration += 1;
 
@@ -12598,17 +12690,24 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
                        continue;
                    }
 
-                 if (stub_type == ppc_stub_plt_call
-                     && irela + 1 < irelaend
-                     && irela[1].r_offset == irela->r_offset + 4
-                     && ELF64_R_TYPE (irela[1].r_info) == R_PPC64_TOCSAVE)
+                 if (stub_type == ppc_stub_plt_call)
                    {
-                     if (!tocsave_find (htab, INSERT,
-                                        &local_syms, irela + 1, input_bfd))
-                       goto error_ret_free_internal;
+                     if (!htab->opd_abi
+                         && htab->params->plt_localentry0 != 0
+                         && is_elfv2_localentry0 (&hash->elf))
+                       htab->has_plt_localentry0 = 1;
+                     else if (irela + 1 < irelaend
+                              && irela[1].r_offset == irela->r_offset + 4
+                              && (ELF64_R_TYPE (irela[1].r_info)
+                                  == R_PPC64_TOCSAVE))
+                       {
+                         if (!tocsave_find (htab, INSERT,
+                                            &local_syms, irela + 1, input_bfd))
+                           goto error_ret_free_internal;
+                       }
+                     else
+                       stub_type = ppc_stub_plt_call_r2save;
                    }
-                 else if (stub_type == ppc_stub_plt_call)
-                   stub_type = ppc_stub_plt_call_r2save;
 
                  /* Support for grouping stub sections.  */
                  id_sec = htab->sec_info[section->id].u.group->link_sec;
@@ -12681,11 +12780,11 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
 
       /* We may have added some stubs.  Find out the new size of the
         stub sections.  */
-      for (stub_sec = htab->params->stub_bfd->sections;
-          stub_sec != NULL;
-          stub_sec = stub_sec->next)
-       if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
+      for (group = htab->group; group != NULL; group = group->next)
+       if (group->stub_sec != NULL)
          {
+           asection *stub_sec = group->stub_sec;
+
            if (htab->stub_iteration <= STUB_SHRINK_ITER
                || stub_sec->rawsize < stub_sec->size)
              /* Past STUB_SHRINK_ITER, rawsize is the max size seen.  */
@@ -12720,11 +12819,9 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
        {
          size_t size = 0, align = 4;
 
-         for (stub_sec = htab->params->stub_bfd->sections;
-              stub_sec != NULL;
-              stub_sec = stub_sec->next)
-           if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
-             size += (17 + align - 1) & -align;
+         for (group = htab->group; group != NULL; group = group->next)
+           if (group->stub_sec != NULL)
+             size += stub_eh_frame_size (group, align);
          if (htab->glink != NULL && htab->glink->size != 0)
            size += (24 + align - 1) & -align;
          if (size != 0)
@@ -12736,24 +12833,20 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
        }
 
       if (htab->params->plt_stub_align != 0)
-       for (stub_sec = htab->params->stub_bfd->sections;
-            stub_sec != NULL;
-            stub_sec = stub_sec->next)
-         if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
-           stub_sec->size = ((stub_sec->size
-                              + (1 << htab->params->plt_stub_align) - 1)
-                             & -(1 << htab->params->plt_stub_align));
-
-      for (stub_sec = htab->params->stub_bfd->sections;
-          stub_sec != NULL;
-          stub_sec = stub_sec->next)
-       if ((stub_sec->flags & SEC_LINKER_CREATED) == 0
-           && stub_sec->rawsize != stub_sec->size
+       for (group = htab->group; group != NULL; group = group->next)
+         if (group->stub_sec != NULL)
+           group->stub_sec->size = ((group->stub_sec->size
+                                     + (1 << htab->params->plt_stub_align) - 1)
+                                    & -(1 << htab->params->plt_stub_align));
+
+      for (group = htab->group; group != NULL; group = group->next)
+       if (group->stub_sec != NULL
+           && group->stub_sec->rawsize != group->stub_sec->size
            && (htab->stub_iteration <= STUB_SHRINK_ITER
-               || stub_sec->rawsize < stub_sec->size))
+               || group->stub_sec->rawsize < group->stub_sec->size))
          break;
 
-      if (stub_sec == NULL
+      if (group == NULL
          && (htab->glink_eh_frame == NULL
              || htab->glink_eh_frame->rawsize == htab->glink_eh_frame->size))
        break;
@@ -12768,7 +12861,7 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
       bfd_vma val;
       bfd_byte *p, *last_fde;
       size_t last_fde_len, size, align, pad;
-      asection *stub_sec;
+      struct map_stub *group;
 
       p = bfd_zalloc (htab->glink_eh_frame->owner, htab->glink_eh_frame->size);
       if (p == NULL)
@@ -12783,13 +12876,11 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
       bfd_put_32 (htab->elf.dynobj, last_fde_len, p);
       p += last_fde_len + 4;
 
-      for (stub_sec = htab->params->stub_bfd->sections;
-          stub_sec != NULL;
-          stub_sec = stub_sec->next)
-       if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
+      for (group = htab->group; group != NULL; group = group->next)
+       if (group->stub_sec != NULL)
          {
            last_fde = p;
-           last_fde_len = ((17 + align - 1) & -align) - 4;
+           last_fde_len = stub_eh_frame_size (group, align) - 4;
            /* FDE length.  */
            bfd_put_32 (htab->elf.dynobj, last_fde_len, p);
            p += 4;
@@ -12800,12 +12891,44 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
            /* Offset to stub section, written later.  */
            p += 4;
            /* stub section size.  */
-           bfd_put_32 (htab->elf.dynobj, stub_sec->size, p);
+           bfd_put_32 (htab->elf.dynobj, group->stub_sec->size, p);
            p += 4;
            /* Augmentation.  */
            p += 1;
+           if (group->tls_get_addr_opt_bctrl != -1u)
+             {
+               unsigned int to_bctrl = group->tls_get_addr_opt_bctrl / 4;
+
+               /* This FDE needs more than just the default.
+                  Describe __tls_get_addr_opt stub LR.  */
+               if (to_bctrl < 64)
+                 *p++ = DW_CFA_advance_loc + to_bctrl;
+               else if (to_bctrl < 256)
+                 {
+                   *p++ = DW_CFA_advance_loc1;
+                   *p++ = to_bctrl;
+                 }
+               else if (to_bctrl < 65536)
+                 {
+                   *p++ = DW_CFA_advance_loc2;
+                   bfd_put_16 (htab->elf.dynobj, to_bctrl, p);
+                   p += 2;
+                 }
+               else
+                 {
+                   *p++ = DW_CFA_advance_loc4;
+                   bfd_put_32 (htab->elf.dynobj, to_bctrl, p);
+                   p += 4;
+                 }
+               *p++ = DW_CFA_offset_extended_sf;
+               *p++ = 65;
+               *p++ = -(STK_LINKER (htab) / 8) & 0x7f;
+               *p++ = DW_CFA_advance_loc + 4;
+               *p++ = DW_CFA_restore_extended;
+               *p++ = 65;
+             }
            /* Pad.  */
-           p += ((17 + align - 1) & -align) - 17;
+           p = last_fde + last_fde_len + 4;
          }
       if (htab->glink != NULL && htab->glink->size != 0)
        {
@@ -12830,7 +12953,7 @@ ppc64_elf_size_stubs (struct bfd_link_info *info)
          *p++ = DW_CFA_register;
          *p++ = 65;
          *p++ = htab->opd_abi ? 12 : 0;
-         *p++ = DW_CFA_advance_loc + 4;
+         *p++ = DW_CFA_advance_loc + (htab->opd_abi ? 5 : 7);
          *p++ = DW_CFA_restore_extended;
          *p++ = 65;
          p += ((24 + align - 1) & -align) - 24;
@@ -13074,10 +13197,8 @@ ppc64_elf_build_stubs (struct bfd_link_info *info,
     return FALSE;
 
   /* Allocate memory to hold the linker stubs.  */
-  for (stub_sec = htab->params->stub_bfd->sections;
-       stub_sec != NULL;
-       stub_sec = stub_sec->next)
-    if ((stub_sec->flags & SEC_LINKER_CREATED) == 0
+  for (group = htab->group; group != NULL; group = group->next)
+    if ((stub_sec = group->stub_sec) != NULL
        && stub_sec->size != 0)
       {
        stub_sec->contents = bfd_zalloc (htab->params->stub_bfd, stub_sec->size);
@@ -13160,6 +13281,8 @@ ppc64_elf_build_stubs (struct bfd_link_info *info,
          p += 4;
          bfd_put_32 (htab->glink->owner, MFLR_R11, p);
          p += 4;
+         bfd_put_32 (htab->glink->owner, STD_R2_0R1 + 24, p);
+         p += 4;
          bfd_put_32 (htab->glink->owner, LD_R2_0R11 | (-16 & 0xfffc), p);
          p += 4;
          bfd_put_32 (htab->glink->owner, MTLR_R0, p);
@@ -13257,18 +13380,14 @@ ppc64_elf_build_stubs (struct bfd_link_info *info,
     htab->relbrlt->reloc_count = 0;
 
   if (htab->params->plt_stub_align != 0)
-    for (stub_sec = htab->params->stub_bfd->sections;
-        stub_sec != NULL;
-        stub_sec = stub_sec->next)
-      if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
+    for (group = htab->group; group != NULL; group = group->next)
+      if ((stub_sec = group->stub_sec) != NULL)
        stub_sec->size = ((stub_sec->size
                           + (1 << htab->params->plt_stub_align) - 1)
                          & -(1 << htab->params->plt_stub_align));
 
-  for (stub_sec = htab->params->stub_bfd->sections;
-       stub_sec != NULL;
-       stub_sec = stub_sec->next)
-    if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
+  for (group = htab->group; group != NULL; group = group->next)
+    if ((stub_sec = group->stub_sec) != NULL)
       {
        stub_sec_count += 1;
        if (stub_sec->rawsize != stub_sec->size
@@ -13280,7 +13399,7 @@ ppc64_elf_build_stubs (struct bfd_link_info *info,
   /* Note that the glink_eh_frame check here is not only testing that
      the generated size matched the calculated size but also that
      bfd_elf_discard_info didn't make any changes to the section.  */
-  if (stub_sec != NULL
+  if (group != NULL
       || (htab->glink_eh_frame != NULL
          && htab->glink_eh_frame->rawsize != htab->glink_eh_frame->size))
     {
@@ -14170,10 +14289,19 @@ ppc64_elf_relocate_section (bfd *output_bfd,
            {
              bfd_boolean can_plt_call = FALSE;
 
-             /* All of these stubs will modify r2, so there must be a
+             if (stub_entry->stub_type == ppc_stub_plt_call
+                 && !htab->opd_abi
+                 && htab->params->plt_localentry0 != 0
+                 && is_elfv2_localentry0 (&h->elf))
+               {
+                 /* The function doesn't use or change r2.  */
+                 can_plt_call = TRUE;
+               }
+
+             /* All of these stubs may modify r2, so there must be a
                 branch and link followed by a nop.  The nop is
                 replaced by an insn to restore r2.  */
-             if (rel->r_offset + 8 <= input_section->size)
+             else if (rel->r_offset + 8 <= input_section->size)
                {
                  unsigned long br;
 
@@ -14595,11 +14723,6 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                   emitting a reloc.  */
                else
                  {
-                   int tlsopt
-                     = (htab->params->tls_get_addr_opt
-                        && htab->tls_get_addr_fd != NULL
-                        && htab->tls_get_addr_fd->elf.plt.plist != NULL);
-
                    relocation += addend;
                    if (tls_type != 0)
                      {
@@ -14611,8 +14734,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                              relocation = 0;
                            else
                              relocation -= htab->elf.tls_sec->vma + DTP_OFFSET;
-                           if ((tls_type & TLS_TPREL)
-                               || (tlsopt && !(tls_type & TLS_DTPREL)))
+                           if (tls_type & TLS_TPREL)
                              relocation += DTP_OFFSET - TP_OFFSET;
                          }
 
@@ -14620,7 +14742,7 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                          {
                            bfd_put_64 (output_bfd, relocation,
                                        got->contents + off + 8);
-                           relocation = !tlsopt;
+                           relocation = 1;
                          }
                      }
                    bfd_put_64 (output_bfd, relocation,
@@ -15028,32 +15150,6 @@ ppc64_elf_relocate_section (bfd *output_bfd,
                    addend = outrel.r_offset;
                }
            }
-         else if (r_type == R_PPC64_DTPMOD64
-                  && htab->params->tls_get_addr_opt
-                  && htab->tls_get_addr_fd != NULL
-                  && htab->tls_get_addr_fd->elf.plt.plist != NULL)
-           {
-             /* Set up for __tls_get_addr_opt stub, when this entry
-                does not have dynamic relocs.  */
-             relocation = 0;
-             /* Set up the next word for local dynamic.  If it turns
-                out to be global dynamic, the reloc will overwrite
-                this value.  */
-             if (rel->r_offset + 16 <= input_section->size)
-               bfd_put_64 (input_bfd, DTP_OFFSET - TP_OFFSET,
-                           contents + rel->r_offset + 8);
-           }
-         else if (r_type == R_PPC64_DTPREL64
-                  && htab->params->tls_get_addr_opt
-                  && htab->tls_get_addr_fd != NULL
-                  && htab->tls_get_addr_fd->elf.plt.plist != NULL
-                  && rel > relocs
-                  && rel[-1].r_info == ELF64_R_INFO (r_symndx, R_PPC64_DTPMOD64)
-                  && rel[-1].r_offset + 8 == rel->r_offset)
-           {
-             /* __tls_get_addr_opt stub value.  */
-             addend += DTP_OFFSET - TP_OFFSET;
-           }
          break;
 
        case R_PPC64_COPY:
@@ -15636,6 +15732,8 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd,
            case DT_PPC64_OPT:
              if (htab->do_multi_toc && htab->multi_toc_needed)
                dyn.d_un.d_val |= PPC64_OPT_MULTI_TOC;
+             if (htab->has_plt_localentry0)
+               dyn.d_un.d_val |= PPC64_OPT_LOCALENTRY;
              break;
 
            case DT_PPC64_OPDSZ:
@@ -15721,55 +15819,40 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd,
     {
       bfd_vma val;
       bfd_byte *p;
-      asection *stub_sec;
+      struct map_stub *group;
       size_t align = 4;
 
       p = htab->glink_eh_frame->contents;
       p += (sizeof (glink_eh_frame_cie) + align - 1) & -align;
-      for (stub_sec = htab->params->stub_bfd->sections;
-          stub_sec != NULL;
-          stub_sec = stub_sec->next)
-       if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
+
+      for (group = htab->group; group != NULL; group = group->next)
+       if (group->stub_sec != NULL)
          {
-           /* FDE length.  */
-           p += 4;
-           /* CIE pointer.  */
-           p += 4;
            /* Offset to stub section.  */
-           val = (stub_sec->output_section->vma
-                  + stub_sec->output_offset);
+           val = (group->stub_sec->output_section->vma
+                  + group->stub_sec->output_offset);
            val -= (htab->glink_eh_frame->output_section->vma
                    + htab->glink_eh_frame->output_offset
-                   + (p - htab->glink_eh_frame->contents));
+                   + (p + 8 - htab->glink_eh_frame->contents));
            if (val + 0x80000000 > 0xffffffff)
              {
                info->callbacks->einfo
                  (_("%P: %s offset too large for .eh_frame sdata4 encoding"),
-                  stub_sec->name);
+                  group->stub_sec->name);
                return FALSE;
              }
-           bfd_put_32 (dynobj, val, p);
-           p += 4;
-           /* stub section size.  */
-           p += 4;
-           /* Augmentation.  */
-           p += 1;
-           /* Pad.  */
-           p += ((17 + align - 1) & -align) - 17;
+           bfd_put_32 (dynobj, val, p + 8);
+           p += stub_eh_frame_size (group, align);
          }
       if (htab->glink != NULL && htab->glink->size != 0)
        {
-         /* FDE length.  */
-         p += 4;
-         /* CIE pointer.  */
-         p += 4;
          /* Offset to .glink.  */
          val = (htab->glink->output_section->vma
                 + htab->glink->output_offset
                 + 8);
          val -= (htab->glink_eh_frame->output_section->vma
                  + htab->glink_eh_frame->output_offset
-                 + (p - htab->glink_eh_frame->contents));
+                 + (p + 8 - htab->glink_eh_frame->contents));
          if (val + 0x80000000 > 0xffffffff)
            {
              info->callbacks->einfo
@@ -15777,15 +15860,8 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd,
                 htab->glink->name);
              return FALSE;
            }
-         bfd_put_32 (dynobj, val, p);
-         p += 4;
-         /* .glink size.  */
-         p += 4;
-         /* Augmentation.  */
-         p += 1;
-         /* Ops.  */
-         p += 7;
-         p += ((24 + align - 1) & -align) - 24;
+         bfd_put_32 (dynobj, val, p + 8);
+         p += (24 + align - 1) & -align;
        }
 
       if (htab->glink_eh_frame->sec_info_type == SEC_INFO_TYPE_EH_FRAME
@@ -15845,4 +15921,3 @@ ppc64_elf_finish_dynamic_sections (bfd *output_bfd,
 #define elf64_bed      elf64_powerpc_fbsd_bed
 
 #include "elf64-target.h"
-
This page took 0.04232 seconds and 4 git commands to generate.