gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / bfd / elf32-ppc.c
index d5c3ae9d0b78d53dc5e3239f13bfca0838a0ed0c..0cb7f67504d4d4f56a4272f37d65f4f604a0f12c 100644 (file)
@@ -1,5 +1,5 @@
 /* PowerPC-specific support for 32-bit ELF
-   Copyright (C) 1994-2019 Free Software Foundation, Inc.
+   Copyright (C) 1994-2020 Free Software Foundation, Inc.
    Written by Ian Lance Taylor, Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -37,6 +37,9 @@
 #include "dwarf2.h"
 #include "opcode/ppc.h"
 
+/* All users of this file have bfd_octets_per_byte (abfd, sec) == 1.  */
+#define OCTETS_PER_BYTE(ABFD, SEC) 1
+
 typedef enum split16_format_type
 {
   split16a_type = 0,
@@ -956,7 +959,7 @@ ppc_elf_addr16_ha_reloc (bfd *abfd,
            + input_section->output_section->vma);
   value >>= 16;
 
-  octets = reloc_entry->address * bfd_octets_per_byte (abfd);
+  octets = reloc_entry->address * OCTETS_PER_BYTE (abfd, input_section);
   insn = bfd_get_32 (abfd, (bfd_byte *) data + octets);
   insn &= ~0x1fffc1;
   insn |= (value & 0xffc1) | ((value & 0x3e) << 15);
@@ -1329,15 +1332,21 @@ ppc_elf_section_from_shdr (bfd *abfd,
     return FALSE;
 
   newsect = hdr->bfd_section;
-  flags = bfd_section_flags (newsect);
+  flags = 0;
   if (hdr->sh_flags & SHF_EXCLUDE)
     flags |= SEC_EXCLUDE;
 
   if (hdr->sh_type == SHT_ORDERED)
     flags |= SEC_SORT_ENTRIES;
 
-  bfd_set_section_flags (newsect, flags);
-  return TRUE;
+  if (strncmp (name, ".PPC.EMB", 8) == 0)
+    name += 8;
+  if (strncmp (name, ".sbss", 5) == 0
+      || strncmp (name, ".sdata", 6) == 0)
+    flags |= SEC_SMALL_DATA;
+
+  return (flags == 0
+         || bfd_set_section_flags (newsect, newsect->flags | flags));
 }
 
 /* Set up any other section flags and such that may be necessary.  */
@@ -1391,7 +1400,7 @@ ppc_elf_modify_segment_map (bfd *abfd,
   for (m = elf_seg_map (abfd); m != NULL; m = m->next)
     {
       struct elf_segment_map *n;
-      bfd_size_type amt;
+      size_t amt;
       unsigned int j, k;
       unsigned int p_flags;
 
@@ -1624,8 +1633,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info)
       apuinfo_set = TRUE;
       if (largest_input_size < asec->size)
        {
-         if (buffer)
-           free (buffer);
+         free (buffer);
          largest_input_size = asec->size;
          buffer = bfd_malloc (largest_input_size);
          if (!buffer)
@@ -1683,8 +1691,7 @@ ppc_elf_begin_write_processing (bfd *abfd, struct bfd_link_info *link_info)
     }
 
  fail:
-  if (buffer)
-    free (buffer);
+  free (buffer);
 
   if (error_message)
     _bfd_error_handler (error_message, APUINFO_SECTION_NAME, ibfd);
@@ -1799,7 +1806,7 @@ ppc_elf_get_synthetic_symtab (bfd *abfd, long symcount, asymbol **syms,
   bfd_vma stub_off;
   asymbol *s;
   arelent *p;
-  long count, i, stub_delta;
+  size_t count, i, stub_delta;
   size_t size;
   char *names;
   bfd_byte buf[4];
@@ -2109,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
@@ -2257,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;
     }
@@ -2531,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;
@@ -2555,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
@@ -2799,7 +2802,7 @@ update_plt_info (bfd *abfd, struct plt_entry **plist,
       break;
   if (ent == NULL)
     {
-      bfd_size_type amt = sizeof (*ent);
+      size_t amt = sizeof (*ent);
       ent = bfd_alloc (abfd, amt);
       if (ent == NULL)
        return FALSE;
@@ -3475,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)
                    {
@@ -3550,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];
@@ -3567,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)
        {
@@ -3577,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)
        {
@@ -3585,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)
        {
@@ -3593,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)
        {
@@ -3601,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;
@@ -3610,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)
        {
@@ -3620,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)
        {
@@ -3628,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)
        {
@@ -3636,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)
        {
@@ -3644,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;
        }
     }
 
@@ -3793,6 +3813,9 @@ ppc_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
   if (!ppc_elf_merge_obj_attributes (ibfd, info))
     return FALSE;
 
+  if ((ibfd->flags & DYNAMIC) != 0)
+    return TRUE;
+
   new_flags = elf_elfheader (ibfd)->e_flags;
   old_flags = elf_elfheader (obfd)->e_flags;
   if (!elf_flags_init (obfd))
@@ -4251,8 +4274,7 @@ ppc_elf_inline_plt (struct bfd_link_info *info)
                  {
                    if (elf_section_data (sec)->relocs != relstart)
                      free (relstart);
-                   if (local_syms != NULL
-                       && symtab_hdr->contents != (unsigned char *) local_syms)
+                   if (symtab_hdr->contents != (unsigned char *) local_syms)
                      free (local_syms);
                    return FALSE;
                  }
@@ -4530,8 +4552,11 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED,
                      else
                        continue;
 
-                   case R_PPC_TLSGD:
                    case R_PPC_TLSLD:
+                     if (!is_local)
+                       continue;
+                     /* Fall through.  */
+                   case R_PPC_TLSGD:
                      if (rel + 1 < relend
                          && is_plt_seq_reloc (ELF32_R_TYPE (rel[1].r_info)))
                        {
@@ -4633,7 +4658,7 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED,
                          != (TLS_TLS | TLS_MARK)))
                    continue;
 
