OSDN Git Service

daily update
[pf3gnuchains/pf3gnuchains3x.git] / bfd / coff-m68k.c
index 0947811..b53cc5f 100644 (file)
@@ -1,27 +1,28 @@
 /* BFD back-end for Motorola 68000 COFF binaries.
    Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1999,
-   2000, 2001, 2002, 2003
+   2000, 2001, 2002, 2003, 2005, 2007, 2008
    Free Software Foundation, Inc.
    Written by Cygnus Support.
 
-This file is part of BFD, the Binary File Descriptor library.
+   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
-(at your option) any later version.
+   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 3 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-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.  */
+   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.  */
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libbfd.h"
 #include "coff/m68k.h"
 #include "coff/internal.h"
@@ -91,6 +92,7 @@ m68k_coff_is_local_label_name (abfd, name)
 #define m68k_rtype2howto       _bfd_m68kcoff_rtype2howto
 #define m68k_howto2rtype       _bfd_m68kcoff_howto2rtype
 #define m68k_reloc_type_lookup _bfd_m68kcoff_reloc_type_lookup
+#define m68k_reloc_name_lookup _bfd_m68kcoff_reloc_name_lookup
 #endif
 
 #ifdef ONLY_DECLARE_RELOCS
@@ -123,6 +125,8 @@ extern void m68k_rtype2howto PARAMS ((arelent *internal, int relocentry));
 extern int m68k_howto2rtype PARAMS ((reloc_howto_type *));
 extern reloc_howto_type *m68k_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
+extern reloc_howto_type *m68k_reloc_name_lookup
+  PARAMS ((bfd *, const char *));
 #else
 
 #ifdef STATIC_RELOCS
@@ -132,6 +136,7 @@ extern reloc_howto_type *m68k_reloc_type_lookup
 #endif
 
 STAT_REL reloc_howto_type * m68k_reloc_type_lookup PARAMS ((bfd *, bfd_reloc_code_real_type));
+STAT_REL reloc_howto_type * m68k_reloc_name_lookup PARAMS ((bfd *, const char *));
 STAT_REL int m68k_howto2rtype PARAMS ((reloc_howto_type *));
 STAT_REL void m68k_rtype2howto PARAMS ((arelent *, int));
 
@@ -198,6 +203,22 @@ m68k_reloc_type_lookup (abfd, code)
   /*NOTREACHED*/
 }
 
+STAT_REL reloc_howto_type *
+m68k_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                       const char *r_name)
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < sizeof (m68kcoff_howto_table) / sizeof (m68kcoff_howto_table[0]);
+       i++)
+    if (m68kcoff_howto_table[i].name != NULL
+       && strcasecmp (m68kcoff_howto_table[i].name, r_name) == 0)
+      return &m68kcoff_howto_table[i];
+
+  return NULL;
+}
+
 #endif /* not ONLY_DECLARE_RELOCS */
 
 #define RTYPE2HOWTO(internal, relocentry) \
@@ -207,6 +228,7 @@ m68k_reloc_type_lookup (abfd, code)
   external.r_type = m68k_howto2rtype (internal)
 
 #define coff_bfd_reloc_type_lookup m68k_reloc_type_lookup
+#define coff_bfd_reloc_name_lookup m68k_reloc_name_lookup
 
 #ifndef COFF_COMMON_ADDEND
 #ifndef coff_rtype_to_howto
@@ -230,11 +252,12 @@ m68kcoff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
   arelent relent;
   reloc_howto_type *howto;
 
+  relent.howto = NULL;
   RTYPE2HOWTO (&relent, rel);
 
   howto = relent.howto;
 
-  if (howto->pc_relative)
+  if (howto != NULL && howto->pc_relative)
     *addendp += sec->vma;
 
   return howto;
@@ -390,6 +413,7 @@ m68kcoff_common_addend_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
   arelent relent;
   reloc_howto_type *howto;
 
+  relent.howto = NULL;
   RTYPE2HOWTO (&relent, rel);
 
   howto = relent.howto;
@@ -510,7 +534,7 @@ bfd_m68k_coff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
                  (irel->r_vaddr - datasec->vma + datasec->output_offset), p);
       memset (p + 4, 0, 8);
       if (targetsec != NULL)
-       strncpy (p + 4, targetsec->output_section->name, 8);
+       strncpy ((char *) p + 4, targetsec->output_section->name, 8);
     }
 
   return TRUE;
@@ -521,6 +545,10 @@ bfd_m68k_coff_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
 
 #define coff_relocate_section _bfd_coff_generic_relocate_section
 
+#ifndef bfd_pe_print_pdata
+#define bfd_pe_print_pdata     NULL
+#endif
+
 #include "coffcode.h"
 
 #ifndef TARGET_SYM