* srconv.c (wr_tr): Write out handcrafted tr block.
[deliverable/binutils-gdb.git] / bfd / coffcode.h
index 8f4e25e584d99652eff0e6236718b15d7cc0d9e4..14326fbe5313a01562e556833553f84b729bdef8 100644 (file)
@@ -1,5 +1,5 @@
 /* Support for the generic parts of most COFF variants, for BFD.
-   Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+   Copyright 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
 This file is part of BFD, the Binary File Descriptor library.
@@ -298,6 +298,10 @@ CODE_FRAGMENT
 
 */
 
+#ifndef IMAGE_BASE
+#define IMAGE_BASE 0
+#endif
+
 #include "coffswap.h"
 \f
 /* void warning(); */
@@ -359,8 +363,7 @@ sec_to_styp_flags (sec_name, sec_flags)
       styp_flags = STYP_INFO;
 #endif
     }
-  else if (!strcmp (sec_name, ".stab")
-          || !strncmp (sec_name, ".stabstr", 8))
+  else if (!strncmp (sec_name, ".stab", 5))
     {
       styp_flags = STYP_INFO;
     }
@@ -391,7 +394,7 @@ sec_to_styp_flags (sec_name, sec_flags)
     }
 
 #ifdef STYP_NOLOAD
-  if (sec_flags & SEC_NEVER_LOAD)
+  if ((sec_flags & (SEC_NEVER_LOAD | SEC_COFF_SHARED_LIBRARY)) != 0)
     styp_flags |= STYP_NOLOAD;
 #endif
 
@@ -405,9 +408,10 @@ sec_to_styp_flags (sec_name, sec_flags)
  *      in sec_to_styp_flags().
  */
 static flagword