-                 if (expecting_tls_get_addr)
+                 if (expecting_tls_get_addr == 1 + !sec->nomark_tls_get_addr)
                    {
                      struct plt_entry *ent;
                      bfd_vma addend = 0;
@@ -4646,10 +4671,9 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED,
                                          got2, addend);
                      if (ent != NULL && ent->plt.refcount > 0)
                        ent->plt.refcount -= 1;
-
-                     if (expecting_tls_get_addr == 2)
-                       continue;
                    }
+                 if (tls_clear == 0)
+                   continue;
 
                  if (tls_set == 0)
                    {
@@ -4670,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.  */
@@ -4697,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);
@@ -4712,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;
@@ -4756,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.  */
@@ -4802,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
@@ -4813,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.  */
@@ -4834,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;
     }
 
@@ -4930,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
@@ -5140,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
@@ -5172,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;
@@ -5187,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;
@@ -5196,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))
@@ -5221,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)
@@ -5416,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.  */
@@ -5893,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)
@@ -6637,8 +6618,7 @@ ppc_elf_relax_section (bfd *abfd,
       rel_hdr = _bfd_elf_single_rel_hdr (isec);
       rel_hdr->sh_size += changes * rel_hdr->sh_entsize;
     }
-  else if (internal_relocs != NULL
-          && elf_section_data (isec)->relocs != internal_relocs)
+  else if (elf_section_data (isec)->relocs != internal_relocs)
     free (internal_relocs);
 
   *again = changes != 0 || workaround_change;
@@ -6651,13 +6631,11 @@ ppc_elf_relax_section (bfd *abfd,
       branch_fixups = branch_fixups->next;
       free (f);
     }
-  if (isymbuf != NULL && (unsigned char *) isymbuf != symtab_hdr->contents)
+  if ((unsigned char *) isymbuf != symtab_hdr->contents)
     free (isymbuf);
-  if (contents != NULL
-      && elf_section_data (isec)->this_hdr.contents != contents)
+  if (elf_section_data (isec)->this_hdr.contents != contents)
     free (contents);
