Fix potential address violation parsing a corrupt Alpha VMS file.
[binutils-gdb.git] / bfd / elfxx-mips.c
index 7a1d5f848bbbd15748b3a6de17d31b97a04188cd..830207ad6ae70ddbe414cea084acf2c40f17610d 100644 (file)
@@ -7028,7 +7028,7 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym)
    did so.  */
 
 unsigned int
-_bfd_mips_elf_eh_frame_address_size (bfd *abfd, asection *sec)
+_bfd_mips_elf_eh_frame_address_size (bfd *abfd, const asection *sec)
 {
   if (elf_elfheader (abfd)->e_ident[EI_CLASS] == ELFCLASS64)
     return 8;
@@ -7128,7 +7128,8 @@ _bfd_mips_elf_section_processing (bfd *abfd, Elf_Internal_Shdr *hdr)
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B: Warning: bad `%s' option size %u smaller than its header"),
+               (_("%B: Warning: bad `%s' option size %u smaller than"
+                  " its header"),
                abfd, MIPS_ELF_OPTIONS_SECTION_NAME (abfd), intopt.size);
              break;
            }
@@ -7362,7 +7363,8 @@ _bfd_mips_elf_section_from_shdr (bfd *abfd,
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B: Warning: bad `%s' option size %u smaller than its header"),
+               (_("%B: Warning: bad `%s' option size %u smaller than"
+                  " its header"),
                abfd, MIPS_ELF_OPTIONS_SECTION_NAME (abfd), intopt.size);
              break;
            }
@@ -8100,7 +8102,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
   extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
 
   bed = get_elf_backend_data (abfd);
-  rel_end = relocs + sec->reloc_count * bed->s->int_rels_per_ext_rel;
+  rel_end = relocs + sec->reloc_count;
 
   /* Check for the mips16 stub sections.  */
 
@@ -8391,7 +8393,7 @@ _bfd_mips_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;
            }
        }
 
@@ -8875,7 +8877,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
              howto = MIPS_ELF_RTYPE_TO_HOWTO (abfd, r_type, FALSE);
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"),
+               (_("%B: relocation %s against `%s' can not be used"
+                  " when making a shared object; recompile with -fPIC"),
                 abfd, howto->name,
                 (h) ? h->root.root.string : "a local symbol");
              bfd_set_error (bfd_error_bad_value);
@@ -10028,10 +10031,8 @@ _bfd_mips_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
   const Elf_Internal_Rela *relend;
   bfd_vma addend = 0;
   bfd_boolean use_saved_addend_p = FALSE;
-  const struct elf_backend_data *bed;
 
-  bed = get_elf_backend_data (output_bfd);
-  relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
+  relend = relocs + input_section->reloc_count;
   for (rel = relocs; rel < relend; ++rel)
     {
       const char *name;
@@ -10132,9 +10133,10 @@ _bfd_mips_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
                                                 sec);
                      _bfd_error_handler
                        /* xgettext:c-format */
-                       (_("%B: Can't find matching LO16 reloc against `%s' for %s at 0x%lx in section `%A'"),
-                        input_bfd, input_section, name, howto->name,
-                        rel->r_offset);
+                       (_("%B: Can't find matching LO16 reloc against `%s'"
+                          " for %s at 0x%lx in section `%A'"),
+                        input_bfd, name,
+                        howto->name, rel->r_offset, input_section);
                    }
                }
              else
@@ -10679,8 +10681,8 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd,
                       "beyond the range of ADDIUPC"),
                     output_bfd,
                     htab->root.sgotplt->output_section,
-                    htab->root.splt->output_section,
-                    (long) gotpc_offset);
+                    (long) gotpc_offset,
+                    htab->root.splt->output_section);
                  bfd_set_error (bfd_error_no_error);
                  return FALSE;
                }
@@ -11173,7 +11175,7 @@ _bfd_mips_vxworks_finish_dynamic_symbol (bfd *output_bfd,
                      + h->root.u.def.value);
       rel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_COPY);
       rel.r_addend = 0;
-      if ((h->root.u.def.section->flags & SEC_READONLY) != 0)
+      if (h->root.u.def.section == htab->root.sdynrelro)
        srel = htab->root.sreldynrelro;
       else
        srel = htab->root.srelbss;
@@ -11246,8 +11248,8 @@ mips_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info)
            (_("%B: `%A' offset of %ld from `%A' beyond the range of ADDIUPC"),
             output_bfd,
             htab->root.sgotplt->output_section,
-            htab->root.splt->output_section,
-            (long) gotpc_offset);
+            (long) gotpc_offset,
+            htab->root.splt->output_section);
          bfd_set_error (bfd_error_no_error);
          return FALSE;
        }
