Fix indentation (and clang warning) in c-lang.c
[deliverable/binutils-gdb.git] / bfd / elf32-xstormy16.c
index c5c88c79aa4b9d589da211bd2c477729fa898eac..ef106b3f928a441c2d8640d300cbd2899bba2a48 100644 (file)
@@ -1,12 +1,11 @@
 /* Xstormy16-specific support for 32-bit ELF.
 /* Xstormy16-specific support for 32-bit ELF.
-   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006
-   Free Software Foundation, Inc.
+   Copyright (C) 2000-2019 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 
    This file is part of BFD, the Binary File Descriptor library.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
-   USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
 
-#include "bfd.h"
 #include "sysdep.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/xstormy16.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/xstormy16.h"
@@ -74,11 +73,11 @@ static reloc_howto_type xstormy16_elf_howto_table [] =
   /* This reloc does nothing.  */
   HOWTO (R_XSTORMY16_NONE,     /* type */
         0,                     /* rightshift */
   /* This reloc does nothing.  */
   HOWTO (R_XSTORMY16_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 */
         FALSE,                 /* pc_relative */
         0,                     /* bitpos */
-        complain_overflow_bitfield, /* complain_on_overflow */
+        complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_XSTORMY16_NONE",    /* name */
         FALSE,                 /* partial_inplace */
         bfd_elf_generic_reloc, /* special_function */
         "R_XSTORMY16_NONE",    /* name */
         FALSE,                 /* partial_inplace */
@@ -271,33 +270,33 @@ static reloc_howto_type xstormy16_elf_howto_table2 [] =
 {
   /* GNU extension to record C++ vtable hierarchy */
   HOWTO (R_XSTORMY16_GNU_VTINHERIT, /* type */
 {
   /* GNU extension to record C++ vtable hierarchy */
   HOWTO (R_XSTORMY16_GNU_VTINHERIT, /* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         0,                     /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_dont, /* complain_on_overflow */
-         NULL,                  /* special_function */
-         "R_XSTORMY16_GNU_VTINHERIT", /* name */
-         FALSE,                 /* partial_inplace */
-         0,                     /* src_mask */
-         0,                     /* dst_mask */
-         FALSE),                /* pcrel_offset */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        0,                     /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont, /* complain_on_overflow */
+        NULL,                  /* special_function */
+        "R_XSTORMY16_GNU_VTINHERIT", /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        0,                     /* dst_mask */
+        FALSE),                /* pcrel_offset */
 
   /* GNU extension to record C++ vtable member usage */
   HOWTO (R_XSTORMY16_GNU_VTENTRY,     /* type */
 
   /* GNU extension to record C++ vtable member usage */
   HOWTO (R_XSTORMY16_GNU_VTENTRY,     /* type */
-         0,                     /* rightshift */
-         2,                     /* size (0 = byte, 1 = short, 2 = long) */
-         0,                     /* bitsize */
-         FALSE,                 /* pc_relative */
-         0,                     /* bitpos */
-         complain_overflow_dont, /* complain_on_overflow */
-         _bfd_elf_rel_vtable_reloc_fn,  /* special_function */
-         "R_XSTORMY16_GNU_VTENTRY",   /* name */
-         FALSE,                 /* partial_inplace */
-         0,                     /* src_mask */
-         0,                     /* dst_mask */
-         FALSE),                /* pcrel_offset */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        0,                     /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_dont, /* complain_on_overflow */
+        _bfd_elf_rel_vtable_reloc_fn,  /* special_function */
+        "R_XSTORMY16_GNU_VTENTRY",   /* name */
+        FALSE,                 /* partial_inplace */
+        0,                     /* src_mask */
+        0,                     /* dst_mask */
+        FALSE),                /* pcrel_offset */
 
 };
 \f
 
 };
 \f
@@ -306,27 +305,27 @@ static reloc_howto_type xstormy16_elf_howto_table2 [] =
 typedef struct xstormy16_reloc_map
 {
   bfd_reloc_code_real_type  bfd_reloc_val;
 typedef struct xstormy16_reloc_map
 {
   bfd_reloc_code_real_type  bfd_reloc_val;
-  unsigned int              xstormy16_reloc_val;
-  reloc_howto_type *        table;
+  unsigned int             xstormy16_reloc_val;
+  reloc_howto_type *       table;
 } reloc_map;
 
 static const reloc_map xstormy16_reloc_map [] =
 {
 } reloc_map;
 
 static const reloc_map xstormy16_reloc_map [] =
 {
-  { BFD_RELOC_NONE,                 R_XSTORMY16_NONE,          xstormy16_elf_howto_table },
-  { BFD_RELOC_32,                   R_XSTORMY16_32,            xstormy16_elf_howto_table },
-  { BFD_RELOC_16,                   R_XSTORMY16_16,            xstormy16_elf_howto_table },
-  { BFD_RELOC_8,                    R_XSTORMY16_8,             xstormy16_elf_howto_table },
-  { BFD_RELOC_32_PCREL,             R_XSTORMY16_PC32,          xstormy16_elf_howto_table },
-  { BFD_RELOC_16_PCREL,             R_XSTORMY16_PC16,          xstormy16_elf_howto_table },
-  { BFD_RELOC_8_PCREL,              R_XSTORMY16_PC8,           xstormy16_elf_howto_table },
-  { BFD_RELOC_XSTORMY16_REL_12,     R_XSTORMY16_REL_12,        xstormy16_elf_howto_table },
-  { BFD_RELOC_XSTORMY16_24,        R_XSTORMY16_24,            xstormy16_elf_howto_table },
-  { BFD_RELOC_XSTORMY16_FPTR16,            R_XSTORMY16_FPTR16,        xstormy16_elf_howto_table },
-  { BFD_RELOC_LO16,                 R_XSTORMY16_LO16,          xstormy16_elf_howto_table },
-  { BFD_RELOC_HI16,                 R_XSTORMY16_HI16,          xstormy16_elf_howto_table },
-  { BFD_RELOC_XSTORMY16_12,         R_XSTORMY16_12,            xstormy16_elf_howto_table },
-  { BFD_RELOC_VTABLE_INHERIT,       R_XSTORMY16_GNU_VTINHERIT, xstormy16_elf_howto_table2 },
-  { BFD_RELOC_VTABLE_ENTRY,         R_XSTORMY16_GNU_VTENTRY,   xstormy16_elf_howto_table2 },
+  { BFD_RELOC_NONE,                R_XSTORMY16_NONE,          xstormy16_elf_howto_table },
+  { BFD_RELOC_32,                  R_XSTORMY16_32,            xstormy16_elf_howto_table },
+  { BFD_RELOC_16,                  R_XSTORMY16_16,            xstormy16_elf_howto_table },
+  { BFD_RELOC_8,                   R_XSTORMY16_8,             xstormy16_elf_howto_table },
+  { BFD_RELOC_32_PCREL,                    R_XSTORMY16_PC32,          xstormy16_elf_howto_table },
+  { BFD_RELOC_16_PCREL,                    R_XSTORMY16_PC16,          xstormy16_elf_howto_table },
+  { BFD_RELOC_8_PCREL,             R_XSTORMY16_PC8,           xstormy16_elf_howto_table },
+  { BFD_RELOC_XSTORMY16_REL_12,            R_XSTORMY16_REL_12,        xstormy16_elf_howto_table },
+  { BFD_RELOC_XSTORMY16_24,        R_XSTORMY16_24,            xstormy16_elf_howto_table },
+  { BFD_RELOC_XSTORMY16_FPTR16,            R_XSTORMY16_FPTR16,        xstormy16_elf_howto_table },
+  { BFD_RELOC_LO16,                R_XSTORMY16_LO16,          xstormy16_elf_howto_table },
+  { BFD_RELOC_HI16,                R_XSTORMY16_HI16,          xstormy16_elf_howto_table },
+  { BFD_RELOC_XSTORMY16_12,        R_XSTORMY16_12,            xstormy16_elf_howto_table },
+  { BFD_RELOC_VTABLE_INHERIT,      R_XSTORMY16_GNU_VTINHERIT, xstormy16_elf_howto_table2 },
+  { BFD_RELOC_VTABLE_ENTRY,        R_XSTORMY16_GNU_VTENTRY,   xstormy16_elf_howto_table2 },
 };
 
 static reloc_howto_type *
 };
 
 static reloc_howto_type *
@@ -335,7 +334,7 @@ xstormy16_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
 {
   unsigned int i;
 
 {
   unsigned int i;
 
-  for (i = ARRAY_SIZE (xstormy16_reloc_map); --i;)
+  for (i = ARRAY_SIZE (xstormy16_reloc_map); i--;)
     {
       const reloc_map * entry;
 
     {
       const reloc_map * entry;
 
@@ -349,10 +348,35 @@ xstormy16_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
   return NULL;
 }
 
   return NULL;
 }
 
+static reloc_howto_type *
+xstormy16_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                            const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < (sizeof (xstormy16_elf_howto_table)
+           / sizeof (xstormy16_elf_howto_table[0]));
+       i++)
+    if (xstormy16_elf_howto_table[i].name != NULL
+       && strcasecmp (xstormy16_elf_howto_table[i].name, r_name) == 0)
+      return &xstormy16_elf_howto_table[i];
+
+  for (i = 0;
+       i < (sizeof (xstormy16_elf_howto_table2)
+           / sizeof (xstormy16_elf_howto_table2[0]));
+       i++)
+    if (xstormy16_elf_howto_table2[i].name != NULL
+       && strcasecmp (xstormy16_elf_howto_table2[i].name, r_name) == 0)
+      return &xstormy16_elf_howto_table2[i];
+
+  return NULL;
+}
+
 /* Set the howto pointer for an XSTORMY16 ELF reloc.  */
 
 /* Set the howto pointer for an XSTORMY16 ELF reloc.  */
 
-static void
-xstormy16_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
+static bfd_boolean
+xstormy16_info_to_howto_rela (bfd * abfd,
                              arelent * cache_ptr,
                              Elf_Internal_Rela * dst)
 {
                              arelent * cache_ptr,
                              Elf_Internal_Rela * dst)
 {
@@ -361,11 +385,19 @@ xstormy16_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED,
   if (r_type <= (unsigned int) R_XSTORMY16_12)
     cache_ptr->howto = &xstormy16_elf_howto_table [r_type];
   else if (r_type - R_XSTORMY16_GNU_VTINHERIT
   if (r_type <= (unsigned int) R_XSTORMY16_12)
     cache_ptr->howto = &xstormy16_elf_howto_table [r_type];
   else if (r_type - R_XSTORMY16_GNU_VTINHERIT
-          <= (unsigned int) R_XSTORMY16_GNU_VTENTRY)
+          <= ((unsigned int) R_XSTORMY16_GNU_VTENTRY
+              - (unsigned int) R_XSTORMY16_GNU_VTINHERIT))
     cache_ptr->howto
       = &xstormy16_elf_howto_table2 [r_type - R_XSTORMY16_GNU_VTINHERIT];
   else
     cache_ptr->howto
       = &xstormy16_elf_howto_table2 [r_type - R_XSTORMY16_GNU_VTINHERIT];
   else
-    abort ();
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, r_type);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+  return TRUE;
 }
 \f
 /* We support 16-bit pointers to code above 64k by generating a thunk
 }
 \f
 /* We support 16-bit pointers to code above 64k by generating a thunk
@@ -387,13 +419,12 @@ xstormy16_elf_check_relocs (bfd *abfd,
   asection *splt;
   bfd *dynobj;
 
   asection *splt;
   bfd *dynobj;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   symtab_hdr = &elf_tdata(abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   local_plt_offsets = elf_local_got_offsets (abfd);
     return TRUE;
 
   symtab_hdr = &elf_tdata(abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
   local_plt_offsets = elf_local_got_offsets (abfd);
-  splt = NULL;
   dynobj = elf_hash_table(info)->dynobj;
 
   relend = relocs + sec->reloc_count;
   dynobj = elf_hash_table(info)->dynobj;
 
   relend = relocs + sec->reloc_count;
@@ -415,7 +446,7 @@ xstormy16_elf_check_relocs (bfd *abfd,
        }
 
       switch (ELF32_R_TYPE (rel->r_info))
        }
 
       switch (ELF32_R_TYPE (rel->r_info))
-        {
+       {
          /* This relocation describes a 16-bit pointer to a function.
             We may need to allocate a thunk in low memory; reserve memory
             for it now.  */
          /* This relocation describes a 16-bit pointer to a function.
             We may need to allocate a thunk in low memory; reserve memory
             for it now.  */
@@ -429,24 +460,19 @@ xstormy16_elf_check_relocs (bfd *abfd,
 
          if (dynobj == NULL)
            elf_hash_table (info)->dynobj = dynobj = abfd;
 
          if (dynobj == NULL)
            elf_hash_table (info)->dynobj = dynobj = abfd;
+         splt = elf_hash_table (info)->splt;
          if (splt == NULL)
            {
          if (splt == NULL)
            {
-             splt = bfd_get_section_by_name (dynobj, ".plt");
-             if (splt == NULL)
-               {
-                 splt = bfd_make_section_with_flags (dynobj, ".plt",
-                                                     (SEC_ALLOC
-                                                      | SEC_LOAD
-                                                      | SEC_HAS_CONTENTS
-                                                      | SEC_IN_MEMORY
-                                                      | SEC_LINKER_CREATED
-                                                      | SEC_READONLY
-                                                      | SEC_CODE));
-
-                 if (splt == NULL
-                     || ! bfd_set_section_alignment (dynobj, splt, 1))
-                   return FALSE;
-               }
+             flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                               | SEC_IN_MEMORY | SEC_LINKER_CREATED
+                               | SEC_READONLY | SEC_CODE);
+
+             splt = bfd_make_section_anyway_with_flags (dynobj, ".plt",
+                                                        flags);
+             elf_hash_table (info)->splt = splt;
+             if (splt == NULL
+                 || !bfd_set_section_alignment (splt, 1))
+               return FALSE;
            }
 
          if (h != NULL)
            }
 
          if (h != NULL)
@@ -479,17 +505,17 @@ xstormy16_elf_check_relocs (bfd *abfd,
 
          /* This relocation describes the C++ object vtable hierarchy.
             Reconstruct it for later use during GC.  */
 
          /* This relocation describes the C++ object vtable hierarchy.
             Reconstruct it for later use during GC.  */
-        case R_XSTORMY16_GNU_VTINHERIT:
-          if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
-            return FALSE;
-          break;
+       case R_XSTORMY16_GNU_VTINHERIT:
+         if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+           return FALSE;
+         break;
 
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
 
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
-        case R_XSTORMY16_GNU_VTENTRY:
-          if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
-            return FALSE;
-          break;
+       case R_XSTORMY16_GNU_VTENTRY:
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+           return FALSE;
+         break;
        }
     }
 
        }
     }
 