-  if (internal_relocs != NULL
-      && elf_section_data (isec)->relocs != internal_relocs)
+  if (elf_section_data (isec)->relocs != internal_relocs)
     free (internal_relocs);
   return FALSE;
 }
@@ -6838,7 +6816,7 @@ _bfd_elf_ppc_at_tls_transform (unsigned int insn, unsigned int reg)
 {
   unsigned int rtra;
 
-  if ((insn & (0x3f << 26)) != 31 << 26)
+  if ((insn & (0x3fu << 26)) != 31 << 26)
     return 0;
 
   if (reg == 0 || ((insn >> 11) & 0x1f) == reg)
@@ -6856,13 +6834,13 @@ _bfd_elf_ppc_at_tls_transform (unsigned int insn, unsigned int reg)
               || ((insn & (0x1f << 6)) >= 16 << 6
                   && (insn & (0x1f << 6)) < 24 << 6)))
     /* load and store indexed -> dform.  */
-    insn = (32 | ((insn >> 6) & 0x1f)) << 26;
+    insn = (32u | ((insn >> 6) & 0x1f)) << 26;
   else if ((insn & (((0x1a << 5) | 0x1f) << 1)) == 21 << 1)
     /* ldx, ldux, stdx, stdux -> ld, ldu, std, stdu.  */
-    insn = ((58 | ((insn >> 6) & 4)) << 26) | ((insn >> 6) & 1);
+    insn = ((58u | ((insn >> 6) & 4)) << 26) | ((insn >> 6) & 1);
   else if ((insn & (((0x1f << 5) | 0x1f) << 1)) == 341 << 1)
     /* lwax -> lwa.  */
-    insn = (58 << 26) | 2;
+    insn = (58u << 26) | 2;
   else
     return 0;
   insn |= rtra;
