2000-11-06 Kazu Hirata <kazu@hxi.com>
[deliverable/binutils-gdb.git] / bfd / aout-encap.c
index 6565df1f9269008fc7588cabab8bd0464f37f79b..d6650a99c48dc5c3a3e9f69068d3cadd46d6fee9 100644 (file)
@@ -1,5 +1,5 @@
 /* BFD back-end for a.out files encapsulated with COFF headers.
-   Copyright (C) 1990-1991 Free Software Foundation, Inc.
+   Copyright (C) 19901991 Free Software Foundation, Inc.
 
 This file is part of BFD, the Binary File Descriptor library.
 
@@ -15,37 +15,30 @@ 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.  */
 
 /* THIS MODULE IS NOT FINISHED.  IT PROBABLY DOESN'T EVEN COMPILE.  */
 
 #if 0
-#define        PAGE_SIZE       4096
-#define        SEGMENT_SIZE    PAGE_SIZE
+#define        TARGET_PAGE_SIZE        4096
+#define        SEGMENT_SIZE    TARGET_PAGE_SIZE
 #define TEXT_START_ADDR 0
-#define ARCH 32
 #define BYTES_IN_WORD 4
 #endif
 
 #include "bfd.h"
 #include <sysdep.h>
 #include "libbfd.h"
-#include "aout64.h"
-
-/**From: bothner@cs.wisc.edu***********************************************/
-#undef N_TXTOFF
-#define N_TXTOFF(x)   ( (N_MAGIC((x)) == ZMAGIC) ? PAGE_SIZE : EXEC_BYTES_SIZE)
-/**************************************************************************/
-
+#include <aout/aout64.h>
 #include "aout/stab_gnu.h"
 #include "aout/ar.h"
 #include "libaout.h"           /* BFD a.out internal data structures */
 
-bfd_target *encap_callback ();
+const bfd_target *encap_real_callback ();
 
-bfd_target *
-DEFUN(encap_object_p,(abfd),
-     bfd *abfd)
+const bfd_target *
+encap_object_p (abfd)
+     bfd *abfd;
 {
   unsigned char magicbuf[4]; /* Raw bytes of magic number from file */
   unsigned long magic;         /* Swapped magic number */
@@ -53,12 +46,14 @@ DEFUN(encap_object_p,(abfd),
   struct external_exec exec_bytes;
   struct internal_exec exec;
 
-  bfd_error = system_call_error;
-
   if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
       sizeof (magicbuf))
-    return 0;
-  
+    {
+      if (bfd_get_error () != bfd_error_system_call)
+       bfd_set_error (bfd_error_wrong_format);
+      return 0;
+    }
+
   coff_magic = bfd_h_get_16 (abfd, magicbuf);
   if (coff_magic != COFF_MAGIC)
     return 0;                  /* Not an encap coff file */
@@ -73,23 +68,24 @@ DEFUN(encap_object_p,(abfd),
   struct external_exec exec_bytes;
   if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
       != EXEC_BYTES_SIZE) {
-    bfd_error = wrong_format;
+    if (bfd_get_error () != bfd_error_system_call)
+      bfd_set_error (bfd_error_wrong_format);
     return 0;
   }
   NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
 
-  return aout_32_some_aout_object_p (abfd, &exec, encap_callback);
+  return aout_32_some_aout_object_p (abfd, &exec, encap_realcallback);
 }
 
 /* Finish up the reading of a encapsulated-coff a.out file header */
