* elf-m10300.c (mn10300_elf_relax_section): Fix check for an
[deliverable/binutils-gdb.git] / bfd / elf32-crx.c
index 438c1c26682a751f8e285f4274850b26555b9904..d48932d5e00b0aae37b7ee8e0ef3eb75b331a6a8 100644 (file)
@@ -1,12 +1,13 @@
 /* BFD back-end for National Semiconductor's CRX ELF
-   Copyright 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+   Copyright 2004, 2005, 2006, 2007, 2009, 2010
+   Free Software Foundation, Inc.
    Written by Tomer Levi, NSC, Israel.
 
    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, 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 "bfd.h"
 #include "bfdlink.h"
 #include "libbfd.h"
 #include "elf-bfd.h"
@@ -103,7 +105,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REL4",          /* name */
         FALSE,                 /* partial_inplace */
-        0xf,                   /* src_mask */
+        0x0,                   /* src_mask */
         0xf,                   /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -117,7 +119,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REL8",          /* name */
         FALSE,                 /* partial_inplace */
-        0xff,                  /* src_mask */
+        0x0,                   /* src_mask */
         0xff,                  /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -131,7 +133,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REL8_CMP",      /* name */
         FALSE,                 /* partial_inplace */
-        0xff,                  /* src_mask */
+        0x0,                   /* src_mask */
         0xff,                  /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -145,7 +147,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REL16",         /* name */
         FALSE,                 /* partial_inplace */
-        0xffff,                /* src_mask */
+        0x0,                   /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -159,7 +161,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REL24",         /* name */
         FALSE,                 /* partial_inplace */
-        0xffffff,              /* src_mask */
+        0x0,                   /* src_mask */
         0xffffff,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -173,7 +175,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REL32",         /* name */
         FALSE,                 /* partial_inplace */
-        0xffffffff,            /* src_mask */
+        0x0,                   /* src_mask */
         0xffffffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -187,7 +189,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REGREL12",      /* name */
         FALSE,                 /* partial_inplace */
-        0xfff,                 /* src_mask */
+        0x0,                   /* src_mask */
         0xfff,                 /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -201,7 +203,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REGREL22",      /* name */
         FALSE,                 /* partial_inplace */
-        0x3fffff,              /* src_mask */
+        0x0,                   /* src_mask */
         0x3fffff,              /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -215,7 +217,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REGREL28",      /* name */
         FALSE,                 /* partial_inplace */
-        0xfffffff,             /* src_mask */
+        0x0,                   /* src_mask */
         0xfffffff,             /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -229,7 +231,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_REGREL32",      /* name */
         FALSE,                 /* partial_inplace */
-        0xffffffff,            /* src_mask */
+        0x0,                   /* src_mask */
         0xffffffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -243,7 +245,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_ABS16",         /* name */
         FALSE,                 /* partial_inplace */
-        0xffff,                /* src_mask */
+        0x0,                   /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -257,7 +259,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_ABS32",         /* name */
         FALSE,                 /* partial_inplace */
-        0xffffffff,            /* src_mask */
+        0x0,                   /* src_mask */
         0xffffffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -271,7 +273,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_NUM8",          /* name */
         FALSE,                 /* partial_inplace */
-        0xff,                  /* src_mask */
+        0x0,                   /* src_mask */
         0xff,                  /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -285,7 +287,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_NUM16",         /* name */
         FALSE,                 /* partial_inplace */
-        0xffff,                /* src_mask */
+        0x0,                   /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -299,7 +301,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_NUM32",         /* name */
         FALSE,                 /* partial_inplace */
-        0xffffffff,            /* src_mask */
+        0x0,                   /* src_mask */
         0xffffffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -313,7 +315,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_IMM16",         /* name */
         FALSE,                 /* partial_inplace */
-        0xffff,                /* src_mask */
+        0x0,                   /* src_mask */
         0xffff,                /* dst_mask */
         FALSE),                /* pcrel_offset */
 
@@ -327,7 +329,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_IMM32",         /* name */
         FALSE,                 /* partial_inplace */
-        0xffffffff,            /* src_mask */
+        0x0,                   /* src_mask */
         0xffffffff,            /* dst_mask */
         FALSE),                /* pcrel_offset */
  
@@ -344,7 +346,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_SWITCH8",       /* name */
         FALSE,                 /* partial_inplace */
-        0xff,                  /* src_mask */
+        0x0,                   /* src_mask */
         0xff,                  /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
@@ -361,7 +363,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_SWITCH16",      /* name */
         FALSE,                 /* partial_inplace */
-        0xffff,                /* src_mask */
+        0x0,                   /* src_mask */
         0xffff,                /* dst_mask */
         TRUE),                 /* pcrel_offset */
 
@@ -378,7 +380,7 @@ static reloc_howto_type crx_elf_howto_table[] =
         bfd_elf_generic_reloc, /* special_function */
         "R_CRX_SWITCH32",      /* name */
         FALSE,                 /* partial_inplace */
-        0xffffffff,            /* src_mask */
+        0x0,                   /* src_mask */
         0xffffffff,            /* dst_mask */
         TRUE)                  /* pcrel_offset */
 };
@@ -399,6 +401,22 @@ elf_crx_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   return 0;
 }
 
+static reloc_howto_type *
+elf_crx_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                          const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < sizeof (crx_elf_howto_table) / sizeof (crx_elf_howto_table[0]);
+       i++)
+    if (crx_elf_howto_table[i].name != NULL
+       && strcasecmp (crx_elf_howto_table[i].name, r_name) == 0)
+      return &crx_elf_howto_table[i];
+
+  return NULL;
+}
+
 /* Retrieve a howto ptr using an internal relocation entry.  */
 
 static void
@@ -574,7 +592,6 @@ elf32_crx_relax_delete_bytes (struct bfd_link_info *link_info, bfd *abfd,
   unsigned int sec_shndx;
   bfd_byte *contents;
   Elf_Internal_Rela *irel, *irelend;
-  Elf_Internal_Rela *irelalign;
   bfd_vma toaddr;
   Elf_Internal_Sym *isym;
   Elf_Internal_Sym *isymend;
@@ -587,10 +604,6 @@ elf32_crx_relax_delete_bytes (struct bfd_link_info *link_info, bfd *abfd,
 
   contents = elf_section_data (sec)->this_hdr.contents;
 
-  /* The deletion must stop at the next ALIGN reloc for an aligment
-     power larger than the number of bytes we are deleting.  */
-
-  irelalign = NULL;
   toaddr = sec->size;
 
   irel = elf_section_data (sec)->relocs;
@@ -861,15 +874,8 @@ elf32_crx_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
        }
 
       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;
-       }
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, relend, howto, contents);
 
       if (info->relocatable)
        continue;
@@ -1311,6 +1317,8 @@ elf32_crx_relax_section (bfd *abfd, asection *sec,
 #define elf_symbol_leading_char                '_'
 
 #define bfd_elf32_bfd_reloc_type_lookup        elf_crx_reloc_type_lookup
+#define bfd_elf32_bfd_reloc_name_lookup \
+                                       elf_crx_reloc_name_lookup
 #define elf_info_to_howto              elf_crx_info_to_howto
 #define elf_info_to_howto_rel          0
 #define elf_backend_relocate_section   elf32_crx_relocate_section
This page took 0.0368540000000001 seconds and 4 git commands to generate.