gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / bfd / elf32-ppc.c
index a900abe35ef004709f5196d26452641a5a1e925e..0cb7f67504d4d4f56a4272f37d65f4f604a0f12c 100644 (file)
@@ -2116,9 +2116,6 @@ struct ppc_elf_link_hash_entry
      from the beginning of the section.  */
   elf_linker_section_pointers_t *linker_section_pointer;
 
-  /* Track dynamic relocs copied for this symbol.  */
-  struct elf_dyn_relocs *dyn_relocs;
-
   /* Contexts in which symbol is used in the GOT.
      Bits are or'd into the mask as the corresponding relocs are
      encountered during check_relocs, with TLS_TLS being set when any
@@ -2264,7 +2261,6 @@ ppc_elf_link_hash_newfunc (struct bfd_hash_entry *entry,
   if (entry != NULL)
     {
       ppc_elf_hash_entry (entry)->linker_section_pointer = NULL;
-      ppc_elf_hash_entry (entry)->dyn_relocs = NULL;
       ppc_elf_hash_entry (entry)->tls_mask = 0;
       ppc_elf_hash_entry (entry)->has_sda_refs = 0;
     }
@@ -2538,20 +2534,20 @@ ppc_elf_copy_indirect_symbol (struct bfd_link_info *info,
   if (eind->elf.root.type != bfd_link_hash_indirect)
     return;
 
-  if (eind->dyn_relocs != NULL)
+  if (ind->dyn_relocs != NULL)
     {
-      if (edir->dyn_relocs != NULL)
+      if (dir->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; )
+         for (pp = &ind->dyn_relocs; (p = *pp) != NULL; )
            {
              struct elf_dyn_relocs *q;
 
-             for (q = edir->dyn_relocs; q != NULL; q = q->next)
+             for (q = dir->dyn_relocs; q != NULL; q = q->next)
                if (q->sec == p->sec)
                  {
                    q->pc_count += p->pc_count;
@@ -2562,11 +2558,11 @@ ppc_elf_copy_indirect_symbol (struct bfd_link_info *info,
              if (q == NULL)
                pp = &p->next;
            }
-         *pp = edir->dyn_relocs;
+         *pp = dir->dyn_relocs;
        }
 
-      edir->dyn_relocs = eind->dyn_relocs;
-      eind->dyn_relocs = NULL;
+      dir->dyn_relocs = ind->dyn_relocs;
+      ind->dyn_relocs = NULL;
     }
 
   /* Copy over the GOT refcount entries that we may have already seen to
@@ -3482,7 +3478,7 @@ ppc_elf_check_relocs (bfd *abfd,
                  struct elf_dyn_relocs *p;
                  struct elf_dyn_relocs **rel_head;
 
-                 rel_head = &ppc_elf_hash_entry (h)->dyn_relocs;
+                 rel_head = &h->dyn_relocs;
                  p = *rel_head;
                  if (p == NULL || p->sec != sec)
                    {
@@ -3557,6 +3553,17 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
   obj_attribute *in_attr, *in_attrs;
   obj_attribute *out_attr, *out_attrs;
   bfd_boolean ret = TRUE;
+  bfd_boolean warn_only;
+
+  /* We only warn about shared library mismatches, because common
+     libraries advertise support for a particular long double variant
+     but actually support more than one variant.  For example, glibc
+     typically supports 128-bit IBM long double in the shared library
+     but has a compatibility static archive for 64-bit long double.
+     The linker doesn't have the smarts to see that an app using
+     object files marked as 64-bit long double call the compatibility
+     layer objects and only from there call into the shared library.  */
+  warn_only = (ibfd->flags & DYNAMIC) != 0;
 
   in_attrs = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
   out_attrs = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
@@ -3574,9 +3581,12 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
        ;
       else if (out_fp == 0)
        {
-         out_attr->type = ATTR_TYPE_FLAG_INT_VAL;
-         out_attr->i ^= in_fp;
-         last_fp = ibfd;
+         if (!warn_only)
+           {
+             out_attr->type = ATTR_TYPE_FLAG_INT_VAL;
+             out_attr->i ^= in_fp;
+             last_fp = ibfd;
+           }
        }
       else if (out_fp != 2 && in_fp == 2)
        {
@@ -3584,7 +3594,7 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
            /* xgettext:c-format */
            (_("%pB uses hard float, %pB uses soft float"),
             last_fp, ibfd);
-         ret = FALSE;
+         ret = warn_only;
        }
       else if (out_fp == 2 && in_fp != 2)
        {
@@ -3592,7 +3602,7 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
            /* xgettext:c-format */
            (_("%pB uses hard float, %pB uses soft float"),
             ibfd, last_fp);
-         ret = FALSE;
+         ret = warn_only;
        }
       else if (out_fp == 1 && in_fp == 3)
        {
@@ -3600,7 +3610,7 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
            /* xgettext:c-format */
            (_("%pB uses double-precision hard float, "
               "%pB uses single-precision hard float"), last_fp, ibfd);
-         ret = FALSE;
+         ret = warn_only;
        }
       else if (out_fp == 3 && in_fp == 1)
        {
@@ -3608,7 +3618,7 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
            /* xgettext:c-format */
            (_("%pB uses double-precision hard float, "
               "%pB uses single-precision hard float"), ibfd, last_fp);
-         ret = FALSE;
+         ret = warn_only;
        }
 
       in_fp = in_attr->i & 0xc;