@@ -14267,11 +14269,11 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info)
     scRData, scSData, scSBss, scBss
   };
 
-  /* Sort the dynamic symbols so that those with GOT entries come after
-     those without.  */
   htab = mips_elf_hash_table (info);
   BFD_ASSERT (htab != NULL);
 
+  /* Sort the dynamic symbols so that those with GOT entries come after
+     those without.  */
   if (!mips_elf_sort_hash_table (abfd, info))
     return FALSE;
 
@@ -14684,8 +14686,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info)
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%s: illegal section name `%s'"),
-                bfd_get_filename (abfd), o->name);
+               (_("%B: illegal section name `%A'"), abfd, o);
              bfd_set_error (bfd_error_nonrepresentable_section);
              return FALSE;
            }
@@ -15197,19 +15198,19 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
            _bfd_error_handler
              (_("Warning: %B uses unknown floating point ABI %d "
                 "(set by %B), %B uses unknown floating point ABI %d"),
-              obfd, abi_fp_bfd, ibfd, out_fp, in_fp);
+              obfd, out_fp, abi_fp_bfd, ibfd, in_fp);
          else if (!out_string)
            _bfd_error_handler
              /* xgettext:c-format */
              (_("Warning: %B uses unknown floating point ABI %d "
                 "(set by %B), %B uses %s"),
-              obfd, abi_fp_bfd, ibfd, out_fp, in_string);
+              obfd, out_fp, abi_fp_bfd, ibfd, in_string);
          else if (!in_string)
            _bfd_error_handler
              /* xgettext:c-format */
              (_("Warning: %B uses %s (set by %B), "
                 "%B uses unknown floating point ABI %d"),
-              obfd, abi_fp_bfd, ibfd, out_string, in_fp);
+              obfd, out_string, abi_fp_bfd, ibfd, in_fp);
          else
            {
              /* If one of the bfds is soft-float, the other must be
@@ -15222,7 +15223,7 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
              _bfd_error_handler
                /* xgettext:c-format */
                (_("Warning: %B uses %s (set by %B), %B uses %s"),
-                obfd, abi_fp_bfd, ibfd, out_string, in_string);
+                obfd, out_string, abi_fp_bfd, ibfd, in_string);
            }
        }
     }
@@ -15242,8 +15243,8 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
              /* xgettext:c-format */
              (_("Warning: %B uses %s (set by %B), "
                 "%B uses unknown MSA ABI %d"),
-              obfd, abi_msa_bfd, ibfd,
-              "-mmsa", in_attr[Tag_GNU_MIPS_ABI_MSA].i);
+              obfd, "-mmsa", abi_msa_bfd,
+              ibfd, in_attr[Tag_GNU_MIPS_ABI_MSA].i);
            break;
 
          default:
@@ -15254,8 +15255,8 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
                  /* xgettext:c-format */
                  (_("Warning: %B uses unknown MSA ABI %d "
                     "(set by %B), %B uses %s"),
-                    obfd, abi_msa_bfd, ibfd,
-                    out_attr[Tag_GNU_MIPS_ABI_MSA].i, "-mmsa");
+                    obfd, out_attr[Tag_GNU_MIPS_ABI_MSA].i,
+                  abi_msa_bfd, ibfd, "-mmsa");
                  break;
 
              default:
@@ -15263,9 +15264,8 @@ mips_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
                  /* xgettext:c-format */
                  (_("Warning: %B uses unknown MSA ABI %d "
                     "(set by %B), %B uses unknown MSA ABI %d"),
-                  obfd, abi_msa_bfd, ibfd,
-                  out_attr[Tag_GNU_MIPS_ABI_MSA].i,
-                  in_attr[Tag_GNU_MIPS_ABI_MSA].i);
+                  obfd, out_attr[Tag_GNU_MIPS_ABI_MSA].i,
+                  abi_msa_bfd, ibfd, in_attr[Tag_GNU_MIPS_ABI_MSA].i);
                break;
              }
          }
@@ -15646,6 +15646,8 @@ print_mips_ases (FILE *file, unsigned int mask)
     fputs ("\n\tMICROMIPS ASE", file);
   if (mask & AFL_ASE_XPA)
     fputs ("\n\tXPA ASE", file);
+  if (mask & AFL_ASE_MIPS16E2)
+    fputs ("\n\tMIPS16e2 ASE", file);
   if (mask == 0)
     fprintf (file, "\n\t%s", _("None"));
   else if ((mask & ~AFL_ASE_MASK) != 0)