daily update
[deliverable/binutils-gdb.git] / bfd / elf32-xc16x.c
index 1824302e88508c18f8d6a448fbe566249b3914bb..b7e0d412d50b3df6b7e59879c89f7c3ef2da12fd 100644 (file)
@@ -1,12 +1,12 @@
 /* Infineon XC16X-specific support for 16-bit ELF.
-   Copyright 2006  Free Software Foundation, Inc.
+   Copyright 2006, 2007, 2009, 2010, 2012 Free Software Foundation, Inc.
    Contributed by KPIT Cummins Infosystems 
 
    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,
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   Foundation, 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
 #include "elf/xc16x.h"
-#include "elf/dwarf2.h"
+#include "dwarf2.h"
 #include "libiberty.h"
 
 static reloc_howto_type xc16x_elf_howto_table [] =
@@ -205,6 +206,22 @@ xc16x_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   return NULL;
 }
 
+static reloc_howto_type *
+xc16x_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                        const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < sizeof (xc16x_elf_howto_table) / sizeof (xc16x_elf_howto_table[0]);
+       i++)
+    if (xc16x_elf_howto_table[i].name != NULL
+       && strcasecmp (xc16x_elf_howto_table[i].name, r_name) == 0)
+      return &xc16x_elf_howto_table[i];
+
+  return NULL;
+}
+
 /* For a particular operand this function is
    called to finalise the type of relocation.  */
 
@@ -328,9 +345,6 @@ elf32_xc16x_relocate_section (bfd *output_bfd,
   struct elf_link_hash_entry **sym_hashes;
   Elf_Internal_Rela *rel, *relend;
 
-  if (info->relocatable)
-    return TRUE;
-
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
 
@@ -344,7 +358,6 @@ elf32_xc16x_relocate_section (bfd *output_bfd,
       asection *sec;
       struct elf_link_hash_entry *h;
       bfd_vma relocation;
-      bfd_reloc_status_type r;
 
       /* This is a final link.  */
       r_symndx = ELF32_R_SYM (rel->r_info);
@@ -368,11 +381,25 @@ elf32_xc16x_relocate_section (bfd *output_bfd,
                                   unresolved_reloc, warned);
        }
 
-      r = elf32_xc16x_final_link_relocate (r_type, input_bfd, output_bfd,
-                                       input_section,
-                                       contents, rel->r_offset,
-                                       relocation, rel->r_addend,
-                                       info, sec, h == NULL);
+      if (sec != NULL && discarded_section (sec))
+       {
+         /* For relocs against symbols from removed linkonce sections,
+            or sections discarded by a linker script, we just want the
+            section contents cleared.  Avoid any special processing.  */
+         reloc_howto_type *howto;
+         howto = xc16x_reloc_type_lookup (input_bfd, r_type);
+         RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                          rel, 1, relend, howto, 0, contents);
+       }
+
+      if (info->relocatable)
+       continue;
+
+      elf32_xc16x_final_link_relocate (r_type, input_bfd, output_bfd,
+                                      input_section,
+                                      contents, rel->r_offset,
+                                      relocation, rel->r_addend,
+                                      info, sec, h == NULL);
     }
 
   return TRUE;
@@ -441,6 +468,7 @@ elf32_xc16x_object_p (bfd *abfd)
 #define elf_backend_object_p                   elf32_xc16x_object_p
 #define elf_backend_can_gc_sections    1
 #define bfd_elf32_bfd_reloc_type_lookup        xc16x_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup xc16x_reloc_name_lookup
 #define elf_info_to_howto              elf32_xc16x_info_to_howto
 #define elf_info_to_howto_rel          elf32_xc16x_info_to_howto
 #define elf_backend_relocate_section   elf32_xc16x_relocate_section
This page took 0.024745 seconds and 4 git commands to generate.