@@ -3617,9 +3627,12 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
        ;
       else if (out_fp == 0)
        {
-         out_attr->type = ATTR_TYPE_FLAG_INT_VAL;
-         out_attr->i ^= in_fp;
-         last_ld = ibfd;
+         if (!warn_only)
+           {
+             out_attr->type = ATTR_TYPE_FLAG_INT_VAL;
+             out_attr->i ^= in_fp;
+             last_ld = ibfd;
+           }
        }
       else if (out_fp != 2 * 4 && in_fp == 2 * 4)
        {
@@ -3627,7 +3640,7 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
            /* xgettext:c-format */
            (_("%pB uses 64-bit long double, "
               "%pB uses 128-bit long double"), ibfd, last_ld);
-         ret = FALSE;
+         ret = warn_only;
        }
       else if (in_fp != 2 * 4 && out_fp == 2 * 4)
        {
@@ -3635,7 +3648,7 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
            /* xgettext:c-format */
            (_("%pB uses 64-bit long double, "
               "%pB uses 128-bit long double"), last_ld, ibfd);
-         ret = FALSE;
+         ret = warn_only;
        }
       else if (out_fp == 1 * 4 && in_fp == 3 * 4)
        {
@@ -3643,7 +3656,7 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
            /* xgettext:c-format */
            (_("%pB uses IBM long double, "
               "%pB uses IEEE long double"), last_ld, ibfd);
-         ret = FALSE;
+         ret = warn_only;
        }
       else if (out_fp == 3 * 4 && in_fp == 1 * 4)
        {
@@ -3651,7 +3664,7 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *ibfd, struct bfd_link_info *info)
            /* xgettext:c-format */
            (_("%pB uses IBM long double, "
               "%pB uses IEEE long double"), ibfd, last_ld);
-         ret = FALSE;
+         ret = warn_only;
        }
     }
 
@@ -4681,23 +4694,6 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED,
   return TRUE;
 }
 \f
-/* 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 = ppc_elf_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;
-}
-
 /* Return true if we have dynamic relocs against H or any of its weak
    aliases, that apply to read-only sections.  Cannot be used after
    size_dynamic_sections.  */
@@ -4708,7 +4704,7 @@ alias_readonly_dynrelocs (struct elf_link_hash_entry *h)
   struct ppc_elf_link_hash_entry *eh = ppc_elf_hash_entry (h);
   do
     {
-      if (readonly_dynrelocs (&eh->elf))
+      if (_bfd_elf_readonly_dynrelocs (&eh->elf))
        return TRUE;
       eh = ppc_elf_hash_entry (eh->elf.u.alias);
     } while (eh != NULL && &eh->elf != h);
@@ -4723,7 +4719,7 @@ pc_dynrelocs (struct elf_link_hash_entry *h)
 {
   struct elf_dyn_relocs *p;
 
-  for (p = ppc_elf_hash_entry (h)->dyn_relocs; p != NULL; p = p->next)
+  for (p = h->dyn_relocs; p != NULL; p = p->next)
     if (p->pc_count != 0)
       return TRUE;
   return FALSE;
@@ -4767,7 +4763,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
       /* Discard dyn_relocs when non-pic if we've decided that a
         function symbol is local.  */
       if (!bfd_link_pic (info) && local)
-       ppc_elf_hash_entry (h)->dyn_relocs = NULL;
+       h->dyn_relocs = NULL;
 
       /* Clear procedure linkage table information for any symbol that
         won't need a .plt entry.  */
@@ -4813,7 +4809,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
                   && !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)))
              && !htab->is_vxworks
              && !ppc_elf_hash_entry (h)->has_sda_refs
-             && !readonly_dynrelocs (h))
+             && !_bfd_elf_readonly_dynrelocs (h))
            {
              h->pointer_equality_needed = 0;
              /* If we haven't seen a branch reloc and the symbol
@@ -4824,7 +4820,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
          else if (!bfd_link_pic (info))
            /* We are going to be defining the function symbol on the
               plt stub, so no dyn_relocs needed when non-pic.  */
-           ppc_elf_hash_entry (h)->dyn_relocs = NULL;
+           h->dyn_relocs = NULL;
        }
       h->protected_def = 0;
       /* Function symbols can't have copy relocs.  */