-DEFUN (styp_to_sec_flags, (abfd, hdr),
-       bfd * abfd AND
-       PTR hdr)
+styp_to_sec_flags (abfd, hdr, name)
+     bfd *abfd;
+     PTR hdr;
+     const char *name;
 {
   struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr;
   long styp_flags = internal_s->s_flags;
@@ -425,14 +429,14 @@ DEFUN (styp_to_sec_flags, (abfd, hdr),
   if (styp_flags & STYP_TEXT)
     {
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_CODE | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
       else
        sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
     }
   else if (styp_flags & STYP_DATA)
     {
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_DATA | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
       else
        sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
     }
@@ -440,19 +444,70 @@ DEFUN (styp_to_sec_flags, (abfd, hdr),
     {
 #ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
       if (sec_flags & SEC_NEVER_LOAD)
-       sec_flags |= SEC_ALLOC | SEC_SHARED_LIBRARY;
+       sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
       else
 #endif
        sec_flags |= SEC_ALLOC;
     }
   else if (styp_flags & STYP_INFO)
     {
-      /* This should be marked as SEC_DEBUGGING, but that can't be
-        done until we make sure that strip can still work.  strip
-        will probably have to preserve the same number of sections to
-        ensure that the section vma matches the section file
-        position.  */
+      /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is
+        defined.  coff_compute_section_file_positions uses
+        COFF_PAGE_SIZE to ensure that the low order bits of the
+        section VMA and the file offset match.  If we don't know
+        COFF_PAGE_SIZE, we can't ensure the correct correspondence,
+        and demand page loading of the file will fail.  */
+#ifdef COFF_PAGE_SIZE
+      sec_flags |= SEC_DEBUGGING;
+#endif
+    }
+  else if (strcmp (name, _TEXT) == 0)
+    {
+      if (sec_flags & SEC_NEVER_LOAD)
+       sec_flags |= SEC_CODE | SEC_COFF_SHARED_LIBRARY;
+      else
+       sec_flags |= SEC_CODE | SEC_LOAD | SEC_ALLOC;
+    }
+  else if (strcmp (name, _DATA) == 0
+#ifdef TWO_DATA_SECS
+          || strcmp (name, ".data2") == 0
+#endif
+          )
+    {
+      if (sec_flags & SEC_NEVER_LOAD)
+       sec_flags |= SEC_DATA | SEC_COFF_SHARED_LIBRARY;
+      else
+       sec_flags |= SEC_DATA | SEC_LOAD | SEC_ALLOC;
+    }
+  else if (strcmp (name, _BSS) == 0)
+    {
+#ifdef BSS_NOLOAD_IS_SHARED_LIBRARY
+      if (sec_flags & SEC_NEVER_LOAD)
+       sec_flags |= SEC_ALLOC | SEC_COFF_SHARED_LIBRARY;
+      else
+#endif
+       sec_flags |= SEC_ALLOC;
+    }
+  else if (strcmp (name, ".debug") == 0
+#ifdef _COMMENT
+          || strcmp (name, _COMMENT) == 0
+#endif
+          || strncmp (name, ".stab", 5) == 0)
+    {
+#ifdef COFF_PAGE_SIZE
+      sec_flags |= SEC_DEBUGGING;
+#endif
+    }
+#ifdef _LIB
+  else if (strcmp (name, _LIB) == 0)
+    ;
+#endif
+#ifdef _LIT
+  else if (strcmp (name, _LIT) == 0)
+    {
+      sec_flags = SEC_LOAD | SEC_ALLOC | SEC_READONLY;
     }
+#endif
   else
     {
       sec_flags |= SEC_ALLOC | SEC_LOAD;
@@ -474,7 +529,7 @@ DEFUN (styp_to_sec_flags, (abfd, hdr),
   return (sec_flags);
 }
 
-#define        get_index(symbol)       ((long) (symbol)->udata)
+#define        get_index(symbol)       ((symbol)->udata.i)
 
 /*
 INTERNAL_DEFINITION
@@ -555,6 +610,7 @@ dependent COFF routines:
 . unsigned int _bfd_scnhsz;
 . unsigned int _bfd_symesz;
 . unsigned int _bfd_auxesz;
+. unsigned int _bfd_relsz;
 . unsigned int _bfd_linesz;
 . boolean _bfd_coff_long_filenames;
 . void (*_bfd_coff_swap_filehdr_in) PARAMS ((
@@ -569,6 +625,10 @@ dependent COFF routines:
 .       bfd     *abfd,
 .       PTR     ext,
 .       PTR     in));
+. void (*_bfd_coff_swap_reloc_in) PARAMS ((
+.       bfd     *abfd,
+.       PTR     ext,
+.       PTR     in));
 . boolean (*_bfd_coff_bad_format_hook) PARAMS ((
 .       bfd     *abfd,
 .       PTR     internal_filehdr));
@@ -581,7 +641,8 @@ dependent COFF routines:
 .       PTR     internal_aouthdr));
 . flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((
 .       bfd     *abfd,
-.       PTR     internal_scnhdr));
+.       PTR     internal_scnhdr,
+.       const char *name));
 . asection *(*_bfd_make_section_hook) PARAMS ((
 .       bfd     *abfd,
 .       char    *name));
@@ -603,11 +664,39 @@ dependent COFF routines:
 .       unsigned int *src_ptr,
 .       unsigned int *dst_ptr));
 . int (*_bfd_coff_reloc16_estimate) PARAMS ((
+.       bfd *abfd,
 .       asection *input_section,
-.       asymbol **symbols,
 .       arelent *r,
 .       unsigned int shrink,
 .       struct bfd_link_info *link_info));
+. boolean (*_bfd_coff_sym_is_global) PARAMS ((
+.       bfd *abfd,
+.       struct internal_syment *));
+. void (*_bfd_coff_compute_section_file_positions) PARAMS ((
+.       bfd *abfd));
+. boolean (*_bfd_coff_relocate_section) PARAMS ((
+.       bfd *output_bfd,
+.       struct bfd_link_info *info,
+.       bfd *input_bfd,
+.       asection *input_section,
+.       bfd_byte *contents,
+.       struct internal_reloc *relocs,
+.       struct internal_syment *syms,
+.       asection **sections));
+. reloc_howto_type *(*_bfd_coff_rtype_to_howto) PARAMS ((
+.       bfd *abfd,
+.       asection *sec,
+.       struct internal_reloc *rel,
+.       struct coff_link_hash_entry *h,
+.       struct internal_syment *sym,
+.       bfd_vma *addendp));
+. boolean (*_bfd_coff_adjust_symndx) PARAMS ((
+.       bfd *obfd,
+.       struct bfd_link_info *info,
+.       bfd *ibfd,
+.       asection *sec,
+.       struct internal_reloc *reloc,
+.       boolean *adjustedp));
 .
 .} bfd_coff_backend_data;
 .
@@ -648,6 +737,7 @@ dependent COFF routines:
 .#define bfd_coff_scnhsz(abfd) (coff_backend_info (abfd)->_bfd_scnhsz)
 .#define bfd_coff_symesz(abfd) (coff_backend_info (abfd)->_bfd_symesz)
 .#define bfd_coff_auxesz(abfd) (coff_backend_info (abfd)->_bfd_auxesz)
+.#define bfd_coff_relsz(abfd)  (coff_backend_info (abfd)->_bfd_relsz)
 .#define bfd_coff_linesz(abfd) (coff_backend_info (abfd)->_bfd_linesz)
 .#define bfd_coff_long_filenames(abfd) (coff_backend_info (abfd)->_bfd_coff_long_filenames)
 .#define bfd_coff_swap_filehdr_in(abfd, i,o) \
@@ -659,6 +749,9 @@ dependent COFF routines:
 .#define bfd_coff_swap_scnhdr_in(abfd, i,o) \
 .        ((coff_backend_info (abfd)->_bfd_coff_swap_scnhdr_in) (abfd, i, o))
 .
+.#define bfd_coff_swap_reloc_in(abfd, i, o) \
+.        ((coff_backend_info (abfd)->_bfd_coff_swap_reloc_in) (abfd, i, o))
+.
 .#define bfd_coff_bad_format_hook(abfd, filehdr) \
 .        ((coff_backend_info (abfd)->_bfd_coff_bad_format_hook) (abfd, filehdr))
 .
@@ -667,8 +760,8 @@ dependent COFF routines:
 .#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\
 .        ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr))
 .
-.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr)\
-.        ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr))
+.#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr, name)\
+.        ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr, name))
 .
 .#define bfd_coff_make_section_hook(abfd, name)\
 .        ((coff_backend_info (abfd)->_bfd_make_section_hook) (abfd, name))
@@ -686,18 +779,36 @@ dependent COFF routines:
 .        ((coff_backend_info (abfd)->_bfd_coff_reloc16_extra_cases)\
 .         (abfd, link_info, link_order, reloc, data, src_ptr, dst_ptr))
 .
-.#define bfd_coff_reloc16_estimate(abfd, section, symbols, reloc, shrink, link_info)\
+.#define bfd_coff_reloc16_estimate(abfd, section, reloc, shrink, link_info)\
 .        ((coff_backend_info (abfd)->_bfd_coff_reloc16_estimate)\
-.         (section, symbols, reloc, shrink, link_info))
+.         (abfd, section, reloc, shrink, link_info))
+.
+.#define bfd_coff_sym_is_global(abfd, sym)\
+.        ((coff_backend_info (abfd)->_bfd_coff_sym_is_global)\
+.         (abfd, sym))
+.
+.#define bfd_coff_compute_section_file_positions(abfd)\
+.        ((coff_backend_info (abfd)->_bfd_coff_compute_section_file_positions)\
+.         (abfd))
+.
+.#define bfd_coff_relocate_section(obfd,info,ibfd,o,con,rel,isyms,secs)\
+.        ((coff_backend_info (ibfd)->_bfd_coff_relocate_section)\
+.         (obfd, info, ibfd, o, con, rel, isyms, secs))
+.#define bfd_coff_rtype_to_howto(abfd, sec, rel, h, sym, addendp)\
+.        ((coff_backend_info (abfd)->_bfd_coff_rtype_to_howto)\
+.         (abfd, sec, rel, h, sym, addendp))
+.#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\
+.        ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\
+.         (obfd, info, ibfd, sec, rel, adjustedp))
 .
 */
 
 /* See whether the magic number matches.  */
 
 static boolean
-DEFUN (coff_bad_format_hook, (abfd, filehdr),
-       bfd * abfd AND
-       PTR filehdr)
+coff_bad_format_hook (abfd, filehdr)
+     bfd * abfd;
+     PTR filehdr;
 {
   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
 
@@ -722,9 +833,9 @@ DEFUN (coff_bad_format_hook, (abfd, filehdr),
 }
 
 static asection *
-DEFUN (coff_make_section_hook, (abfd, name),
-       bfd * abfd AND
-       char *name)
+coff_make_section_hook (abfd, name)
+     bfd * abfd;
+     char *name;
 {
 #ifdef TWO_DATA_SECS
   /* FIXME: This predates the call to bfd_make_section_anyway
@@ -743,11 +854,12 @@ DEFUN (coff_make_section_hook, (abfd, name),
 */
 
 static boolean
-DEFUN (coff_new_section_hook, (abfd, section),
-       bfd * abfd AND
-       asection * section)
+coff_new_section_hook (abfd, section)
+     bfd * abfd;
+     asection * section;
 {
-  section->alignment_power = abfd->xvec->align_power_min;
+  section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER;
+
   /* Allocate aux records for section symbols, to store size and
      related info.
 
@@ -755,19 +867,29 @@ DEFUN (coff_new_section_hook, (abfd, section),
   coffsymbol (section->symbol)->native =
     (combined_entry_type *) bfd_zalloc (abfd,
                                        sizeof (combined_entry_type) * 10);
+
+  /* The .stab section must be aligned to 2**2 at most, because
+     otherwise there may be gaps in the section which gdb will not
+     know how to interpret.  Examining the section name is a hack, but
+     that is also how gdb locates the section.  We also align the
+     .stabstr section this way for backward compatibility, although I
+     believe it would work anyhow.  */
+  if (COFF_DEFAULT_SECTION_ALIGNMENT_POWER > 2
+      && (strncmp (section->name, ".stab", 5) == 0))
+    section->alignment_power = 2;
+
   return true;
 }
 
-
 #ifdef I960
 
 /* Set the alignment of a BFD section.  */
 
 static void
-DEFUN (coff_set_alignment_hook, (abfd, section, scnhdr),
-       bfd * abfd AND
-       asection * section AND
-       PTR scnhdr)
+coff_set_alignment_hook (abfd, section, scnhdr)
+     bfd * abfd;
+     asection * section;
+     PTR scnhdr;
 {
   struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr;
   unsigned int i;
@@ -786,34 +908,37 @@ DEFUN (coff_set_alignment_hook, (abfd, section, scnhdr),
 #endif /* ! I960 */
 
 static boolean
-DEFUN (coff_mkobject, (abfd),
-       bfd * abfd)
+coff_mkobject (abfd)
+     bfd * abfd;
 {
   coff_data_type *coff;
 
   abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, sizeof (coff_data_type));
   if (abfd->tdata.coff_obj_data == 0)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   coff = coff_data (abfd);
   coff->symbols = (coff_symbol_type *) NULL;
   coff->conversion_table = (unsigned int *) NULL;
   coff->raw_syments = (struct coff_ptr_struct *) NULL;
-  coff->raw_linenos = (struct lineno *) NULL;
   coff->relocbase = 0;
 /*  make_abs_section(abfd);*/
+
+#ifdef COFF_WITH_PE
+  obj_pe (abfd) = 1;
+#endif
   return true;
 }
 
 /* Create the COFF backend specific information.  */
 
 static PTR
-DEFUN (coff_mkobject_hook, (abfd, filehdr, aouthdr),
-       bfd * abfd AND
-       PTR filehdr AND
-       PTR aouthdr)
+coff_mkobject_hook (abfd, filehdr, aouthdr)
+     bfd * abfd;
+     PTR filehdr;
+     PTR aouthdr;
 {
   struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr;
   coff_data_type *coff;
@@ -824,7 +949,6 @@ DEFUN (coff_mkobject_hook, (abfd, filehdr, aouthdr),
   coff = coff_data (abfd);
 
   coff->sym_filepos = internal_f->f_symptr;
-  coff->flags = internal_f->f_flags;
 
   /* These members communicate important constants about the symbol
      table to GDB's symbol-reading code.  These `constants'
@@ -837,6 +961,10 @@ DEFUN (coff_mkobject_hook, (abfd, filehdr, aouthdr),
   coff->local_auxesz = AUXESZ;
   coff->local_linesz = LINESZ;
 
+  obj_raw_syment_count (abfd) =
+    obj_conv_table_size (abfd) =
+      internal_f->f_nsyms;
+
   return (PTR) coff;
 }
 
@@ -868,7 +996,6 @@ coff_set_arch_mach_hook (abfd, filehdr)
       machine = 0;
       break;
 #endif
-
 #ifdef A29K_MAGIC_BIG
     case A29K_MAGIC_BIG:
     case A29K_MAGIC_LITTLE:
@@ -876,7 +1003,12 @@ coff_set_arch_mach_hook (abfd, filehdr)
       machine = 0;
       break;
 #endif
-
+#ifdef ARMMAGIC
+    case ARMMAGIC:
+      arch = bfd_arch_arm;
+      machine =0;
+      break;
+#endif
 #ifdef MC68MAGIC
     case MC68MAGIC:
     case M68MAGIC:
@@ -943,6 +1075,11 @@ coff_set_arch_mach_hook (abfd, filehdr)
        case F_I960KA:
          machine = bfd_mach_i960_ka_sa;
          break;
+         /* start-sanitize-i960xl */
+       case F_I960XL:
+         machine = bfd_mach_i960_xl;
+         break;
+         /* end-sanitize-i960xl */
        }
       break;
 #endif
@@ -982,8 +1119,9 @@ coff_set_arch_mach_hook (abfd, filehdr)
       break;
 #endif
 
-#ifdef SHMAGIC
-    case SHMAGIC:
+#ifdef SH_ARCH_MAGIC_BIG
+    case SH_ARCH_MAGIC_BIG:
+    case SH_ARCH_MAGIC_LITTLE:
       arch = bfd_arch_sh;
       machine = 0;
       break;
@@ -998,6 +1136,9 @@ coff_set_arch_mach_hook (abfd, filehdr)
 
 #ifdef SPARCMAGIC
     case SPARCMAGIC:
+#ifdef LYNXCOFFMAGIC
+    case LYNXCOFFMAGIC:
+#endif
       arch = bfd_arch_sparc;
       machine = 0;
       break;
@@ -1015,9 +1156,9 @@ coff_set_arch_mach_hook (abfd, filehdr)
 #ifdef SYMNAME_IN_DEBUG
 
 static boolean
-DEFUN (symname_in_debug_hook, (abfd, sym),
-       bfd * abfd AND
-       struct internal_syment *sym)
+symname_in_debug_hook (abfd, sym)
+     bfd * abfd;
+     struct internal_syment *sym;
 {
   return SYMNAME_IN_DEBUG (sym) ? true : false;
 }
@@ -1045,9 +1186,10 @@ SUBSUBSECTION
 
 */
 
-static void
-DEFUN (coff_write_relocs, (abfd),
-       bfd * abfd)
+static boolean
+coff_write_relocs (abfd, first_undef)
+     bfd * abfd;
+     int first_undef;
 {
   asection *s;
   for (s = abfd->sections; s != (asection *) NULL; s = s->next)
@@ -1056,38 +1198,65 @@ DEFUN (coff_write_relocs, (abfd),
       struct external_reloc dst;
 
       arelent **p = s->orelocation;
-      bfd_seek (abfd, s->rel_filepos, SEEK_SET);
+      if (bfd_seek (abfd, s->rel_filepos, SEEK_SET) != 0)
+       return false;
       for (i = 0; i < s->reloc_count; i++)
        {
          struct internal_reloc n;
          arelent *q = p[i];
          memset ((PTR) & n, 0, sizeof (n));
 
+         /* Now we've renumbered the symbols we know where the
+            undefined symbols live in the table.  Check the reloc
+            entries for symbols who's output bfd isn't the right one.
+            This is because the symbol was undefined (which means
+            that all the pointers are never made to point to the same
+            place). This is a bad thing,'cause the symbols attached
+            to the output bfd are indexed, so that the relocation
+            entries know which symbol index they point to.  So we
+            have to look up the output symbol here. */
+
+         if (q->sym_ptr_ptr[0]->the_bfd != abfd)
+           {
+             int i;
+             const char *sname = q->sym_ptr_ptr[0]->name;
+             asymbol **outsyms = abfd->outsymbols;
+             for (i = first_undef; outsyms[i]; i++)
+               {
+                 const char *intable = outsyms[i]->name;
+                 if (strcmp (intable, sname) == 0) {
+                   /* got a hit, so repoint the reloc */
+                   q->sym_ptr_ptr = outsyms + i;
+                   break;
+                 }
+               }
+           }
+
          n.r_vaddr = q->address + s->vma;
 
 #ifdef R_IHCONST
          /* The 29k const/consth reloc pair is a real kludge.  The consth
-        part doesn't have a symbol; it has an offset.  So rebuilt
-        that here.  */
+            part doesn't have a symbol; it has an offset.  So rebuilt
+            that here.  */
          if (q->howto->type == R_IHCONST)
            n.r_symndx = q->addend;
          else
 #endif
-         if (q->sym_ptr_ptr)
-           {
-             if (q->sym_ptr_ptr == bfd_abs_section.symbol_ptr_ptr)
-               /* This is a relocation relative to the absolute symbol.  */
-               n.r_symndx = -1;
-             else
-               {
-                 n.r_symndx = get_index ((*(q->sym_ptr_ptr)));
-                 /* Take notice if the symbol reloc points to a symbol
-                  we don't have in our symbol table.  What should we
-                  do for this??  */
-                 if (n.r_symndx > obj_conv_table_size (abfd))
-                   abort ();
-               }
-           }
+           if (q->sym_ptr_ptr)
+             {
+               if (q->sym_ptr_ptr == bfd_abs_section_ptr->symbol_ptr_ptr)
+                 /* This is a relocation relative to the absolute symbol.  */
+                 n.r_symndx = -1;
+               else
+                 {
+                   n.r_symndx = get_index ((*(q->sym_ptr_ptr)));
+                   /* Take notice if the symbol reloc points to a symbol
+                      we don't have in our symbol table.  What should we
+                      do for this??  */
+                   if (n.r_symndx > obj_conv_table_size (abfd))
+                     abort ();
+                 }
+             }
 
 #ifdef SWAP_OUT_RELOC_OFFSET
          n.r_offset = q->addend;
@@ -1100,19 +1269,22 @@ DEFUN (coff_write_relocs, (abfd),
          n.r_type = q->howto->type;
 #endif
          coff_swap_reloc_out (abfd, &n, &dst);
-         bfd_write ((PTR) & dst, 1, RELSZ, abfd);
+         if (bfd_write ((PTR) & dst, 1, RELSZ, abfd) != RELSZ)
+           return false;
        }
     }
+
+  return true;
 }
 
 /* Set flags and magic number of a coff file from architecture and machine
    type.  Result is true if we can represent the arch&type, false if not.  */
 
 static boolean
-DEFUN (coff_set_flags, (abfd, magicp, flagsp),
-       bfd * abfd AND
-       unsigned *magicp AND
-       unsigned short *flagsp)
+coff_set_flags (abfd, magicp, flagsp)
+     bfd * abfd;
+     unsigned *magicp;
+     unsigned short *flagsp;
 {
   switch (bfd_get_arch (abfd))
     {
@@ -1163,6 +1335,11 @@ DEFUN (coff_set_flags, (abfd, magicp, flagsp),
          case bfd_mach_i960_ka_sa:
            flags = F_I960KA;
            break;
+           /* start-sanitize-i960xl */
+         case bfd_mach_i960_xl:
+           flags = F_I960XL;
+           break;
+           /* end-sanitize-i960xl */
          default:
            return false;
          }
@@ -1171,6 +1348,11 @@ DEFUN (coff_set_flags, (abfd, magicp, flagsp),
       }
       break;
 #endif
+#ifdef ARMMAGIC
+    case bfd_arch_arm:
+      *magicp = ARMMAGIC;
+      return true;
+#endif
 #ifdef I386MAGIC
     case bfd_arch_i386:
       *magicp = I386MAGIC;
@@ -1216,9 +1398,12 @@ DEFUN (coff_set_flags, (abfd, magicp, flagsp),
       break;
 #endif
 
-#ifdef SHMAGIC
+#ifdef SH_ARCH_MAGIC_BIG
     case bfd_arch_sh:
-      *magicp = SHMAGIC;
+      if (abfd->xvec->byteorder_big_p)
+       *magicp = SH_ARCH_MAGIC_BIG;
+      else
+       *magicp = SH_ARCH_MAGIC_LITTLE;
       return true;
       break;
 #endif
@@ -1259,6 +1444,7 @@ DEFUN (coff_set_flags, (abfd, magicp, flagsp),
 
 #ifdef U802TOCMAGIC
     case bfd_arch_rs6000:
+    case bfd_arch_powerpc:
       *magicp = U802TOCMAGIC;
       return true;
       break;
@@ -1275,18 +1461,21 @@ DEFUN (coff_set_flags, (abfd, magicp, flagsp),
 
 
 static boolean
-DEFUN (coff_set_arch_mach, (abfd, arch, machine),
-       bfd * abfd AND
-       enum bfd_architecture arch AND
-       unsigned long machine)
+coff_set_arch_mach (abfd, arch, machine)
+     bfd * abfd;
+     enum bfd_architecture arch;
+     unsigned long machine;
 {
   unsigned dummy1;
   unsigned short dummy2;
-  bfd_default_set_arch_mach (abfd, arch, machine);
+
+  if (! bfd_default_set_arch_mach (abfd, arch, machine))
+    return false;
 
   if (arch != bfd_arch_unknown &&
       coff_set_flags (abfd, &dummy1, &dummy2) != true)
     return false;              /* We can't represent this type */
+
   return true;                 /* We're easy ... */
 }
 
@@ -1294,8 +1483,8 @@ DEFUN (coff_set_arch_mach, (abfd, arch, machine),
 /* Calculate the file position for each section. */
 
 static void
-DEFUN (coff_compute_section_file_positions, (abfd),
-       bfd * abfd)
+coff_compute_section_file_positions (abfd)
+     bfd * abfd;
 {
   asection *current;
   asection *previous = (asection *) NULL;
@@ -1303,6 +1492,8 @@ DEFUN (coff_compute_section_file_positions, (abfd),
 #ifndef I960
   file_ptr old_sofar;
 #endif
+  unsigned int count;
+
   if (bfd_get_start_address (abfd))
     {
       /*  A start address may have been added to the original file. In this
@@ -1314,15 +1505,26 @@ DEFUN (coff_compute_section_file_positions, (abfd),
     sofar += AOUTSZ;
 
   sofar += abfd->section_count * SCNHSZ;
-  for (current = abfd->sections;
+  for (current = abfd->sections, count = 1;
        current != (asection *) NULL;
-       current = current->next)
+       current = current->next, ++count)
     {
+      current->target_index = count;
 
       /* Only deal with sections which have contents */
       if (!(current->flags & SEC_HAS_CONTENTS))
        continue;
 
+#ifdef COFF_WITH_PE
+      /* Do not include the .junk section.  This is where we collect section
+         data which we don't need.  This is mainly the MS .debug$ data which
+         stores codeview debug data. */
+      if (strcmp (current->name, ".junk") == 0)
+        {
+         continue;
+        }
+#endif
+
       /* Align the sections in the file to the same boundary on
         which they are aligned in virtual memory.  I960 doesn't
         do this (FIXME) so we can stay in sync with Intel.  960
@@ -1341,10 +1543,14 @@ DEFUN (coff_compute_section_file_positions, (abfd),
       }
 
 #endif
-      /* FIXME, in demand paged files, the low order bits of the file
-        offset must match the low order bits of the virtual address.
-        "Low order" is apparently implementation defined.  Add code
-        here to round sofar up to match the virtual address.  */
+
+#ifdef COFF_PAGE_SIZE
+      /* In demand paged files the low order bits of the file offset
+        must match the low order bits of the virtual address.  */
+      if ((abfd->flags & D_PAGED) != 0
+         && (current->flags & SEC_ALLOC) != 0)
+       sofar += (current->vma - sofar) % COFF_PAGE_SIZE;
+#endif
 
       current->filepos = sofar;
 
@@ -1366,7 +1572,17 @@ DEFUN (coff_compute_section_file_positions, (abfd),
 
       previous = current;
     }
+#ifdef COFF_WITH_PE
+  /* Normally, the starting location for the symbol table will be at the end
+     of the last section.  However, when dealing with NT, the last section
+     must be as long as its size rounded up to the next page (0x1000). */
+  sofar = ((sofar + NT_FILE_ALIGNMENT - 1) /
+                           NT_FILE_ALIGNMENT) * NT_FILE_ALIGNMENT; 
+#endif
+
   obj_relocbase (abfd) = sofar;
+  abfd->output_has_begun = true;
+
 }
 
 #ifndef RS6000COFF_C
@@ -1422,7 +1638,7 @@ coff_add_missing_symbols (abfd)
   sympp2 = (asymbol **) bfd_alloc_by_size_t (abfd, nsyms * sizeof (asymbol *));
   if (!sympp2)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   memcpy (sympp2, sympp, i * sizeof (asymbol *));
@@ -1444,82 +1660,63 @@ coff_add_missing_symbols (abfd)
 
 #endif /* ! defined (RS6000COFF_C) */
 
+#ifdef COFF_WITH_PE
+static void add_data_entry (abfd, aout, idx, name)
+     bfd *abfd;
+     struct internal_aouthdr *aout;
+     int idx;
+     char *name;
+{
+  asection *sec = bfd_get_section_by_name (abfd, name);
+
+  /* add import directory information if it exists */
+  if (sec != NULL)
+    {
+      aout->DataDirectory[idx].VirtualAddress = sec->lma - NT_IMAGE_BASE;
+      aout->DataDirectory[idx].Size = sec->_raw_size;
+    }
+}
+#endif
+
 /* SUPPRESS 558 */
 /* SUPPRESS 529 */
 static boolean
-DEFUN (coff_write_object_contents, (abfd),
-       bfd * abfd)
+coff_write_object_contents (abfd)
+     bfd * abfd;
 {
   asection *current;
-  unsigned int count;
-
   boolean hasrelocs = false;
   boolean haslinno = false;
   file_ptr reloc_base;
   file_ptr lineno_base;
   file_ptr sym_base;
-  file_ptr scn_base;
-  file_ptr data_base;
   unsigned long reloc_size = 0;
   unsigned long lnno_size = 0;
   asection *text_sec = NULL;
   asection *data_sec = NULL;
   asection *bss_sec = NULL;
+  bfd_vma end_of_image = 0;
 
   struct internal_filehdr internal_f;
   struct internal_aouthdr internal_a;
 
-
-  bfd_error = system_call_error;
-  /* Number the output sections, starting from one on the first section
-     with a name which doesn't start with a *.
-     @@ The code doesn't make this check.  Is it supposed to be done,
-     or isn't it??  */
-  count = 1;
-  for (current = abfd->sections; current != (asection *) NULL;
-       current = current->next)
-    {
-      current->target_index = count;
-      count++;
-    }
+  bfd_set_error (bfd_error_system_call);
 
   if (abfd->output_has_begun == false)
-    {
-      coff_compute_section_file_positions (abfd);
-    }
+    coff_compute_section_file_positions (abfd);
 
-  if (abfd->sections != (asection *) NULL)
-    {
-      scn_base = abfd->sections->filepos;
-    }
-  else
-    {
-      scn_base = 0;
-    }
-  if (bfd_seek (abfd, scn_base, SEEK_SET) != 0)
-    return false;
   reloc_base = obj_relocbase (abfd);
 
   /* Make a pass through the symbol table to count line number entries and
      put them into the correct asections */
 
   lnno_size = coff_count_linenumbers (abfd) * LINESZ;
-  data_base = scn_base;
 
   /* Work out the size of the reloc and linno areas */
 
   for (current = abfd->sections; current != NULL; current =
        current->next)
-    {
-      /* We give section headers to +ve indexes */
-      if (current->target_index > 0)
-       {
-
-         reloc_size += current->reloc_count * RELSZ;
-         data_base += SCNHSZ;
-       }
-
-    }
+    reloc_size += current->reloc_count * RELSZ;
 
   lineno_base = reloc_base + reloc_size;
   sym_base = lineno_base + lnno_size;
@@ -1528,124 +1725,152 @@ DEFUN (coff_write_object_contents, (abfd),
   for (current = abfd->sections; current != NULL; current =
        current->next)
     {
-      if (current->target_index > 0)
+      if (current->lineno_count)
        {
-
-         if (current->lineno_count)
-           {
-             current->line_filepos = lineno_base;
-             current->moving_line_filepos = lineno_base;
-             lineno_base += current->lineno_count * LINESZ;
-           }
-         else
-           {
-             current->line_filepos = 0;
-           }
-         if (current->reloc_count)
-           {
-             current->rel_filepos = reloc_base;
-             reloc_base += current->reloc_count * RELSZ;
-           }
-         else
-           {
-             current->rel_filepos = 0;
-           }
+         current->line_filepos = lineno_base;
+         current->moving_line_filepos = lineno_base;
+         lineno_base += current->lineno_count * LINESZ;
+       }
+      else
+       {
+         current->line_filepos = 0;
+       }
+      if (current->reloc_count)
+       {
+         current->rel_filepos = reloc_base;
+         reloc_base += current->reloc_count * RELSZ;
+       }
+      else
+       {
+         current->rel_filepos = 0;
        }
     }
 
-
-
   /* Write section headers to the file.  */
   internal_f.f_nscns = 0;
-  bfd_seek (abfd,
-           (file_ptr) ((abfd->flags & EXEC_P) ?
-                       (FILHSZ + AOUTSZ) : FILHSZ),
-           SEEK_SET);
 
-  {
-#if 0
-    unsigned int pad = abfd->flags & D_PAGED ? data_base : 0;
+#if 0 
+  if (bfd_seek (abfd,
+               (file_ptr) ((abfd->flags & EXEC_P) ?
+                           (EXTRA_NT_HDRSZ + FILHSZ + AOUTSZ) : 
+                            (EXTRA_NT_HDRSZ + FILHSZ)),
+               SEEK_SET)
+      != 0)
+#else
+    if (bfd_seek (abfd,
+                 (file_ptr) ((abfd->flags & EXEC_P) ?
+                             (FILHSZ + AOUTSZ) : FILHSZ),
+                 SEEK_SET)
+       != 0)
 #endif
-    unsigned int pad = 0;
+      return false;
 
+  {
     for (current = abfd->sections;
         current != NULL;
         current = current->next)
       {
        struct internal_scnhdr section;
-       if (current->target_index > 0)
-         {
-           internal_f.f_nscns++;
-           strncpy (&(section.s_name[0]), current->name, 8);
+
+#ifdef COFF_WITH_PE
+        /* Do not include the .junk section.  This is where we collect section
+           data which we don't need.  This is mainly the MS .debug$ data which
+           stores codeview debug data. */
+        if (strcmp (current->name, ".junk") == 0)
+          {
+           continue;
+          }
+#endif
+       internal_f.f_nscns++;
+       strncpy (&(section.s_name[0]), current->name, 8);
 #ifdef _LIB
-           /* Always set s_vaddr of .lib to 0.  This is right for SVR3.2
+       /* Always set s_vaddr of .lib to 0.  This is right for SVR3.2
           Ian Taylor <ian@cygnus.com>.  */
-           if (strcmp (current->name, _LIB) == 0)
-             section.s_vaddr = 0;
-           else
-#endif
-             section.s_vaddr = current->lma + pad;
-           section.s_paddr = current->lma + pad;
-           section.s_size = current->_raw_size - pad;
-           /*
-         If this section has no size or is unloadable then the scnptr
-         will be 0 too
-         */
-           if (current->_raw_size - pad == 0 ||
-               (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
-             {
-               section.s_scnptr = 0;
-             }
-           else
-             {
-               section.s_scnptr = current->filepos;
-             }
-           section.s_relptr = current->rel_filepos;
-           section.s_lnnoptr = current->line_filepos;
-           section.s_nreloc = current->reloc_count;
-           section.s_nlnno = current->lineno_count;
-           if (current->reloc_count != 0)
-             hasrelocs = true;
-           if (current->lineno_count != 0)
-             haslinno = true;
-
-           section.s_flags = sec_to_styp_flags (current->name, current->flags);
-
-           if (!strcmp (current->name, _TEXT))
-             {
-               text_sec = current;
-             }
-           else if (!strcmp (current->name, _DATA))
-             {
-               data_sec = current;
+       if (strcmp (current->name, _LIB) == 0)
+         section.s_vaddr = 0;
+       else
+#endif
+         section.s_vaddr = current->lma;
+       section.s_paddr = current->lma;
+       section.s_size = current->_raw_size;
+
+        /* Remember the address of the end of the last section */
+
+       if (current->lma + current->_raw_size > end_of_image)
+         end_of_image = current->lma + current->_raw_size ;
+
+       /*
+          If this section has no size or is unloadable then the scnptr
+          will be 0 too
+          */
+       if (current->_raw_size == 0 ||
+           (current->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
+         {
+           section.s_scnptr = 0;
+         }
+       else
+         {
+           section.s_scnptr = current->filepos;
+         }
+       section.s_relptr = current->rel_filepos;
+       section.s_lnnoptr = current->line_filepos;
+       section.s_nreloc = current->reloc_count;
+       section.s_nlnno = current->lineno_count;
+       if (current->reloc_count != 0)
+         hasrelocs = true;
+       if (current->lineno_count != 0)
+         haslinno = true;
+
+       section.s_flags = sec_to_styp_flags (current->name, current->flags);
+
+       if (!strcmp (current->name, _TEXT))
+         {
+           text_sec = current;
+         }
+       else if (!strcmp (current->name, _DATA))
+         {
+           data_sec = current;
 #ifdef TWO_DATA_SECS
-             }
-           else if (!strcmp (current->name, ".data2"))
-             {
-               data_sec = current;
+         }
+       else if (!strcmp (current->name, ".data2"))
+         {
+           data_sec = current;
 #endif /* TWO_DATA_SECS */
-             }
-           else if (!strcmp (current->name, _BSS))
-             {
-               bss_sec = current;
-             }
+         }
+       else if (!strcmp (current->name, _BSS))
+         {
+           bss_sec = current;
+         }
 
 #ifdef I960
-           section.s_align = (current->alignment_power
-                              ? 1 << current->alignment_power
-                              : 0);
+       section.s_align = (current->alignment_power
+                          ? 1 << current->alignment_power
+                          : 0);
 
 #endif
-           {
-             SCNHDR buff;
-
+       {
+         SCNHDR buff;
+
+#ifdef WINDOWS_NT
+         /* suppress output of the sections if they are null.  ld includes
+            the bss and data sections even if there is no size assigned
+            to them.  NT loader doesn't like it if these section headers are
+            included if the sections themselves are not needed */
+         if (section.s_size == 0)
+           internal_f.f_nscns--;
+         else
+           { 
              coff_swap_scnhdr_out (abfd, &section, &buff);
-             bfd_write ((PTR) (&buff), 1, SCNHSZ, abfd);
-
-           }
+             if (bfd_write ((PTR) (&buff), 1, SCNHSZ, abfd) != SCNHSZ)
+               return false;
+            }
+#else
+         if (coff_swap_scnhdr_out (abfd, &section, &buff) == 0
+             || bfd_write ((PTR) (&buff), 1, SCNHSZ, abfd) != SCNHSZ)
+           return false;
+#endif
 
-           pad = 0;
-         }
+       }
       }
   }
 
@@ -1655,18 +1880,13 @@ DEFUN (coff_write_object_contents, (abfd),
   /* Don't include the internal abs section in the section count */
 
   /*
-    We will NOT put a fucking timestamp in the header here. Every time you
-    put it back, I will come in and take it out again.  I'm sorry.  This
-    field does not belong here.  We fill it with a 0 so it compares the
-    same but is not a reasonable time. -- gnu@cygnus.com
-    */
+     We will NOT put a fucking timestamp in the header here. Every time you
+     put it back, I will come in and take it out again.  I'm sorry.  This
+     field does not belong here.  We fill it with a 0 so it compares the
+     same but is not a reasonable time. -- gnu@cygnus.com
+     */
   internal_f.f_timdat = 0;
 
-  if (bfd_get_symcount (abfd) != 0)
-    internal_f.f_symptr = sym_base;
-  else
-    internal_f.f_symptr = 0;
-
   internal_f.f_flags = 0;
 
   if (abfd->flags & EXEC_P)
@@ -1678,8 +1898,6 @@ DEFUN (coff_write_object_contents, (abfd),
     internal_f.f_flags |= F_RELFLG;
   if (!haslinno)
     internal_f.f_flags |= F_LNNO;
-  if (0 == bfd_get_symcount (abfd))
-    internal_f.f_flags |= F_LSYMS;
   if (abfd->flags & EXEC_P)
     internal_f.f_flags |= F_EXEC;
 
@@ -1688,10 +1906,62 @@ DEFUN (coff_write_object_contents, (abfd),
   else
     internal_f.f_flags |= F_AR32W;
 
+#ifdef COFF_WITH_PE
+  /* assign other filehdr fields for DOS header and NT signature */
+  internal_f.e_magic    = DOSMAGIC;
+  internal_f.e_cblp     = 0x90;
+  internal_f.e_cp       = 0x3;
+  internal_f.e_crlc     = 0x0;
+  internal_f.e_cparhdr  = 0x4;
+  internal_f.e_minalloc = 0x0;
+  internal_f.e_maxalloc = 0xffff;
+  internal_f.e_ss       = 0x0;
+  internal_f.e_sp       = 0xb8;
+  internal_f.e_csum     = 0x0;
+  internal_f.e_ip       = 0x0;
+  internal_f.e_cs       = 0x0;
+  internal_f.e_lfarlc   = 0x40;
+  internal_f.e_ovno     = 0x0;
+  {
+    int idx;
+    for (idx=0; idx < 4; idx++)
+      internal_f.e_res[idx] = 0x0;
+  }
+  internal_f.e_oemid   = 0x0;
+  internal_f.e_oeminfo = 0x0;
+  {
+    int idx;
+    for (idx=0; idx < 10; idx++)
+      internal_f.e_res2[idx] = 0x0;
+  }
+  internal_f.e_lfanew = 0x80;
+
+  /* this next collection of data are mostly just characters.  It appears
+     to be constant within the headers put on NT exes */
+  internal_f.dos_message[0]  = 0x0eba1f0e;
+  internal_f.dos_message[1]  = 0xcd09b400;
+  internal_f.dos_message[2]  = 0x4c01b821;
+  internal_f.dos_message[3]  = 0x685421cd;
+  internal_f.dos_message[4]  = 0x70207369;
+  internal_f.dos_message[5]  = 0x72676f72;
+  internal_f.dos_message[6]  = 0x63206d61;
+  internal_f.dos_message[7]  = 0x6f6e6e61;
+  internal_f.dos_message[8]  = 0x65622074;
+  internal_f.dos_message[9]  = 0x6e757220;
+  internal_f.dos_message[10] = 0x206e6920;
+  internal_f.dos_message[11] = 0x20534f44;
+  internal_f.dos_message[12] = 0x65646f6d;
+  internal_f.dos_message[13] = 0x0a0d0d2e;
+  internal_f.dos_message[14] = 0x24;
+  internal_f.dos_message[15] = 0x0;
+  internal_f.nt_signature = NT_SIGNATURE;
+#endif
+
+
   /*
-    FIXME, should do something about the other byte orders and
-    architectures.
-    */
+     FIXME, should do something about the other byte orders and
+     architectures.
+     */
 
   memset (&internal_a, 0, sizeof internal_a);
 
@@ -1708,14 +1978,14 @@ DEFUN (coff_write_object_contents, (abfd),
 #ifdef A29K
 #ifdef ULTRA3                  /* NYU's machine */
     /* FIXME: This is a bogus check.  I really want to see if there
-   * is a .shbss or a .shdata section, if so then set the magic
-   * number to indicate a shared data executable.
-   */
+     * is a .shbss or a .shdata section, if so then set the magic
+     * number to indicate a shared data executable.
+     */
     if (internal_f.f_nscns >= 7)
-      internal_a.magic = SHMAGIC;      /* Shared magic */
+      internal_a.magic = SHMAGIC; /* Shared magic */
     else
 #endif /* ULTRA3 */
-      internal_a.magic = NMAGIC;/* Assume separate i/d */
+      internal_a.magic = NMAGIC; /* Assume separate i/d */
 #define __A_MAGIC_SET__
 #endif /* A29K */
 #ifdef I960
@@ -1732,21 +2002,38 @@ DEFUN (coff_write_object_contents, (abfd),
     internal_a.magic = APOLLO_COFF_VERSION_NUMBER;
 #endif
 
-#if M68 || WE32K
+#if defined(M68) || defined(WE32K) || defined(M68K)
 #define __A_MAGIC_SET__
-    /* Never was anything here for the 68k */
-#endif /* M68 || WE32K */
+#if defined(LYNXOS)
+    internal_a.magic = LYNXCOFFMAGIC;
+#endif /* LYNXOS */
+#endif /* M68 || WE32K || M68K */
 
-#if I386
+#if defined(ARM)
 #define __A_MAGIC_SET__
     internal_a.magic = ZMAGIC;
+#endif 
+#if defined(I386)
+#define __A_MAGIC_SET__
+#if defined(LYNXOS)
+    internal_a.magic = LYNXCOFFMAGIC;
+#else  /* LYNXOS */
+    internal_a.magic = ZMAGIC;
+#endif /* LYNXOS */
 #endif /* I386 */
 
+#if defined(SPARC)
+#define __A_MAGIC_SET__
+#if defined(LYNXOS)
+    internal_a.magic = LYNXCOFFMAGIC;
+#endif /* LYNXOS */
+#endif /* SPARC */
+
 #if RS6000COFF_C
 #define __A_MAGIC_SET__
     internal_a.magic = (abfd->flags & D_PAGED) ? RS6K_AOUTHDR_ZMAGIC :
-      (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC :
-      RS6K_AOUTHDR_OMAGIC;
+    (abfd->flags & WP_TEXT) ? RS6K_AOUTHDR_NMAGIC :
+    RS6K_AOUTHDR_OMAGIC;
 #endif
 
 #ifndef __A_MAGIC_SET__
@@ -1760,35 +2047,157 @@ DEFUN (coff_write_object_contents, (abfd),
 
   if (bfd_get_symcount (abfd) != 0)
     {
+      int firstundef;
 #ifndef RS6000COFF_C
       if (!coff_add_missing_symbols (abfd))
        return false;
 #endif
-      if (!coff_renumber_symbols (abfd))
+      if (!coff_renumber_symbols (abfd, &firstundef))
        return false;
       coff_mangle_symbols (abfd);
-      coff_write_symbols (abfd);
-      if (!coff_write_linenumbers (abfd))
+      if (! coff_write_symbols (abfd))
+       return false;
+      if (! coff_write_linenumbers (abfd))
        return false;
-      coff_write_relocs (abfd);
+      if (! coff_write_relocs (abfd, firstundef))
+       return false;
+    }
+
+  /* If bfd_get_symcount (abfd) != 0, then we are not using the COFF
+     backend linker, and obj_raw_syment_count is not valid until after
+     coff_write_symbols is called.  */
+  if (obj_raw_syment_count (abfd) != 0)
+    internal_f.f_symptr = sym_base;
+  else
+    {
+      internal_f.f_symptr = 0;
+      internal_f.f_flags |= F_LSYMS;
     }
+
   if (text_sec)
     {
       internal_a.tsize = bfd_get_section_size_before_reloc (text_sec);
-      internal_a.text_start = internal_a.tsize ? text_sec->vma : 0;
+      internal_a.text_start = internal_a.tsize ? 
+       (text_sec->vma - IMAGE_BASE) : 0;
     }
   if (data_sec)
     {
       internal_a.dsize = bfd_get_section_size_before_reloc (data_sec);
-      internal_a.data_start = internal_a.dsize ? data_sec->vma : 0;
+      internal_a.data_start = internal_a.dsize ? 
+       (data_sec->vma - IMAGE_BASE) : 0;
     }
   if (bss_sec)
     {
       internal_a.bsize = bfd_get_section_size_before_reloc (bss_sec);
     }
 
-  internal_a.entry = bfd_get_start_address (abfd);
-  internal_f.f_nsyms = bfd_get_symcount (abfd);
+  internal_a.entry = bfd_get_start_address (abfd) - IMAGE_BASE;
+  internal_f.f_nsyms = obj_raw_syment_count (abfd);
+
+#ifdef COFF_WITH_PE            /* write all of the other optional header data */
+  /* Note; the entries for subsystem, stack reserve, stack commit, heap reserve
+     and heap commit may be supplied on the command line via the -subsystem,
+     -stack and/or -heap switches.  This data is initially stored in variable
+     link_info.  This is eventually passed to the bfd (from ld) in (cofflink.c)
+     _bfd_coff_final_link.  Once this function gets it, we copy it into variables
+     NT_subsystem and NT_stack_heap which are defined in internal.h.  With
+     respect to the stack/heap reserve/commit parameters, if nothing has been
+     defined for these, the input values will be '0' (i.e. the values stored
+     in NT_stack_heap) will be 0. */ 
+
+  internal_a.ImageBase = NT_IMAGE_BASE;        /* 0x400000 */
+  internal_a.SectionAlignment = NT_SECTION_ALIGNMENT; /* 0x1000 */ 
+  internal_a.FileAlignment = NT_FILE_ALIGNMENT;        /* 0x200 */
+  internal_a.MajorOperatingSystemVersion = 1;
+  internal_a.MinorOperatingSystemVersion = 0;
+  internal_a.MajorImageVersion = 0;
+  internal_a.MinorImageVersion = 0;
+  internal_a.MajorSubsystemVersion = 3;
+  internal_a.MinorSubsystemVersion = 0xA;
+  internal_a.Reserved1 = 0;
+  /* Virtual start address, take virtual start address of last section, 
+     add its physical size and round up the next page (NT_SECTION_ALIGNMENT).
+     An assumption has been made that the sections stored in the abfd
+     structure are in order and that I have successfully saved the last
+     section's address and size. */
+
+  internal_a.SizeOfImage = 
+    (end_of_image - NT_IMAGE_BASE + NT_SECTION_ALIGNMENT - 1)
+      & ~ (NT_SECTION_ALIGNMENT-1);
+
+  /* Start of .text section will do here since it is the first section after
+     the headers.  Note that NT_IMAGE_BASE has already been removed above */
+  internal_a.SizeOfHeaders = internal_a.text_start; 
+  internal_a.CheckSum = 0;
+  switch (NT_subsystem)
+    {
+      /* The possible values are:
+        1 - NATIVE   Doesn't require a subsystem
+        2 - WINDOWS_GUI runs in Windows GUI subsystem
+        3 - WINDOWS_CUI runs in Windows char sub. (console app)
+        5 - OS2_CUI runs in OS/2 character subsystem
+        7 - POSIX_CUI runs in Posix character subsystem */
+    case native:
+      internal_a.Subsystem = 1;
+      break;
+    case windows:
+      internal_a.Subsystem = 2;
+      break;
+    case console:
+      internal_a.Subsystem = 3;
+      break;
+    case os2:
+      internal_a.Subsystem = 5;
+      break;
+    case posix:
+      internal_a.Subsystem = 7;
+      break;
+    default:
+      internal_a.Subsystem = 3;
+    }
+  internal_a.DllCharacteristics = 0;
+  if (NT_stack_heap.stack_defined)
+    {
+      internal_a.SizeOfStackReserve = NT_stack_heap.stack_reserve;
+      /* since commit is an optional parameter, verify that it is non-zero */
+      if (NT_stack_heap.stack_commit > 0)
+       internal_a.SizeOfStackCommit = NT_stack_heap.stack_commit;
+      else
+       internal_a.SizeOfStackCommit = NT_DEF_COMMIT;
+    }
+  else
+    {
+      internal_a.SizeOfStackReserve = NT_DEF_RESERVE; /* 0x100000 */
+      internal_a.SizeOfStackCommit = NT_DEF_COMMIT; /* 0x1000 */
+    }
+  if (NT_stack_heap.heap_defined)
+    {
+      internal_a.SizeOfHeapReserve = NT_stack_heap.heap_reserve;
+      /* since commit is an optional parameter, verify that it is non-zero */
+      if (NT_stack_heap.heap_commit > 0)
+       internal_a.SizeOfHeapCommit = NT_stack_heap.heap_commit;
+      else
+       internal_a.SizeOfHeapCommit = NT_DEF_COMMIT;
+    }
+  else
+    {
+      internal_a.SizeOfHeapReserve = NT_DEF_RESERVE; /* 0x100000 */
+      internal_a.SizeOfHeapCommit = NT_DEF_COMMIT; /* 0x1000 */
+    }
+  internal_a.LoaderFlags = 0;
+  internal_a.NumberOfRvaAndSizes = IMAGE_NUMBEROF_DIRECTORY_ENTRIES; /* 0x10 */
+
+  /* first null out all data directory entries .. */
+  memset (internal_a.DataDirectory, sizeof (internal_a.DataDirectory), 0);
+
+  add_data_entry (abfd, &internal_a, 0, ".edata");
+  add_data_entry (abfd, &internal_a, 1, ".idata");
+  add_data_entry (abfd, &internal_a, 2, ".rsrc");
+  add_data_entry (abfd, &internal_a, 5, ".reloc");
+
+
+
+#endif
 
   /* now write them */
   if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
@@ -1796,24 +2205,27 @@ DEFUN (coff_write_object_contents, (abfd),
   {
     FILHDR buff;
     coff_swap_filehdr_out (abfd, (PTR) & internal_f, (PTR) & buff);
-    bfd_write ((PTR) & buff, 1, FILHSZ, abfd);
+    if (bfd_write ((PTR) & buff, 1, FILHSZ, abfd) != FILHSZ)
+      return false;
   }
   if (abfd->flags & EXEC_P)
     {
       AOUTHDR buff;
       coff_swap_aouthdr_out (abfd, (PTR) & internal_a, (PTR) & buff);
-      bfd_write ((PTR) & buff, 1, AOUTSZ, abfd);
+      if (bfd_write ((PTR) & buff, 1, AOUTSZ, abfd) != AOUTSZ)
+       return false;
     }
+
   return true;
 }
 
 static boolean
-DEFUN (coff_set_section_contents, (abfd, section, location, offset, count),
-       bfd * abfd AND
-       sec_ptr section AND
-       PTR location AND
-       file_ptr offset AND
-       bfd_size_type count)
+coff_set_section_contents (abfd, section, location, offset, count)
+     bfd * abfd;
+     sec_ptr section;
+     PTR location;
+     file_ptr offset;
+     bfd_size_type count;
 {
   if (abfd->output_has_begun == false) /* set by bfd.c handler */
     coff_compute_section_file_positions (abfd);
@@ -1832,7 +2244,8 @@ DEFUN (coff_set_section_contents, (abfd, section, location, offset, count),
   if (section->filepos == 0)
     return true;
 
-  bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET);
+  if (bfd_seek (abfd, (file_ptr) (section->filepos + offset), SEEK_SET) != 0)
+    return false;
 
   if (count != 0)
     {
@@ -1857,7 +2270,7 @@ coff_close_and_cleanup (abfd)
          return false;
        break;
       default:
-       bfd_error = invalid_operation;
+       bfd_set_error (bfd_error_invalid_operation);
        return false;
       }
 
@@ -1878,15 +2291,12 @@ buy_and_read (abfd, where, seek_direction, size)
   PTR area = (PTR) bfd_alloc (abfd, size);
   if (!area)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return (NULL);
     }
-  bfd_seek (abfd, where, seek_direction);
-  if (bfd_read (area, 1, size, abfd) != size)
-    {
-      bfd_error = system_call_error;
-      return (NULL);
-    }                          /* on error */
+  if (bfd_seek (abfd, where, seek_direction) != 0
+      || bfd_read (area, 1, size, abfd) != size)
+    return (NULL);
   return (area);
 }                              /* buy_and_read() */
 
@@ -1930,7 +2340,7 @@ coff_slurp_line_table (abfd, asect)
     (alent *) bfd_alloc (abfd, (size_t) ((asect->lineno_count + 1) * sizeof (alent)));
   if (lineno_cache == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   else
@@ -1972,17 +2382,19 @@ coff_slurp_line_table (abfd, asect)
 }
 
 static boolean
-DEFUN (coff_slurp_symbol_table, (abfd),
-       bfd * abfd)
+coff_slurp_symbol_table (abfd)
+     bfd * abfd;
 {
   combined_entry_type *native_symbols;
   coff_symbol_type *cached_area;
   unsigned int *table_ptr;
 
   unsigned int number_of_symbols = 0;
+
   if (obj_symbols (abfd))
     return true;
-  bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET);
+  if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
+    return false;
 
   /* Read in the symbol table */
   if ((native_symbols = coff_get_normalized_symtab (abfd)) == NULL)
@@ -1991,28 +2403,30 @@ DEFUN (coff_slurp_symbol_table, (abfd),
     }                          /* on error */
 
   /* Allocate enough room for all the symbols in cached form */
-  cached_area =
-    (coff_symbol_type *)
-    bfd_alloc (abfd, (size_t) (bfd_get_symcount (abfd) * sizeof (coff_symbol_type)));
+  cached_area = ((coff_symbol_type *)
+                bfd_alloc (abfd,
+                           (obj_raw_syment_count (abfd)
+                            * sizeof (coff_symbol_type))));
 
   if (cached_area == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }                          /* on error */
-  table_ptr =
-    (unsigned int *)
-    bfd_alloc (abfd, (size_t) (bfd_get_symcount (abfd) * sizeof (unsigned int)));
+  table_ptr = ((unsigned int *)
+              bfd_alloc (abfd,
+                         (obj_raw_syment_count (abfd)
+                          * sizeof (unsigned int))));
 
   if (table_ptr == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
   else
     {
       coff_symbol_type *dst = cached_area;
-      unsigned int last_native_index = bfd_get_symcount (abfd);
+      unsigned int last_native_index = obj_raw_syment_count (abfd);
       unsigned int this_index = 0;
       while (this_index < last_native_index)
        {
@@ -2035,7 +2449,7 @@ DEFUN (coff_slurp_symbol_table, (abfd),
 #if 0
              dst->symbol.value = src->u.syment.n_value - dst->symbol.section->vma;
              dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
-             dst->symbol.flags |= BSF_NOT_AT_END;
+             dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
 #endif
              /* Fall through to next case */
 
@@ -2044,17 +2458,21 @@ DEFUN (coff_slurp_symbol_table, (abfd),
            case C_EXT:
 #ifdef RS6000COFF_C
            case C_HIDEXT:
+#endif
+#ifdef COFF_WITH_PE
+            /* PE uses storage class 0x68 to denote a section symbol */
+            case C_SECTION:
 #endif
              if ((src->u.syment.n_scnum) == 0)
                {
                  if ((src->u.syment.n_value) == 0)
                    {
-                     dst->symbol.section = &bfd_und_section;
+                     dst->symbol.section = bfd_und_section_ptr;
                      dst->symbol.value = 0;
                    }
                  else
                    {
-                     dst->symbol.section = &bfd_com_section;
+                     dst->symbol.section = bfd_com_section_ptr;
                      dst->symbol.value = (src->u.syment.n_value);
                    }
                }
@@ -2073,7 +2491,7 @@ DEFUN (coff_slurp_symbol_table, (abfd),
                      /*
              A function ext does not go at the end of a file
              */
-                     dst->symbol.flags |= BSF_NOT_AT_END;
+                     dst->symbol.flags |= BSF_NOT_AT_END | BSF_FUNCTION;
                    }
                }
 
@@ -2189,7 +2607,11 @@ DEFUN (coff_slurp_symbol_table, (abfd),
            case C_EXTDEF:      /* external definition           */
            case C_ULABEL:      /* undefined label               */
            case C_USTATIC:     /* undefined static              */
+#ifndef COFF_WITH_PE
+            /* C_LINE in regular coff is 0x68.  NT has taken over this storage
+               class to represent a section symbol */
            case C_LINE:        /* line # reformatted as symbol table entry */
+#endif
            case C_ALIAS:       /* duplicate tag                 */
            case C_HIDDEN:      /* ext symbol in dmert public lib */
            default:
@@ -2207,7 +2629,7 @@ DEFUN (coff_slurp_symbol_table, (abfd),
 
          dst->native = src;
 
-         dst->symbol.udata = 0;
+         dst->symbol.udata.i = 0;
          dst->lineno = (alent *) NULL;
          this_index += (src->u.syment.n_numaux) + 1;
          dst++;
@@ -2218,7 +2640,6 @@ DEFUN (coff_slurp_symbol_table, (abfd),
   obj_symbols (abfd) = cached_area;
   obj_raw_syments (abfd) = native_symbols;
 
-  obj_conv_table_size (abfd) = bfd_get_symcount (abfd);
   bfd_get_symcount (abfd) = number_of_symbols;
   obj_convert (abfd) = table_ptr;
   /* Slurp the line tables for each section too */
@@ -2234,6 +2655,47 @@ DEFUN (coff_slurp_symbol_table, (abfd),
   return true;
 }                              /* coff_slurp_symbol_table() */
 
+/* Check whether a symbol is globally visible.  This is used by the
+   COFF backend linker code in cofflink.c, since a couple of targets
+   have globally visible symbols which are not class C_EXT.  This
+   function need not handle the case of n_class == C_EXT.  */
+
+#undef OTHER_GLOBAL_CLASS
+
+#ifdef I960
+#define OTHER_GLOBAL_CLASS C_LEAFEXT
+#endif
+
+#ifdef RS6000COFF_C
+#define OTHER_GLOBAL_CLASS C_HIDEXT
+#endif
+
+#ifdef COFF_WITH_PE
+#define OTHER_GLOBAL_CLASS C_SECTION
+#endif
+
+#ifdef OTHER_GLOBAL_CLASS
+
+static boolean
+coff_sym_is_global (abfd, syment)
+     bfd *abfd;
+     struct internal_syment *syment;
+{
+  if (syment->n_sclass == OTHER_GLOBAL_CLASS)
+    return true;
+  return false;
+}
+
+#undef OTHER_GLOBAL_CLASS
+
+#else /* ! defined (OTHER_GLOBAL_CLASS) */
+
+/* sym_is_global should not be defined if it has nothing to do.  */
+
+#define coff_sym_is_global 0
+
+#endif /* ! defined (OTHER_GLOBAL_CLASS) */
+
 /*
 SUBSUBSECTION
        Reading relocations
@@ -2264,23 +2726,30 @@ SUBSUBSECTION
 */
 
 #ifndef CALC_ADDEND
-#define CALC_ADDEND(abfd, ptr, reloc, cache_ptr)       \
-           if (ptr && bfd_asymbol_bfd(ptr) == abfd     \
-               && !bfd_is_com_section(ptr->section)    \
-               && !(ptr->flags & BSF_OLD_COMMON))      \
-           {                                           \
-               cache_ptr->addend = -(ptr->section->vma + ptr->value);  \
-           }                                           \
-           else {                                      \
-               cache_ptr->addend = 0;                  \
-           }
+#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;                                    \
+  }
 #endif
 
 static boolean
-DEFUN (coff_slurp_reloc_table, (abfd, asect, symbols),
-       bfd * abfd AND
-       sec_ptr asect AND
-       asymbol ** symbols)
+coff_slurp_reloc_table (abfd, asect, symbols)
+     bfd * abfd;
+     sec_ptr asect;
+     asymbol ** symbols;
 {
   RELOC *native_relocs;
   arelent *reloc_cache;
@@ -2307,7 +2776,7 @@ DEFUN (coff_slurp_reloc_table, (abfd, asect, symbols),
 
   if (reloc_cache == NULL)
     {
-      bfd_error = no_memory;
+      bfd_set_error (bfd_error_no_memory);
       return false;
     }
 
@@ -2320,7 +2789,7 @@ DEFUN (coff_slurp_reloc_table, (abfd, asect, symbols),
 
       cache_ptr = reloc_cache + idx;
       src = native_relocs + idx;
-      bfd_swap_reloc_in (abfd, src, &dst);
+      coff_swap_reloc_in (abfd, src, &dst);
 
       RELOC_PROCESSING (cache_ptr, &dst, symbols, abfd, asect);
 #else
@@ -2331,7 +2800,7 @@ DEFUN (coff_slurp_reloc_table, (abfd, asect, symbols),
       cache_ptr = reloc_cache + idx;
       src = native_relocs + idx;
 
-      bfd_swap_reloc_in (abfd, src, &dst);
+      coff_swap_reloc_in (abfd, src, &dst);
 
 
       cache_ptr->address = dst.r_vaddr;
@@ -2346,7 +2815,7 @@ DEFUN (coff_slurp_reloc_table, (abfd, asect, symbols),
        }
       else
        {
-         cache_ptr->sym_ptr_ptr = bfd_abs_section.symbol_ptr_ptr;
+         cache_ptr->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
          ptr = 0;
        }
 
@@ -2373,14 +2842,50 @@ DEFUN (coff_slurp_reloc_table, (abfd, asect, symbols),
   return true;
 }
 
+#ifndef coff_rtype_to_howto
+#ifdef RTYPE2HOWTO
+
+/* Get the howto structure for a reloc.  This is only used if the file
+   including this one defines coff_relocate_section to be
+   _bfd_coff_generic_relocate_section, so it is OK if it does not
+   always work.  It is the responsibility of the including file to
+   make sure it is reasonable if it is needed.  */
+
+static reloc_howto_type *coff_rtype_to_howto
+  PARAMS ((bfd *, asection *, struct internal_reloc *,
+          struct coff_link_hash_entry *, struct internal_syment *,
+          bfd_vma *));
+
+/*ARGSUSED*/
+static reloc_howto_type *
+coff_rtype_to_howto (abfd, sec, rel, h, sym, addendp)
+     bfd *abfd;
+     asection *sec;
+     struct internal_reloc *rel;
+     struct coff_link_hash_entry *h;
+     struct internal_syment *sym;
+     bfd_vma *addendp;
+{
+  arelent genrel;
+
+  RTYPE2HOWTO (&genrel, rel);
+  return genrel.howto;
+}
+
+#else /* ! defined (RTYPE2HOWTO) */
+
+#define coff_rtype_to_howto NULL
+
+#endif /* ! defined (RTYPE2HOWTO) */
+#endif /* ! defined (coff_rtype_to_howto) */
 
 /* This is stupid.  This function should be a boolean predicate.  */
-static unsigned int
-DEFUN (coff_canonicalize_reloc, (abfd, section, relptr, symbols),
-       bfd * abfd AND
-       sec_ptr section AND
-       arelent ** relptr AND
-       asymbol ** symbols)
+static long
+coff_canonicalize_reloc (abfd, section, relptr, symbols)
+     bfd * abfd;
+     sec_ptr section;
+     arelent ** relptr;
+     asymbol ** symbols;
 {
   arelent *tblptr = section->relocation;
   unsigned int count = 0;
@@ -2401,12 +2906,10 @@ DEFUN (coff_canonicalize_reloc, (abfd, section, relptr, symbols),
     }
   else
     {
-      coff_slurp_reloc_table (abfd, section, symbols);
-
+      if (! coff_slurp_reloc_table (abfd, section, symbols))
+       return -1;
 
       tblptr = section->relocation;
-      if (!tblptr)
-       return 0;
 
       for (; count++ < section->reloc_count;)
        *relptr++ = tblptr++;
@@ -2430,9 +2933,9 @@ coff_sym_filepos (abfd)
 #define coff_reloc16_estimate dummy_reloc16_estimate
 
 static int
-dummy_reloc16_estimate (input_section, symbols, reloc, shrink, link_info)
+dummy_reloc16_estimate (abfd, input_section, reloc, shrink, link_info)
+     bfd *abfd;
      asection *input_section;
-     asymbol **symbols;
      arelent *reloc;
      unsigned int shrink;
      struct bfd_link_info *link_info;
@@ -2461,6 +2964,30 @@ dummy_reloc16_extra_cases (abfd, link_info, link_order, reloc, data, src_ptr,
 }
 #endif
 
+/* If coff_relocate_section is defined, we can use the optimized COFF
+   backend linker.  Otherwise we must continue to use the old linker.  */
+#ifdef coff_relocate_section
+#ifndef coff_bfd_link_hash_table_create
+#define coff_bfd_link_hash_table_create _bfd_coff_link_hash_table_create
+#endif
+#ifndef coff_bfd_link_add_symbols
+#define coff_bfd_link_add_symbols _bfd_coff_link_add_symbols
+#endif
+#ifndef coff_bfd_final_link
+#define coff_bfd_final_link _bfd_coff_final_link
+#endif
+#else /* ! defined (coff_relocate_section) */
+#define coff_relocate_section NULL
+#define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
+#define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols
+#define coff_bfd_final_link _bfd_generic_final_link
+#endif /* ! defined (coff_relocate_section) */
+#define coff_bfd_link_split_section  _bfd_generic_link_split_section
+
+#ifndef coff_adjust_symndx
+#define coff_adjust_symndx NULL
+#endif
+
 static CONST bfd_coff_backend_data bfd_coff_std_swap_table =
 {
   coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in,
@@ -2468,40 +2995,43 @@ static CONST bfd_coff_backend_data bfd_coff_std_swap_table =
   coff_swap_lineno_out, coff_swap_reloc_out,
   coff_swap_filehdr_out, coff_swap_aouthdr_out,
   coff_swap_scnhdr_out,
-  FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, LINESZ,
+  FILHSZ, AOUTSZ, SCNHSZ, SYMESZ, AUXESZ, RELSZ, LINESZ,
 #ifdef COFF_LONG_FILENAMES
   true,
 #else
   false,
 #endif
   coff_swap_filehdr_in, coff_swap_aouthdr_in, coff_swap_scnhdr_in,
-  coff_bad_format_hook, coff_set_arch_mach_hook, coff_mkobject_hook,
-  styp_to_sec_flags, coff_make_section_hook, coff_set_alignment_hook,
-  coff_slurp_symbol_table, symname_in_debug_hook,
-  coff_reloc16_extra_cases, coff_reloc16_estimate
+  coff_swap_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook,
+  coff_mkobject_hook, styp_to_sec_flags, coff_make_section_hook,
+  coff_set_alignment_hook, coff_slurp_symbol_table, symname_in_debug_hook,
+  coff_reloc16_extra_cases, coff_reloc16_estimate,
+  coff_sym_is_global, coff_compute_section_file_positions,
+  coff_relocate_section, coff_rtype_to_howto, coff_adjust_symndx
 };
 
-#define coff_core_file_failing_command _bfd_dummy_core_file_failing_command
-#define coff_core_file_failing_signal  _bfd_dummy_core_file_failing_signal
-#define coff_core_file_matches_executable_p    _bfd_dummy_core_file_matches_executable_p
-#define coff_slurp_armap               bfd_slurp_coff_armap
-#define coff_slurp_extended_name_table _bfd_slurp_extended_name_table
-#define coff_truncate_arname           bfd_dont_truncate_arname
-#define coff_openr_next_archived_file  bfd_generic_openr_next_archived_file
-#define coff_generic_stat_arch_elt     bfd_generic_stat_arch_elt
-#define        coff_get_section_contents       bfd_generic_get_section_contents
-#define        coff_close_and_cleanup          bfd_generic_close_and_cleanup
-
-#define coff_bfd_debug_info_start      bfd_void
-#define coff_bfd_debug_info_end                bfd_void
-#define coff_bfd_debug_info_accumulate \
-                       (void (*) PARAMS ((bfd *, struct sec *))) bfd_void
-#define coff_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
-#define coff_bfd_relax_section         bfd_generic_relax_section
+#define        coff_close_and_cleanup _bfd_generic_close_and_cleanup
+#define coff_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
+#define        coff_get_section_contents _bfd_generic_get_section_contents
+
+#define coff_bfd_copy_private_symbol_data \
+  _bfd_generic_bfd_copy_private_symbol_data
+#define coff_bfd_copy_private_section_data \
+  _bfd_generic_bfd_copy_private_section_data
+#define coff_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data
+#define coff_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_private_bfd_data
+#define coff_bfd_set_private_flags _bfd_generic_bfd_set_private_flags
+
+#ifndef coff_bfd_is_local_label
+#define coff_bfd_is_local_label bfd_generic_is_local_label
+#endif
+
+/* The reloc lookup routine must be supplied by each individual COFF
+   backend.  */
 #ifndef coff_bfd_reloc_type_lookup
-#define coff_bfd_reloc_type_lookup \
-  ((CONST struct reloc_howto_struct *(*) PARAMS ((bfd *, bfd_reloc_code_real_type))) bfd_nullvoidptr)
+#define coff_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
 #endif
-#define coff_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
-#define coff_bfd_link_add_symbols _bfd_generic_link_add_symbols
-#define coff_bfd_final_link _bfd_generic_final_link
+
+#define coff_bfd_get_relocated_section_contents \
+  bfd_generic_get_relocated_section_contents
+#define coff_bfd_relax_section bfd_generic_relax_section
This page took 0.045131 seconds and 4 git commands to generate.