@@ -6877,36 +6855,36 @@ unsigned int
 _bfd_elf_ppc_at_tprel_transform (unsigned int insn, unsigned int reg)
 {
   if ((insn & (0x1f << 16)) == reg << 16
-      && ((insn & (0x3f << 26)) == 14u << 26 /* addi */
-         || (insn & (0x3f << 26)) == 15u << 26 /* addis */
-         || (insn & (0x3f << 26)) == 32u << 26 /* lwz */
-         || (insn & (0x3f << 26)) == 34u << 26 /* lbz */
-         || (insn & (0x3f << 26)) == 36u << 26 /* stw */
-         || (insn & (0x3f << 26)) == 38u << 26 /* stb */
-         || (insn & (0x3f << 26)) == 40u << 26 /* lhz */
-         || (insn & (0x3f << 26)) == 42u << 26 /* lha */
-         || (insn & (0x3f << 26)) == 44u << 26 /* sth */
-         || (insn & (0x3f << 26)) == 46u << 26 /* lmw */
-         || (insn & (0x3f << 26)) == 47u << 26 /* stmw */
-         || (insn & (0x3f << 26)) == 48u << 26 /* lfs */
-         || (insn & (0x3f << 26)) == 50u << 26 /* lfd */
-         || (insn & (0x3f << 26)) == 52u << 26 /* stfs */
-         || (insn & (0x3f << 26)) == 54u << 26 /* stfd */
-         || ((insn & (0x3f << 26)) == 58u << 26 /* lwa,ld,lmd */
+      && ((insn & (0x3fu << 26)) == 14u << 26 /* addi */
+         || (insn & (0x3fu << 26)) == 15u << 26 /* addis */
+         || (insn & (0x3fu << 26)) == 32u << 26 /* lwz */
+         || (insn & (0x3fu << 26)) == 34u << 26 /* lbz */
+         || (insn & (0x3fu << 26)) == 36u << 26 /* stw */
+         || (insn & (0x3fu << 26)) == 38u << 26 /* stb */
+         || (insn & (0x3fu << 26)) == 40u << 26 /* lhz */
+         || (insn & (0x3fu << 26)) == 42u << 26 /* lha */
+         || (insn & (0x3fu << 26)) == 44u << 26 /* sth */
+         || (insn & (0x3fu << 26)) == 46u << 26 /* lmw */
+         || (insn & (0x3fu << 26)) == 47u << 26 /* stmw */
+         || (insn & (0x3fu << 26)) == 48u << 26 /* lfs */
+         || (insn & (0x3fu << 26)) == 50u << 26 /* lfd */
+         || (insn & (0x3fu << 26)) == 52u << 26 /* stfs */
+         || (insn & (0x3fu << 26)) == 54u << 26 /* stfd */
+         || ((insn & (0x3fu << 26)) == 58u << 26 /* lwa,ld,lmd */
              && (insn & 3) != 1)
-         || ((insn & (0x3f << 26)) == 62u << 26 /* std, stmd */
+         || ((insn & (0x3fu << 26)) == 62u << 26 /* std, stmd */
              && ((insn & 3) == 0 || (insn & 3) == 3))))
     {
       insn &= ~(0x1f << 16);
     }
   else if ((insn & (0x1f << 21)) == reg << 21
-          && ((insn & (0x3e << 26)) == 24u << 26 /* ori, oris */
-              || (insn & (0x3e << 26)) == 26u << 26 /* xori,xoris */
-              || (insn & (0x3e << 26)) == 28u << 26 /* andi,andis */))
+          && ((insn & (0x3eu << 26)) == 24u << 26 /* ori, oris */
+              || (insn & (0x3eu << 26)) == 26u << 26 /* xori,xoris */
+              || (insn & (0x3eu << 26)) == 28u << 26 /* andi,andis */))
     {
       insn &= ~(0x1f << 21);
       insn |= (insn & (0x1f << 16)) << 5;
-      if ((insn & (0x3e << 26)) == 26 << 26 /* xori,xoris */)
+      if ((insn & (0x3eu << 26)) == 26u << 26 /* xori,xoris */)
        insn -= 2 >> 26;  /* convert to ori,oris */
     }
   else
@@ -6917,17 +6895,17 @@ _bfd_elf_ppc_at_tprel_transform (unsigned int insn, unsigned int reg)
 static bfd_boolean
 is_insn_ds_form (unsigned int insn)
 {
-  return ((insn & (0x3f << 26)) == 58u << 26 /* ld,ldu,lwa */
-         || (insn & (0x3f << 26)) == 62u << 26 /* std,stdu,stq */
-         || (insn & (0x3f << 26)) == 57u << 26 /* lfdp */
-         || (insn & (0x3f << 26)) == 61u << 26 /* stfdp */);
+  return ((insn & (0x3fu << 26)) == 58u << 26 /* ld,ldu,lwa */
+         || (insn & (0x3fu << 26)) == 62u << 26 /* std,stdu,stq */
+         || (insn & (0x3fu << 26)) == 57u << 26 /* lfdp */
+         || (insn & (0x3fu << 26)) == 61u << 26 /* stfdp */);
 }
 
 static bfd_boolean
 is_insn_dq_form (unsigned int insn)
 {
-  return ((insn & (0x3f << 26)) == 56u << 26 /* lq */
-         || ((insn & (0x3f << 26)) == (61u << 26) /* lxv, stxv */
+  return ((insn & (0x3fu << 26)) == 56u << 26 /* lq */
+         || ((insn & (0x3fu << 26)) == (61u << 26) /* lxv, stxv */
              && (insn & 3) == 1));
 }
 
@@ -7240,7 +7218,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
                {
                  /* IE */
                  insn1 &= (0x1f << 21) | (0x1f << 16);
-                 insn1 |= 32 << 26;    /* lwz */
+                 insn1 |= 32u << 26;   /* lwz */
                  if (offset != (bfd_vma) -1)
                    {
                      rel[1].r_info = ELF32_R_INFO (STN_UNDEF, R_PPC_NONE);
@@ -7409,7 +7387,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
 
            insn = bfd_get_32 (input_bfd,
                               contents + rel->r_offset - d_offset);
-           if ((insn & (0x3f << 26)) == 15u << 26
+           if ((insn & (0x3fu << 26)) == 15u << 26
                && (insn & (0x1f << 16)) != 0)
              {
                if (!bfd_link_pic (info))
@@ -7445,7 +7423,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
            {
              insn = bfd_get_32 (input_bfd,
                                 contents + rel->r_offset - d_offset);
-             if ((insn & (0x3f << 26)) == (15u << 26)
+             if ((insn & (0x3fu << 26)) == (15u << 26)
                  && (insn & (0x1f << 16)) == 0 /* lis */)
                {
                  bfd_byte *p;
@@ -7508,23 +7486,23 @@ ppc_elf_relocate_section (bfd *output_bfd,
            {
              insn = bfd_get_32 (input_bfd,
                                 contents + rel->r_offset - d_offset);
-             if ((insn & (0x3f << 26)) == 14u << 26    /* addi */
-                 || (insn & (0x3f << 26)) == 32u << 26 /* lwz */
-                 || (insn & (0x3f << 26)) == 34u << 26 /* lbz */
-                 || (insn & (0x3f << 26)) == 36u << 26 /* stw */
-                 || (insn & (0x3f << 26)) == 38u << 26 /* stb */
-                 || (insn & (0x3f << 26)) == 40u << 26 /* lhz */
-                 || (insn & (0x3f << 26)) == 42u << 26 /* lha */
-                 || (insn & (0x3f << 26)) == 44u << 26 /* sth */
-                 || (insn & (0x3f << 26)) == 46u << 26 /* lmw */
-                 || (insn & (0x3f << 26)) == 47u << 26 /* stmw */
-                 || (insn & (0x3f << 26)) == 48u << 26 /* lfs */
-                 || (insn & (0x3f << 26)) == 50u << 26 /* lfd */
-                 || (insn & (0x3f << 26)) == 52u << 26 /* stfs */
-                 || (insn & (0x3f << 26)) == 54u << 26 /* stfd */
-                 || ((insn & (0x3f << 26)) == 58u << 26 /* lwa,ld,lmd */
+             if ((insn & (0x3fu << 26)) == 14u << 26    /* addi */
+                 || (insn & (0x3fu << 26)) == 32u << 26 /* lwz */
+                 || (insn & (0x3fu << 26)) == 34u << 26 /* lbz */
+                 || (insn & (0x3fu << 26)) == 36u << 26 /* stw */
+                 || (insn & (0x3fu << 26)) == 38u << 26 /* stb */
+                 || (insn & (0x3fu << 26)) == 40u << 26 /* lhz */
+                 || (insn & (0x3fu << 26)) == 42u << 26 /* lha */
+                 || (insn & (0x3fu << 26)) == 44u << 26 /* sth */
+                 || (insn & (0x3fu << 26)) == 46u << 26 /* lmw */
+                 || (insn & (0x3fu << 26)) == 47u << 26 /* stmw */
+                 || (insn & (0x3fu << 26)) == 48u << 26 /* lfs */
+                 || (insn & (0x3fu << 26)) == 50u << 26 /* lfd */
+                 || (insn & (0x3fu << 26)) == 52u << 26 /* stfs */
+                 || (insn & (0x3fu << 26)) == 54u << 26 /* stfd */
+                 || ((insn & (0x3fu << 26)) == 58u << 26 /* lwa,ld,lmd */
                      && (insn & 3) != 1)
-                 || ((insn & (0x3f << 26)) == 62u << 26 /* std, stmd */
+                 || ((insn & (0x3fu << 26)) == 62u << 26 /* std, stmd */
                      && ((insn & 3) == 0 || (insn & 3) == 3)))
                {
                  /* Arrange to apply the reloc addend, if any.  */
@@ -7634,7 +7612,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
            {
              bfd_byte *p = contents + (rel->r_offset & ~3);
              unsigned int insn = bfd_get_32 (input_bfd, p);
-             if ((insn & ((0x3f << 26) | 0x1f << 16))
+             if ((insn & ((0x3fu << 26) | 0x1f << 16))
                  != ((15u << 26) | (2 << 16)) /* addis rt,2,imm */)
                /* xgettext:c-format */
                info->callbacks->minfo
@@ -8086,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;
@@ -8775,7 +8753,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
 
        case R_PPC_VLE_ADDR20:
          ppc_elf_vle_split20 (output_bfd, contents + rel->r_offset, relocation);
-         continue;
+         goto copy_reloc;
 
          /* Relocate against the beginning of the section.  */
        case R_PPC_SECTOFF:
@@ -8988,11 +8966,11 @@ ppc_elf_relocate_section (bfd *output_bfd,
              unsigned int insn;
 
              insn = bfd_get_32 (input_bfd, contents + (rel->r_offset & ~3));
-             if ((insn & (0x3f << 26)) == 10u << 26 /* cmpli */)
+             if ((insn & (0x3fu << 26)) == 10u << 26 /* cmpli */)
                complain = complain_overflow_bitfield;
-             else if ((insn & (0x3f << 26)) == 28u << 26 /* andi */
-                      || (insn & (0x3f << 26)) == 24u << 26 /* ori */
-                      || (insn & (0x3f << 26)) == 26u << 26 /* xori */)
+             else if ((insn & (0x3fu << 26)) == 28u << 26 /* andi */
+                      || (insn & (0x3fu << 26)) == 24u << 26 /* ori */
+                      || (insn & (0x3fu << 26)) == 26u << 26 /* xori */)
                complain = complain_overflow_unsigned;
            }
          if (howto->complain_on_overflow != complain)
@@ -9216,10 +9194,10 @@ ppc_elf_relocate_section (bfd *output_bfd,
             . new_page:                new_page:
             .  */
          insn = bfd_get_32 (input_bfd, contents + offset);
-         if ((insn & (0x3f << 26)) == (18u << 26)          /* b,bl,ba,bla */
-             || ((insn & (0x3f << 26)) == (16u << 26)      /* bc,bcl,bca,bcla*/
+         if ((insn & (0x3fu << 26)) == (18u << 26)         /* b,bl,ba,bla */
+             || ((insn & (0x3fu << 26)) == (16u << 26)     /* bc,bcl,bca,bcla*/
                  && (insn & (0x14 << 21)) == (0x14 << 21)) /*   with BO=0x14 */
-             || ((insn & (0x3f << 26)) == (19u << 26)
+             || ((insn & (0x3fu << 26)) == (19u << 26)
                  && (insn & (0x3ff << 1)) == (16u << 1)    /* bclr,bclrl */
                  && (insn & (0x14 << 21)) == (0x14 << 21)))/*   with BO=0x14 */
            continue;
@@ -9303,7 +9281,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
          else
            rel = NULL;
 
-         if ((insn & (0x3f << 26)) == (16u << 26) /* bc */
+         if ((insn & (0x3fu << 26)) == (16u << 26) /* bc */
              && (insn & 2) == 0 /* relative */)
            {
              bfd_vma delta = ((insn & 0xfffc) ^ 0x8000) - 0x8000;
@@ -9696,8 +9674,7 @@ ppc_finish_symbols (struct bfd_link_info *info)
                if (!get_sym_h (NULL, &sym, &sym_sec, NULL, &local_syms,
                                lplt - local_plt, ibfd))
                  {
-                   if (local_syms != NULL
-                       && symtab_hdr->contents != (unsigned char *) local_syms)
+                   if (symtab_hdr->contents != (unsigned char *) local_syms)
                      free (local_syms);
                    return FALSE;
                  }
@@ -10507,6 +10484,5 @@ ppc_elf_vxworks_final_write_processing (bfd *abfd)
 
 #undef elf32_bed
 #define elf32_bed                              ppc_elf_vxworks_bed
-#undef elf_backend_post_process_headers
 
 #include "elf32-target.h"
This page took 0.048395 seconds and 4 git commands to generate.