Copy several years of fixes from bfd/aoutx.h to bfd/pdp11.c.
[deliverable/binutils-gdb.git] / bfd / elfxx-x86.c
index 9679dca981e77923e7ad2c0bccd5bdb827cba6e5..035b5c5c64c4207018accb279d7957064336700c 100644 (file)
@@ -131,7 +131,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
   if (h->type == STT_GNU_IFUNC
       && h->def_regular)
     {
-      if (_bfd_elf_allocate_ifunc_dyn_relocs (info, h, &eh->dyn_relocs,
+      if (_bfd_elf_allocate_ifunc_dyn_relocs (info, h, &h->dyn_relocs,
                                              &htab->readonly_dynrelocs_against_ifunc,
                                              plt_entry_size,
                                              (htab->plt.has_plt0
@@ -375,7 +375,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
   else
     h->got.offset = (bfd_vma) -1;
 
-  if (eh->dyn_relocs == NULL)
+  if (h->dyn_relocs == NULL)
     return TRUE;
 
   /* In the shared -Bsymbolic case, discard space allocated for
@@ -396,7 +396,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
        {
          struct elf_dyn_relocs **pp;
 
-         for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+         for (pp = &h->dyn_relocs; (p = *pp) != NULL; )
            {
              p->count -= p->pc_count;
              p->pc_count = 0;
@@ -410,7 +410,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       if (htab->target_os == is_vxworks)
        {
          struct elf_dyn_relocs **pp;
-         for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+         for (pp = &h->dyn_relocs; (p = *pp) != NULL; )
            {
              if (strcmp (p->sec->output_section->name, ".tls_vars") == 0)
                *pp = p->next;
@@ -421,7 +421,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 
       /* Also discard relocs on undefined weak syms with non-default
         visibility or in PIE.  */
-      if (eh->dyn_relocs != NULL)
+      if (h->dyn_relocs != NULL)
        {
          if (h->root.type == bfd_link_hash_undefweak)
            {
@@ -437,7 +437,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
                         that we can branch to 0 without PLT.  */
                      struct elf_dyn_relocs **pp;
 
-                     for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+                     for (pp = &h->dyn_relocs; (p = *pp) != NULL; )
                        if (p->pc_count == 0)
                          *pp = p->next;
                        else
@@ -450,12 +450,12 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
                      /* Make sure undefined weak symbols are output
                         as dynamic symbols in PIEs for dynamic non-GOT
                         non-PLT reloations.  */
-                     if (eh->dyn_relocs != NULL
+                     if (h->dyn_relocs != NULL
                          && !bfd_elf_link_record_dynamic_symbol (info, h))
                        return FALSE;
                    }
                  else
-                   eh->dyn_relocs = NULL;
+                   h->dyn_relocs = NULL;
                }
              else if (h->dynindx == -1
                       && !h->forced_local
@@ -472,7 +472,7 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
                 which turn out to need copy relocs.  */
              struct elf_dyn_relocs **pp;
 
-             for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+             for (pp = &h->dyn_relocs; (p = *pp) != NULL; )
                {
                  if (p->pc_count != 0)
                    *pp = p->next;
@@ -513,13 +513,13 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
            goto keep;
        }
 
-      eh->dyn_relocs = NULL;
+      h->dyn_relocs = NULL;
 
     keep: ;
     }
 
   /* Finally, allocate space.  */
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
+  for (p = h->dyn_relocs; p != NULL; p = p->next)
     {
       asection *sreloc;
 
@@ -532,62 +532,6 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
   return TRUE;
 }
 
-/* Find dynamic relocs for H that apply to read-only sections.  */
-
-static asection *
-readonly_dynrelocs (struct elf_link_hash_entry *h)
-{
-  struct elf_dyn_relocs *p;
-
-  for (p = elf_x86_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
-    {
-      asection *s = p->sec->output_section;
-
-      if (s != NULL && (s->flags & SEC_READONLY) != 0)
-       return p->sec;
-    }
-  return NULL;
-}
-
-/* Set DF_TEXTREL if we find any dynamic relocs that apply to
-   read-only sections.  */
-
-static bfd_boolean
-maybe_set_textrel (struct elf_link_hash_entry *h, void *inf)
-{
-  asection *sec;
-
-  if (h->root.type == bfd_link_hash_indirect)
-    return TRUE;
-
-  /* Skip local IFUNC symbols. */
-  if (h->forced_local && h->type == STT_GNU_IFUNC)
-    return TRUE;
-
-  sec = readonly_dynrelocs (h);
-  if (sec != NULL)
-    {
-      struct bfd_link_info *info = (struct bfd_link_info *) inf;
-
-      info->flags |= DF_TEXTREL;
-      /* xgettext:c-format */
-      info->callbacks->minfo (_("%pB: dynamic relocation against `%pT' "
-                               "in read-only section `%pA'\n"),
-                             sec->owner, h->root.root.string, sec);
-
-      if ((info->warn_shared_textrel && bfd_link_pic (info))
-         || info->error_textrel)
-       /* xgettext:c-format */
-       info->callbacks->einfo (_("%P: %pB: warning: relocation against `%s' "
-                                 "in read-only section `%pA'\n"),
-                               sec->owner, h->root.root.string, sec);
-
-      /* Not an error, just cut short the traversal.  */
-      return FALSE;
-    }
-  return TRUE;
-}
-
 /* Allocate space in .plt, .got and associated reloc sections for
    local dynamic relocs.  */
 
@@ -1117,8 +1061,7 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd,
                      && (info->flags & DF_TEXTREL) == 0)
                    {
                      info->flags |= DF_TEXTREL;
-                     if ((info->warn_shared_textrel && bfd_link_pic (info))
-                         || info->error_textrel)
+                     if (bfd_link_textrel_check (info))
                        /* xgettext:c-format */
                        info->callbacks->einfo
                          (_("%P: %pB: warning: relocation "
@@ -1469,7 +1412,8 @@ _bfd_x86_elf_size_dynamic_sections (bfd *output_bfd,
          /* If any dynamic relocs apply to a read-only section,
             then we need a DT_TEXTREL entry.  */
          if ((info->flags & DF_TEXTREL) == 0)
-           elf_link_hash_traverse (&htab->elf, maybe_set_textrel, info);
+           elf_link_hash_traverse (&htab->elf,
+                                   _bfd_elf_maybe_set_textrel, info);
 
          if ((info->flags & DF_TEXTREL) != 0)
            {
@@ -1785,37 +1729,6 @@ _bfd_x86_elf_copy_indirect_symbol (struct bfd_link_info *info,
   edir = (struct elf_x86_link_hash_entry *) dir;
   eind = (struct elf_x86_link_hash_entry *) ind;
 
-  if (eind->dyn_relocs != NULL)
-    {
-      if (edir->dyn_relocs != NULL)
-       {
-         struct elf_dyn_relocs **pp;
-         struct elf_dyn_relocs *p;
-
-         /* Add reloc counts against the indirect sym to the direct sym
-            list.  Merge any entries against the same section.  */
-         for (pp = &eind->dyn_relocs; (p = *pp) != NULL; )
-           {
-             struct elf_dyn_relocs *q;
-
-             for (q = edir->dyn_relocs; q != NULL; q = q->next)
-               if (q->sec == p->sec)
-                 {
-                   q->pc_count += p->pc_count;
-                   q->count += p->count;
-                   *pp = p->next;
-                   break;
-                 }
-             if (q == NULL)
-               pp = &p->next;
-           }
-         *pp = edir->dyn_relocs;
-       }
-
-      edir->dyn_relocs = eind->dyn_relocs;
-      eind->dyn_relocs = NULL;
-    }
-
   if (ind->root.type == bfd_link_hash_indirect
       && dir->got.refcount <= 0)
     {
@@ -1952,7 +1865,7 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
          struct elf_dyn_relocs **pp;
 
          eh = (struct elf_x86_link_hash_entry *) h;
-         for (pp = &eh->dyn_relocs; (p = *pp) != NULL; )
+         for (pp = &h->dyn_relocs; (p = *pp) != NULL; )
            {
              pc_count += p->pc_count;
              p->count -= p->pc_count;
@@ -2080,7 +1993,7 @@ _bfd_x86_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
       /* If we don't find any dynamic relocs in read-only sections,
         then we'll be keeping the dynamic relocs and avoiding the copy
         reloc.  */
-      if (!readonly_dynrelocs (h))
+      if (!_bfd_elf_readonly_dynrelocs (h))
        {
          h->non_got_ref = 0;
          return TRUE;
This page took 0.029399 seconds and 4 git commands to generate.