-bfd_target *
-DEFUN(encap_callback,(abfd),
-      bfd *abfd)
+const bfd_target *
+encap_real_callback (abfd)
+     bfd *abfd;
 {
   struct internal_exec *execp = exec_hdr (abfd);
-  
-  WORK_OUT_FILE_POSITIONS(abfd, execp) ;
-  
+
+  MY(callback)(abfd, execp);
+
   /* If we have a coff header, it can give us better values for
      text_start and exec_data_start.  This is particularly useful
      for remote debugging of embedded systems.  */
@@ -124,8 +120,8 @@ DEFUN(encap_callback,(abfd),
    file header, symbols, and relocation.  */
 
 boolean
-DEFUN(encap_write_object_contents,(abfd),
-      bfd *abfd)
+encap_write_object_contents (abfd)
+     bfd *abfd;
 {
   bfd_size_type data_pad = 0;
   struct external_exec exec_bytes;
@@ -151,7 +147,7 @@ int need_coff_header;
     {
       need_coff_header = 1;
       /* set this flag now, since it will change the values of N_TXTOFF, etc */
-      N_SET_FLAGS (outheader, N_FLAGS_COFF_ENCAPSULATE);
+      N_SET_FLAGS (outheader, aout_backend_info (abfd)->exec_hdr_flags);
       text_size += sizeof (struct coffheader);
     }
 #endif
@@ -232,97 +228,9 @@ int need_coff_header;
   WRITE_HEADERS(abfd, execp);
   return true;
 }
-\f
-/* Transfer vectors for Encapsulated-(aout-in)-coff */
-
-/* We use BFD generic archive files.  */
-#define        newsos_openr_next_archived_file bfd_generic_openr_next_archived_file
-#define        newsos_generic_stat_arch_elt    bfd_generic_stat_arch_elt
-#define        newsos_slurp_armap              bfd_slurp_bsd_armap
-#define        newsos_slurp_extended_name_table        bfd_true
-#define        newsos_write_armap              bsd_write_armap
-#define        newsos_truncate_arname          bfd_bsd_truncate_arname
-
-/* We don't support core files yet.  FIXME.  */
-#define        newsos_core_file_failing_command        _bfd_dummy_core_file_failing_command
-#define        newsos_core_file_failing_signal _bfd_dummy_core_file_failing_signal
-#define        newsos_core_file_matches_executable_p   \
-                               _bfd_dummy_core_file_matches_executable_p
-#define        newsos_core_file_p              _bfd_dummy_target
-
-#define newsos_bfd_debug_info_start            bfd_void
-#define newsos_bfd_debug_info_end              bfd_void
-#define newsos_bfd_debug_info_accumulate       (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
-
-#define newsos_mkobject aout_32_mkobject 
-#define newsos_close_and_cleanup aout_32_close_and_cleanup 
-#define newsos_set_section_contents aout_32_set_section_contents 
-#define newsos_get_section_contents aout_32_get_section_contents 
-#define newsos_new_section_hook aout_32_new_section_hook 
-#define newsos_get_symtab_upper_bound aout_32_get_symtab_upper_bound 
-#define newsos_get_symtab aout_32_get_symtab 
-#define newsos_get_reloc_upper_bound aout_32_get_reloc_upper_bound 
-#define newsos_canonicalize_reloc aout_32_canonicalize_reloc 
-#define newsos_make_empty_symbol aout_32_make_empty_symbol 
-#define newsos_print_symbol aout_32_print_symbol 
-#define newsos_get_lineno aout_32_get_lineno 
-#define newsos_set_arch_mach aout_32_set_arch_mach 
-#define newsos_find_nearest_line aout_32_find_nearest_line 
-#define newsos_sizeof_headers aout_32_sizeof_headers 
-
-
-/* We define our own versions of these routines.  */
-
-
-bfd_target encap_big_vec = /* "Encapsulated coff": a.out with COFF header prefix */
-{
-  "a.out-encap",               /* name */
-  bfd_target_aout_flavour,
-  true,                                /* target byte order */
-  true,                                /* target headers byte order */
-  (HAS_RELOC | EXEC_P |                /* object flags */
-   HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-  ' ',                         /* ar_pad_char */
-  16,                          /* ar_max_namelen */
-  1,                           /* minimum alignment */
-  _do_getb64, _do_putb64,      _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
-  _do_getb64, _do_putb64,      _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
-
-    {_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */
-       bfd_generic_archive_p, newsos_core_file_p},
-    {bfd_false, newsos_mkobject,       /* bfd_set_format */
-       _bfd_generic_mkarchive, bfd_false},
-    {bfd_false, newsos3_write_object_contents, /* bfd_write_contents */
-       _bfd_write_archive_contents, bfd_false},
-
-  JUMP_TABLE(newsos)
-};
-
-/* Little-endian "encapsulated coff": a.out with COFF header prefix */
-bfd_target encap_little_vec = 
-{
-  "a.out-encap-little",                /* name */
-  bfd_target_aout_flavour,
-  false,                       /* target byte order */
-  false,                       /* target headers byte order */
-  (HAS_RELOC | EXEC_P |                /* object flags */
-   HAS_LINENO | HAS_DEBUG |
-   HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
-  ' ',                         /* ar_pad_char */
-  16,                          /* ar_max_namelen */
-  1,                           /* minimum alignment */
-  _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
-  _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putb16, /* hdrs */
-
-    {_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */
-       bfd_generic_archive_p, newsos_core_file_p},
-    {bfd_false, newsos_mkobject,       /* bfd_set_format */
-       _bfd_generic_mkarchive, bfd_false},
-    {bfd_false, newsos3_write_object_contents, /* bfd_write_contents */
-       _bfd_write_archive_contents, bfd_false},
-
-  JUMP_TABLE(newsos)
-};
+
+#define MY_write_object_content encap_write_object_contents
+#define MY_object_p encap_object_p
+#define MY_exec_hdr_flags N_FLAGS_COFF_ENCAPSULATE
+
+#include "aout-target.h"
This page took 0.025308 seconds and 4 git commands to generate.