Update year range in copyright notice of all files.
[deliverable/binutils-gdb.git] / bfd / elf32-mcore.c
index 32ef86a870221b4fa2e01f4c9aa7f2d788a6e027..79c0da606ac7b75aeb8ed0241303cae09c7989ab 100644 (file)
@@ -1,6 +1,5 @@
 /* Motorola MCore specific support for 32-bit ELF
-   Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-   2007 Free Software Foundation, Inc.
+   Copyright (C) 1994-2017 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
@@ -50,13 +49,14 @@ mcore_elf_set_private_flags (bfd * abfd, flagword flags)
    object file when linking.  */
 
 static bfd_boolean
-mcore_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
+mcore_elf_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 {
+  bfd *obfd = info->output_bfd;
   flagword old_flags;
   flagword new_flags;
 
-  /* Check if we have the same endianess.  */
-  if (! _bfd_generic_verify_endian_match (ibfd, obfd))
+  /* Check if we have the same endianness.  */
+  if (! _bfd_generic_verify_endian_match (ibfd, info))
     return FALSE;
 
   if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
@@ -89,13 +89,14 @@ static bfd_reloc_status_type
 mcore_elf_unsupported_reloc (bfd * abfd,
                             arelent * reloc_entry,
                             asymbol * symbol ATTRIBUTE_UNUSED,
-                            PTR data ATTRIBUTE_UNUSED,
+                            void * data ATTRIBUTE_UNUSED,
                             asection * input_section ATTRIBUTE_UNUSED,
                             bfd * output_bfd ATTRIBUTE_UNUSED,
                             char ** error_message ATTRIBUTE_UNUSED)
 {
   BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
 
+  /* xgettext:c-format */
   _bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"),
                      abfd,
                      reloc_entry->howto->name,
@@ -111,11 +112,11 @@ static reloc_howto_type mcore_elf_howto_raw[] =
   /* This reloc does nothing.  */
   HOWTO (R_MCORE_NONE,         /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
-        32,                    /* bitsize */
+        3,                     /* size (0 = byte, 1 = short, 2 = long) */
+        0,                     /* bitsize */
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_bitfield,  /* complain_on_overflow */
+        complain_overflow_dont,  /* complain_on_overflow */
         NULL,                  /* special_function */
         "R_MCORE_NONE",        /* name */
         FALSE,                 /* partial_inplace */
@@ -341,13 +342,23 @@ mcore_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
                         arelent * cache_ptr,
                         Elf_Internal_Rela * dst)
 {
+  unsigned int r_type;
+
   if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4])
     /* Initialize howto table if needed.  */
     mcore_elf_howto_init ();
 
-  BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_MCORE_max);
+  r_type = ELF32_R_TYPE (dst->r_info);
+  if (r_type >= R_MCORE_max)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%B: unrecognised MCore reloc number: %d"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      r_type = R_MCORE_NONE;
+    }
 
-  cache_ptr->howto = mcore_elf_howto_table [ELF32_R_TYPE (dst->r_info)];
+  cache_ptr->howto = mcore_elf_howto_table [r_type];
 }
 \f
 /* The RELOCATE_SECTION function is called by the ELF backend linker
@@ -401,7 +412,7 @@ mcore_elf_relocate_section (bfd * output_bfd,
      input_bfd,
      input_section,
      (long) input_section->reloc_count,
-     (info->relocatable) ? " (relocatable)" : "");
+     (bfd_link_relocatable (info)) ? " (relocatable)" : "");
 #endif
 
   if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4])  /* Initialize howto table if needed */
@@ -425,6 +436,7 @@ mcore_elf_relocate_section (bfd * output_bfd,
       if ((unsigned) r_type >= (unsigned) R_MCORE_max
          || ! mcore_elf_howto_table [(int)r_type])
        {
+         /* xgettext:c-format */
          _bfd_error_handler (_("%B: Unknown relocation type %d\n"),
                              input_bfd, (int) r_type);
 
@@ -439,6 +451,7 @@ mcore_elf_relocate_section (bfd * output_bfd,
       /* Complain about known relocation that are not yet supported.  */
       if (howto->special_function == mcore_elf_unsupported_reloc)
        {
+         /* xgettext:c-format */
          _bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"),
                              input_bfd,
                              howto->name,
@@ -458,26 +471,19 @@ mcore_elf_relocate_section (bfd * output_bfd,
        }
       else
        {
-         bfd_boolean unresolved_reloc, warned;
+         bfd_boolean unresolved_reloc, warned, ignored;
 
          RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
                                   r_symndx, symtab_hdr, sym_hashes,
                                   h, sec, relocation,
-                                  unresolved_reloc, warned);
+                                  unresolved_reloc, warned, ignored);
        }
 
-      if (sec != NULL && elf_discarded_section (sec))
-       {
-         /* For relocs against symbols from removed linkonce sections,
-            or sections discarded by a linker script, we just want the
-            section contents zeroed.  Avoid any special processing.  */
-         _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-         rel->r_info = 0;
-         rel->r_addend = 0;
-         continue;
-       }
+      if (sec != NULL && discarded_section (sec))
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, 1, relend, howto, 0, contents);
 
-      if (info->relocatable)
+      if (bfd_link_relocatable (info))
        continue;
 
       switch (r_type)
@@ -594,18 +600,14 @@ mcore_elf_check_relocs (bfd * abfd,
 {
   Elf_Internal_Shdr * symtab_hdr;
   struct elf_link_hash_entry ** sym_hashes;
-  struct elf_link_hash_entry ** sym_hashes_end;
   const Elf_Internal_Rela * rel;
   const Elf_Internal_Rela * rel_end;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
-  sym_hashes_end = sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym);
-  if (!elf_bad_symtab (abfd))
-    sym_hashes_end -= symtab_hdr->sh_info;
 
   rel_end = relocs + sec->reloc_count;
 
@@ -624,6 +626,10 @@ mcore_elf_check_relocs (bfd * abfd,
          while (h->root.type == bfd_link_hash_indirect
                 || h->root.type == bfd_link_hash_warning)
            h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+         /* PR15323, ref flags aren't set for references in the same
+            object.  */
+         h->root.non_ir_ref = 1;
        }
 
       switch (ELF32_R_TYPE (rel->r_info))
@@ -656,9 +662,9 @@ static const struct bfd_elf_special_section mcore_elf_special_sections[]=
   { NULL,                     0,  0, 0,            0 }
 };
 
-#define TARGET_BIG_SYM         bfd_elf32_mcore_big_vec
+#define TARGET_BIG_SYM         mcore_elf32_be_vec
 #define TARGET_BIG_NAME                "elf32-mcore-big"
-#define TARGET_LITTLE_SYM       bfd_elf32_mcore_little_vec
+#define TARGET_LITTLE_SYM       mcore_elf32_le_vec
 #define TARGET_LITTLE_NAME      "elf32-mcore-little"
 
 #define ELF_ARCH               bfd_arch_mcore
This page took 0.028718 seconds and 4 git commands to generate.