@@ -510,9 +536,6 @@ xstormy16_relax_plt_check (struct elf_link_hash_entry *h, void * xdata)
 {
   struct relax_plt_data *data = (struct relax_plt_data *) xdata;
 
 {
   struct relax_plt_data *data = (struct relax_plt_data *) xdata;
 
-  if (h->root.type == bfd_link_hash_warning)
-    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
   if (h->plt.offset != (bfd_vma) -1)
     {
       bfd_vma address;
   if (h->plt.offset != (bfd_vma) -1)
     {
       bfd_vma address;
@@ -544,9 +567,6 @@ xstormy16_relax_plt_realloc (struct elf_link_hash_entry *h, void * xdata)
 {
   bfd_vma *entry = (bfd_vma *) xdata;
 
 {
   bfd_vma *entry = (bfd_vma *) xdata;
 
-  if (h->root.type == bfd_link_hash_warning)
-    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
   if (h->plt.offset != (bfd_vma) -1)
     {
       h->plt.offset = *entry;
   if (h->plt.offset != (bfd_vma) -1)
     {
       h->plt.offset = *entry;
@@ -568,7 +588,7 @@ xstormy16_elf_relax_section (bfd *dynobj,
   /* Assume nothing changes.  */
   *again = FALSE;
 
   /* Assume nothing changes.  */
   *again = FALSE;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   /* We only relax the .plt section at the moment.  */
     return TRUE;
 
   /* We only relax the .plt section at the moment.  */
@@ -589,7 +609,7 @@ xstormy16_elf_relax_section (bfd *dynobj,
 
   /* Likewise for local symbols, though that's somewhat less convenient
      as we have to walk the list of input bfds and swap in symbol data.  */
 
   /* Likewise for local symbols, though that's somewhat less convenient
      as we have to walk the list of input bfds and swap in symbol data.  */
-  for (ibfd = info->input_bfds; ibfd ; ibfd = ibfd->link_next)
+  for (ibfd = info->input_bfds; ibfd ; ibfd = ibfd->link.next)
     {
       bfd_vma *local_plt_offsets = elf_local_got_offsets (ibfd);
       Elf_Internal_Shdr *symtab_hdr;
     {
       bfd_vma *local_plt_offsets = elf_local_got_offsets (ibfd);
       Elf_Internal_Shdr *symtab_hdr;
@@ -663,7 +683,7 @@ xstormy16_elf_relax_section (bfd *dynobj,
       elf_link_hash_traverse (elf_hash_table (info),
                              xstormy16_relax_plt_realloc, &entry);
 
       elf_link_hash_traverse (elf_hash_table (info),
                              xstormy16_relax_plt_realloc, &entry);
 
-      for (ibfd = info->input_bfds; ibfd ; ibfd = ibfd->link_next)
+      for (ibfd = info->input_bfds; ibfd ; ibfd = ibfd->link.next)
        {
          bfd_vma *local_plt_offsets = elf_local_got_offsets (ibfd);
          unsigned int nlocals = elf_tdata (ibfd)->symtab_hdr.sh_info;
        {
          bfd_vma *local_plt_offsets = elf_local_got_offsets (ibfd);
          unsigned int nlocals = elf_tdata (ibfd)->symtab_hdr.sh_info;
@@ -675,7 +695,7 @@ xstormy16_elf_relax_section (bfd *dynobj,
          for (idx = 0; idx < nlocals; ++idx)
            if (local_plt_offsets[idx] != (bfd_vma) -1)
              {
          for (idx = 0; idx < nlocals; ++idx)
            if (local_plt_offsets[idx] != (bfd_vma) -1)
              {
-               local_plt_offsets[idx] = entry;
+               local_plt_offsets[idx] = entry;
                entry += 4;
              }
        }
                entry += 4;
              }
        }
@@ -691,14 +711,14 @@ xstormy16_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
   bfd *dynobj;
   asection *splt;
 
   bfd *dynobj;
   asection *splt;
 
-  if (info->relocatable)
+  if (bfd_link_relocatable (info))
     return TRUE;
 
   dynobj = elf_hash_table (info)->dynobj;
   if (dynobj == NULL)
     return TRUE;
 
     return TRUE;
 
   dynobj = elf_hash_table (info)->dynobj;
   if (dynobj == NULL)
     return TRUE;
 
-  splt = bfd_get_section_by_name (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
   BFD_ASSERT (splt != NULL);
 
   splt->contents = bfd_zalloc (dynobj, splt->size);
   BFD_ASSERT (splt != NULL);
 
   splt->contents = bfd_zalloc (dynobj, splt->size);
@@ -739,45 +759,38 @@ xstormy16_elf_always_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
    accordingly.  */
 
 static bfd_boolean
    accordingly.  */
 
 static bfd_boolean
-xstormy16_elf_relocate_section (bfd *                   output_bfd ATTRIBUTE_UNUSED,
-                               struct bfd_link_info *  info,
-                               bfd *                   input_bfd,
-                               asection *              input_section,
-                               bfd_byte *              contents,
-                               Elf_Internal_Rela *     relocs,
-                               Elf_Internal_Sym *      local_syms,
-                               asection **             local_sections)
+xstormy16_elf_relocate_section (bfd *                  output_bfd ATTRIBUTE_UNUSED,
+                               struct bfd_link_info *  info,
+                               bfd *                   input_bfd,
+                               asection *              input_section,
+                               bfd_byte *              contents,
+                               Elf_Internal_Rela *     relocs,
+                               Elf_Internal_Sym *      local_syms,
+                               asection **             local_sections)
 {
 {
-  Elf_Internal_Shdr *           symtab_hdr;
+  Elf_Internal_Shdr *          symtab_hdr;
   struct elf_link_hash_entry ** sym_hashes;
   struct elf_link_hash_entry ** sym_hashes;
-  Elf_Internal_Rela *           rel;
-  Elf_Internal_Rela *           relend;
-  bfd *dynobj;
+  Elf_Internal_Rela *          rel;
+  Elf_Internal_Rela *          relend;
   asection *splt;
 
   asection *splt;
 
-  if (info->relocatable)
-    return TRUE;
-
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
   relend     = relocs + input_section->reloc_count;
 
   symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
   relend     = relocs + input_section->reloc_count;
 
-  dynobj = elf_hash_table (info)->dynobj;
-  splt = NULL;
-  if (dynobj != NULL)
-    splt = bfd_get_section_by_name (dynobj, ".plt");
+  splt = elf_hash_table (info)->splt;
 
   for (rel = relocs; rel < relend; rel ++)
     {
 
   for (rel = relocs; rel < relend; rel ++)
     {
-      reloc_howto_type *           howto;
-      unsigned long                r_symndx;
-      Elf_Internal_Sym *           sym;
-      asection *                   sec;
+      reloc_howto_type *          howto;
+      unsigned long               r_symndx;
+      Elf_Internal_Sym *          sym;
+      asection *                  sec;
       struct elf_link_hash_entry * h;
       struct elf_link_hash_entry * h;
-      bfd_vma                      relocation;
-      bfd_reloc_status_type        r;
-      const char *                 name = NULL;
-      int                          r_type;
+      bfd_vma                     relocation;
+      bfd_reloc_status_type       r;
+      const char *                name = NULL;
+      int                         r_type;
 
       r_type = ELF32_R_TYPE (rel->r_info);
 
 
       r_type = ELF32_R_TYPE (rel->r_info);
 
@@ -799,14 +812,21 @@ xstormy16_elf_relocate_section (bfd *                   output_bfd ATTRIBUTE_UNU
        }
       else
        {
        }
       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,
 
          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 && discarded_section (sec))
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, 1, relend, howto, 0, contents);
+
+      if (bfd_link_relocatable (info))
+       continue;
+
       if (h != NULL)
        name = h->root.root.string;
       else
       if (h != NULL)
        name = h->root.root.string;
       else
@@ -814,7 +834,7 @@ xstormy16_elf_relocate_section (bfd *                   output_bfd ATTRIBUTE_UNU
          name = (bfd_elf_string_from_elf_section
                  (input_bfd, symtab_hdr->sh_link, sym->st_name));
          if (name == NULL || *name == '\0')
          name = (bfd_elf_string_from_elf_section
                  (input_bfd, symtab_hdr->sh_link, sym->st_name));
          if (name == NULL || *name == '\0')
-           name = bfd_section_name (input_bfd, sec);
+           name = bfd_section_name (sec);
        }
 
       switch (ELF32_R_TYPE (rel->r_info))
        }
 
       switch (ELF32_R_TYPE (rel->r_info))
@@ -848,9 +868,9 @@ xstormy16_elf_relocate_section (bfd *                   output_bfd ATTRIBUTE_UNU
 
            if (relocation <= 0xffff)
              {
 
            if (relocation <= 0xffff)
              {
-               /* If the symbol is in range for a 16-bit address, we should
+               /* If the symbol is in range for a 16-bit address, we should
                   have deallocated the plt entry in relax_section.  */
                   have deallocated the plt entry in relax_section.  */
-               BFD_ASSERT (*plt_offset == (bfd_vma) -1);
+               BFD_ASSERT (*plt_offset == (bfd_vma) -1);
              }
            else
              {
              }
            else
              {
@@ -895,15 +915,14 @@ xstormy16_elf_relocate_section (bfd *                   output_bfd ATTRIBUTE_UNU
          switch (r)
            {
            case bfd_reloc_overflow:
          switch (r)
            {
            case bfd_reloc_overflow:
-             r = info->callbacks->reloc_overflow
+             (*info->callbacks->reloc_overflow)
                (info, (h ? &h->root : NULL), name, howto->name,
                 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
              break;
 
            case bfd_reloc_undefined:
                (info, (h ? &h->root : NULL), name, howto->name,
                 (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
              break;
 
            case bfd_reloc_undefined:
-             r = info->callbacks->undefined_symbol
-               (info, name, input_bfd, input_section, rel->r_offset,
-                TRUE);
+             (*info->callbacks->undefined_symbol)
+               (info, name, input_bfd, input_section, rel->r_offset, TRUE);
              break;
 
            case bfd_reloc_outofrange:
              break;
 
            case bfd_reloc_outofrange:
@@ -924,11 +943,8 @@ xstormy16_elf_relocate_section (bfd *                   output_bfd ATTRIBUTE_UNU
            }
 
          if (msg)
            }
 
          if (msg)
-           r = info->callbacks->warning
-             (info, msg, name, input_bfd, input_section, rel->r_offset);
-
-         if (! r)
-           return FALSE;
+           (*info->callbacks->warning) (info, msg, name, input_bfd,
+                                        input_section, rel->r_offset);
        }
     }
 
        }
     }
 
@@ -941,14 +957,13 @@ static bfd_boolean
 xstormy16_elf_finish_dynamic_sections (bfd *abfd ATTRIBUTE_UNUSED,
                                       struct bfd_link_info *info)
 {
 xstormy16_elf_finish_dynamic_sections (bfd *abfd ATTRIBUTE_UNUSED,
                                       struct bfd_link_info *info)
 {
-  bfd *dynobj;
-  asection *splt;
+  bfd *dynobj = elf_hash_table (info)->dynobj;
+  asection *splt = elf_hash_table (info)->splt;
 
   /* As an extra sanity check, verify that all plt entries have
      been filled in.  */
 
 
   /* As an extra sanity check, verify that all plt entries have
      been filled in.  */
 
-  if ((dynobj = elf_hash_table (info)->dynobj) != NULL
-      && (splt = bfd_get_section_by_name (dynobj, ".plt")) != NULL)
+  if (dynobj != NULL && splt != NULL)
     {
       bfd_byte *contents = splt->contents;
       unsigned int i, size = splt->size;
     {
       bfd_byte *contents = splt->contents;
       unsigned int i, size = splt->size;
@@ -989,18 +1004,18 @@ xstormy16_elf_gc_mark_hook (asection *sec,
 #define ELF_MACHINE_CODE       EM_XSTORMY16
 #define ELF_MAXPAGESIZE                0x100
 
 #define ELF_MACHINE_CODE       EM_XSTORMY16
 #define ELF_MAXPAGESIZE                0x100
 
-#define TARGET_LITTLE_SYM       bfd_elf32_xstormy16_vec
+#define TARGET_LITTLE_SYM       xstormy16_elf32_vec
 #define TARGET_LITTLE_NAME     "elf32-xstormy16"
 
 #define elf_info_to_howto_rel                  NULL
 #define elf_info_to_howto                      xstormy16_info_to_howto_rela
 #define elf_backend_relocate_section           xstormy16_elf_relocate_section
 #define elf_backend_gc_mark_hook               xstormy16_elf_gc_mark_hook
 #define TARGET_LITTLE_NAME     "elf32-xstormy16"
 
 #define elf_info_to_howto_rel                  NULL
 #define elf_info_to_howto                      xstormy16_info_to_howto_rela
 #define elf_backend_relocate_section           xstormy16_elf_relocate_section
 #define elf_backend_gc_mark_hook               xstormy16_elf_gc_mark_hook
-#define elf_backend_check_relocs                xstormy16_elf_check_relocs
+#define elf_backend_check_relocs               xstormy16_elf_check_relocs
 #define elf_backend_always_size_sections \
   xstormy16_elf_always_size_sections
 #define elf_backend_omit_section_dynsym \
 #define elf_backend_always_size_sections \
   xstormy16_elf_always_size_sections
 #define elf_backend_omit_section_dynsym \
-  ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
+  _bfd_elf_omit_section_dynsym_all
 #define elf_backend_finish_dynamic_sections \
   xstormy16_elf_finish_dynamic_sections
 
 #define elf_backend_finish_dynamic_sections \
   xstormy16_elf_finish_dynamic_sections
 
@@ -1008,6 +1023,8 @@ xstormy16_elf_gc_mark_hook (asection *sec,
 #define elf_backend_rela_normal                        1
 
 #define bfd_elf32_bfd_reloc_type_lookup                xstormy16_reloc_type_lookup
 #define elf_backend_rela_normal                        1
 
 #define bfd_elf32_bfd_reloc_type_lookup                xstormy16_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup \
+  xstormy16_reloc_name_lookup
 #define bfd_elf32_bfd_relax_section            xstormy16_elf_relax_section
 
 #include "elf32-target.h"
 #define bfd_elf32_bfd_relax_section            xstormy16_elf_relax_section
 
 #include "elf32-target.h"
This page took 0.034108 seconds and 4 git commands to generate.