]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/coff-tic30.c
bfd/
[thirdparty/binutils-gdb.git] / bfd / coff-tic30.c
index 3ff8c59403654e86c4677d5143e27fb3562fca16..dd97b2f8abbbbc7f7f88f07759b1f44bbc05a573 100644 (file)
@@ -1,5 +1,6 @@
 /* BFD back-end for TMS320C30 coff binaries.
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000, 2001, 2002, 2007
+   Free Software Foundation, Inc.
    Contributed by Steven Haworth (steve@pm.cse.rmit.edu.au)
 
    This file is part of BFD, the Binary File Descriptor library.
 
    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., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "bfdlink.h"
 #include "coff/tic30.h"
 #include "coff/internal.h"
 #include "libcoff.h"
 
+static int  coff_tic30_select_reloc PARAMS ((reloc_howto_type *));
+static void rtype2howto PARAMS ((arelent *, struct internal_reloc *));
+static void reloc_processing PARAMS ((arelent *, struct internal_reloc *, asymbol **, bfd *, asection *));
+
+reloc_howto_type * tic30_coff_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
+
 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (1)
 
 reloc_howto_type tic30_coff_howto_table[] =
-{
-  HOWTO (R_TIC30_ABS16, 2, 1, 16, false, 0, 0, NULL,
-        "16", false, 0x0000FFFF, 0x0000FFFF, false),
-  HOWTO (R_TIC30_ABS24, 2, 2, 24, false, 8, complain_overflow_bitfield, NULL,
-        "24", false, 0xFFFFFF00, 0xFFFFFF00, false),
-  HOWTO (R_TIC30_LDP, 18, 0, 24, false, 0, complain_overflow_bitfield, NULL,
-        "LDP", false, 0x00FF0000, 0x000000FF, false),
-  HOWTO (R_TIC30_ABS32, 2, 2, 32, false, 0, complain_overflow_bitfield, NULL,
-        "32", false, 0xFFFFFFFF, 0xFFFFFFFF, false),
-  HOWTO (R_TIC30_PC16, 2, 1, 16, true, 0, complain_overflow_signed, NULL,
-        "PCREL", false, 0x0000FFFF, 0x0000FFFF, false),
-  {-1}
-};
+  {
+    HOWTO (R_TIC30_ABS16, 2, 1, 16, FALSE, 0, 0, NULL,
+          "16", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE),
+    HOWTO (R_TIC30_ABS24, 2, 2, 24, FALSE, 8, complain_overflow_bitfield, NULL,
+          "24", FALSE, 0xFFFFFF00, 0xFFFFFF00, FALSE),
+    HOWTO (R_TIC30_LDP, 18, 0, 24, FALSE, 0, complain_overflow_bitfield, NULL,
+          "LDP", FALSE, 0x00FF0000, 0x000000FF, FALSE),
+    HOWTO (R_TIC30_ABS32, 2, 2, 32, FALSE, 0, complain_overflow_bitfield, NULL,
+          "32", FALSE, 0xFFFFFFFF, 0xFFFFFFFF, FALSE),
+    HOWTO (R_TIC30_PC16, 2, 1, 16, TRUE, 0, complain_overflow_signed, NULL,
+          "PCREL", FALSE, 0x0000FFFF, 0x0000FFFF, FALSE),
+    EMPTY_HOWTO (-1)
+  };
 
 #ifndef coff_bfd_reloc_type_lookup
 #define coff_bfd_reloc_type_lookup tic30_coff_reloc_type_lookup
+#define coff_bfd_reloc_name_lookup tic30_coff_reloc_name_lookup
 
 /* For the case statement use the code values used in tc_gen_reloc to
    map to the howto table entries that match those in both the aout
-   and coff implementations. */
+   and coff implementations.  */
+
 reloc_howto_type *
 tic30_coff_reloc_type_lookup (abfd, code)
-     bfd *abfd;
+     bfd *abfd ATTRIBUTE_UNUSED;
      bfd_reloc_code_real_type code;
 {
   switch (code)
@@ -73,9 +82,26 @@ tic30_coff_reloc_type_lookup (abfd, code)
     }
 }
 
+static reloc_howto_type *
+tic30_coff_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                             const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < (sizeof (tic30_coff_howto_table)
+           / sizeof (tic30_coff_howto_table[0]));
+       i++)
+    if (tic30_coff_howto_table[i].name != NULL
+       && strcasecmp (tic30_coff_howto_table[i].name, r_name) == 0)
+      return &tic30_coff_howto_table[i];
+
+  return NULL;
+}
+
 #endif
 
-/* Turn a howto into a reloc number */
+/* Turn a howto into a reloc number */
 
 static int
 coff_tic30_select_reloc (howto)
@@ -86,18 +112,17 @@ coff_tic30_select_reloc (howto)
 
 #define SELECT_RELOC(x,howto) x.r_type = coff_tic30_select_reloc(howto)
 
-
 #define BADMAG(x) TIC30BADMAG(x)
 #define TIC30 1                        /* Customize coffcode.h */
 #define __A_MAGIC_SET__
 
 /* Code to swap in the reloc */
-#define SWAP_IN_RELOC_OFFSET  bfd_h_get_32
-#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32
+#define SWAP_IN_RELOC_OFFSET  H_GET_32
+#define SWAP_OUT_RELOC_OFFSET H_PUT_32
 #define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) dst->r_stuff[0] = 'S'; \
 dst->r_stuff[1] = 'C';
 
-/* Code to turn a r_type into a howto ptr, uses the above howto table. */
+/* Code to turn a r_type into a howto ptr, uses the above howto table.  */
 
 static void
 rtype2howto (internal, dst)
@@ -127,14 +152,13 @@ rtype2howto (internal, dst)
     }
 }
 
-#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
+#define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry)
 
 /* Perform any necessary magic to the addend in a reloc entry */
 
 #define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
  cache_ptr->addend =  ext_reloc.r_offset;
 
-
 #define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
  reloc_processing(relent, reloc, symbols, abfd, section)
 
@@ -150,13 +174,10 @@ reloc_processing (relent, reloc, symbols, abfd, section)
   rtype2howto (relent, reloc);
 
   if (reloc->r_symndx > 0)
-    {
-      relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
-    }
+    relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx];
   else
-    {
-      relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
-    }
+    relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
+
   relent->addend = reloc->r_offset;
   relent->address -= section->vma;
 }
@@ -202,5 +223,7 @@ const bfd_target tic30_coff_vec =
   BFD_JUMP_TABLE_LINK (coff),
   BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
 
+  NULL,
+
   COFF_SWAP_TABLE
 };