Add support for mcore to dlltool.
[deliverable/binutils-gdb.git] / bfd / coff-sparc.c
index e1c3f3d2f80a52bd654958230ffeaf23fd5404ff..bc2cf153843e6b645a2567bd8b36b5183b316a0e 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for Sparc COFF files.
-   Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+   Copyright 1990, 91, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -16,17 +16,21 @@ 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
 #include "libbfd.h"
-#include "obstack.h"
 #include "coff/sparc.h"
 #include "coff/internal.h"
 #include "libcoff.h"
 
-#define BADMAG(x) ((x).f_magic != SPARCMAGIC)
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+
+#define BADMAG(x) ((x).f_magic != SPARCMAGIC && (x).f_magic != LYNXCOFFMAGIC)
+
+/* The page size is a guess based on ELF.  */
+#define COFF_PAGE_SIZE 0x10000
 
 enum reloc_type
   {
@@ -82,8 +86,7 @@ bfd_coff_generic_reloc (abfd, reloc_entry, symbol, data, input_section,
      char **error_message;
 {
   if (output_bfd != (bfd *) NULL
-      && (symbol->flags & BSF_SECTION_SYM) == 0
-      && reloc_entry->addend == 0)
+      && (symbol->flags & BSF_SECTION_SYM) == 0)
     {
       reloc_entry->address += input_section->output_offset;
       return bfd_reloc_ok;
@@ -121,7 +124,7 @@ static reloc_howto_type coff_sparc_howto_table[] =
 };
 
 struct coff_reloc_map {
-  unsigned char bfd_reloc_val;
+  bfd_reloc_code_real_type bfd_reloc_val;
   unsigned char coff_reloc_val;
 };
 
@@ -153,12 +156,12 @@ static CONST struct coff_reloc_map sparc_reloc_map[] =
   /*  { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
 };
 
-static CONST struct reloc_howto_struct *
+static reloc_howto_type *
 coff_sparc_reloc_type_lookup (abfd, code)
      bfd *abfd;
      bfd_reloc_code_real_type code;
 {
-  int i;
+  unsigned int i;
   for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct coff_reloc_map); i++)
     {
       if (sparc_reloc_map[i].bfd_reloc_val == code)
@@ -181,32 +184,25 @@ rtype2howto (cache_ptr, dst)
 
 #define SWAP_IN_RELOC_OFFSET   bfd_h_get_32
 #define SWAP_OUT_RELOC_OFFSET  bfd_h_put_32
-/* This is just like the standard one, except for the addition of the
-   last line, the adjustment of the addend.  */
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr)                \
-  {                                                             \
-    coff_symbol_type *coffsym = (coff_symbol_type *) NULL;      \
-    if (ptr && bfd_asymbol_bfd (ptr) != abfd)                   \
-      coffsym = (obj_symbols (abfd)                             \
-                 + (cache_ptr->sym_ptr_ptr - symbols));         \
-    else if (ptr)                                               \
-      coffsym = coff_symbol_from (abfd, ptr);                   \
-    if (coffsym != (coff_symbol_type *) NULL                    \
-        && coffsym->native->u.syment.n_scnum == 0)              \
-      cache_ptr->addend = 0;                                    \
-    else if (ptr && bfd_asymbol_bfd (ptr) == abfd               \
-             && ptr->section != (asection *) NULL)              \
-      cache_ptr->addend = - (ptr->section->vma + ptr->value);   \
-    else                                                        \
-      cache_ptr->addend = 0;                                    \
-    cache_ptr->addend += reloc.r_offset;                       \
-  }
+#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr) \
+  cache_ptr->addend = reloc.r_offset;
+
+/* Clear the r_spare field in relocs.  */
+#define SWAP_OUT_RELOC_EXTRA(abfd,src,dst) \
+  do { \
+       dst->r_spare[0] = 0; \
+       dst->r_spare[1] = 0; \
+     } while (0)
 
 #define __A_MAGIC_SET__
 
+/* Enable Sparc-specific hacks in coffcode.h. */
+
+#define COFF_SPARC
+
 #include "coffcode.h"
 
-bfd_target
+const bfd_target
 #ifdef TARGET_SYM
   TARGET_SYM =
 #else
@@ -219,19 +215,18 @@ bfd_target
   "coff-sparc",                        /* name */
 #endif
   bfd_target_coff_flavour,
-  true,                        /* data byte order is big */
-  true,                        /* header byte order is big */
+  BFD_ENDIAN_BIG,      /* data byte order is big */
+  BFD_ENDIAN_BIG,      /* header byte order is big */
 
   (HAS_RELOC | EXEC_P |                /* object flags */
    HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
+   HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
 
   (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-  0,                           /* leading underscore */
+  '_',                         /* leading underscore */
   '/',                         /* ar_pad_char */
   15,                          /* ar_max_namelen */
 
-  3,                           /* minimum alignment power */
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
      bfd_getb32, bfd_getb_signed_32, bfd_putb32,
      bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
@@ -259,4 +254,3 @@ bfd_target
 
   COFF_SWAP_TABLE,
 };
-
This page took 0.033097 seconds and 4 git commands to generate.