@@ -4845,7 +4841,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
       if (def->root.u.def.section == htab->elf.sdynbss
          || def->root.u.def.section == htab->elf.sdynrelro
          || def->root.u.def.section == htab->dynsbss)
-       ppc_elf_hash_entry (h)->dyn_relocs = NULL;
+       h->dyn_relocs = NULL;
       return TRUE;
     }
 
@@ -4941,7 +4937,7 @@ ppc_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
     }
 
   /* We no longer want dyn_relocs.  */
-  ppc_elf_hash_entry (h)->dyn_relocs = NULL;
+  h->dyn_relocs = NULL;
   return _bfd_elf_adjust_dynamic_copy (info, h, s);
 }
 \f
@@ -5151,19 +5147,19 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
      IFUNCs which are handled even in static executables.  */
   if (!htab->elf.dynamic_sections_created
       && h->type != STT_GNU_IFUNC)
-    eh->dyn_relocs = NULL;
+    h->dyn_relocs = NULL;
 
   /* Discard relocs on undefined symbols that must be local.  */
   else if (h->root.type == bfd_link_hash_undefined
           && ELF_ST_VISIBILITY (h->other) != STV_DEFAULT)
-    eh->dyn_relocs = NULL;
+    h->dyn_relocs = NULL;
 
   /* Also discard relocs on undefined weak syms with non-default
      visibility, or when dynamic_undefined_weak says so.  */
   else if (UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
-    eh->dyn_relocs = NULL;
+    h->dyn_relocs = NULL;
 
-  if (eh->dyn_relocs == NULL)
+  if (h->dyn_relocs == NULL)
     ;
 
   /* In the shared -Bsymbolic case, discard space allocated for
@@ -5183,7 +5179,7 @@ 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;
@@ -5198,7 +5194,7 @@ 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; )
            {
              if (strcmp (p->sec->output_section->name, ".tls_vars") == 0)
                *pp = p->next;
@@ -5207,7 +5203,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
            }
        }
 
-      if (eh->dyn_relocs != NULL)
+      if (h->dyn_relocs != NULL)
        {
          /* Make sure this symbol is output as a dynamic symbol.  */
          if (!ensure_undef_dynamic (info, h))
@@ -5232,14 +5228,14 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
            return FALSE;
 
          if (h->dynindx == -1)
-           eh->dyn_relocs = NULL;
+           h->dyn_relocs = NULL;
        }
       else
-       eh->dyn_relocs = NULL;
+       h->dyn_relocs = NULL;
     }
 
   /* Allocate space.  */
-  for (p = eh->dyn_relocs; p != NULL; p = p->next)
+  for (p = h->dyn_relocs; p != NULL; p = p->next)
     {
       asection *sreloc = elf_section_data (p->sec)->sreloc;
       if (eh->elf.type == STT_GNU_IFUNC)
@@ -5427,33 +5423,6 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
   return TRUE;
 }
 
-/* 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 *info_p)
-{
-  asection *sec;
-
-  if (h->root.type == bfd_link_hash_indirect)
-    return TRUE;
-
-  sec = readonly_dynrelocs (h);
-  if (sec != NULL)
-    {
-      struct bfd_link_info *info = (struct bfd_link_info *) info_p;
-
-      info->flags |= DF_TEXTREL;
-      info->callbacks->minfo
-       (_("%pB: dynamic relocation against `%pT' 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;
-}
-
 static const unsigned char glink_eh_frame_cie[] =
 {
   0, 0, 0, 16,                         /* length.  */
@@ -5904,7 +5873,8 @@ ppc_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 (elf_hash_table (info), maybe_set_textrel,
+       elf_link_hash_traverse (elf_hash_table (info),
+                               _bfd_elf_maybe_set_textrel,
                                info);
 
       if ((info->flags & DF_TEXTREL) != 0)
@@ -8094,11 +8064,11 @@ ppc_elf_relocate_section (bfd *output_bfd,
 
          if (bfd_link_pic (info)
              ? ((h == NULL
-                 || ppc_elf_hash_entry (h)->dyn_relocs != NULL)
+                 || h->dyn_relocs != NULL)
                 && ((h != NULL && pc_dynrelocs (h))
                     || must_be_dyn_reloc (info, r_type)))
              : (h != NULL
-                && ppc_elf_hash_entry (h)->dyn_relocs != NULL))
+                && h->dyn_relocs != NULL))
            {
              int skip;
              bfd_byte *loc;
This page took 0.030149 seconds and 4 git commands to generate.