1 /*** bfd backend for NewsOS3 (Sony, 68k) binaries */
3 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
5 This file is part of BFD, the Binary File Diddler.
7 BFD is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 1, or (at your option)
12 BFD is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with BFD; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #define TARGET_BYTE_ORDER_BIG_P 1
23 #define PAGE_SIZE 4096
24 #define SEGMENT_SIZE PAGE_SIZE
25 #define TEXT_START_ADDR 0
27 #define BYTES_IN_WORD 4
36 #include "liba.out.h" /* BFD a.out internal data structures */
38 int vfprintf(file
, format
, args
) /* Temporary crock! */
39 FILE *file
; char *format
; char *args
;
41 return _doprnt (format
, args
, file
);
46 bfd_target
*newsos3_callback ();
49 DEFUN(newsos3_object_p
,(abfd
),
52 unsigned char magicbuf
[LONG_SIZE
]; /* Raw bytes of magic number from file */
53 unsigned long magic
; /* Swapped magic number */
55 bfd_error
= system_call_error
;
57 if (bfd_read ((PTR
)magicbuf
, 1, sizeof (magicbuf
), abfd
) !=
60 magic
= bfd_h_get_32 (abfd
, magicbuf
);
62 if (N_BADMAG (*((struct internal_exec
*) &magic
))) return 0;
64 return aout_32_some_aout_object_p (abfd
, newsos3_callback
);
67 /* Finish up the reading of a NEWS-OS a.out file header */
69 DEFUN(newsos3_callback
,(abfd
),
72 struct internal_exec
*execp
= exec_hdr (abfd
);
74 WORK_OUT_FILE_POSITIONS(abfd
, execp
) ;
76 /* Determine the architecture and machine type of the object file. */
77 abfd
->obj_arch
= bfd_arch_m68k
;
78 abfd
->obj_machine
= 0;
83 /* Write an object file in NEWS-OS format.
84 Section contents have already been written. We write the
85 file header, symbols, and relocation. */
88 DEFUN(newsos3_write_object_contents
,(abfd
),
91 bfd_size_type data_pad
= 0;
92 struct external_exec exec_bytes
;
93 struct internal_exec
*execp
= exec_hdr (abfd
);
95 WRITE_HEADERS(abfd
, execp
);
99 /* Transfer vectors for NEWS-OS version 3 */
101 /* We use BFD generic archive files. */
102 #define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file
103 #define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt
104 #define aout_32_slurp_armap bfd_slurp_bsd_armap
105 #define aout_32_slurp_extended_name_table bfd_true
106 #define aout_32_write_armap bsd_write_armap
107 #define aout_32_truncate_arname bfd_bsd_truncate_arname
109 /* We don't support core files yet. FIXME. */
110 #define aout_32_core_file_failing_command _bfd_dummy_core_file_failing_command
111 #define aout_32_core_file_failing_signal _bfd_dummy_core_file_failing_signal
112 #define aout_32_core_file_matches_executable_p \
113 _bfd_dummy_core_file_matches_executable_p
114 #define aout_32_core_file_p _bfd_dummy_target
116 /* We define our own versions of these routines. */
119 bfd_target newsos3_vec
= /* Sony 68k-based machines running newos3 */
121 "a.out-newos3", /* name */
122 bfd_target_aout_flavour_enum
,
123 true, /* target byte order */
124 true, /* target headers byte order */
125 (HAS_RELOC
| EXEC_P
| /* object flags */
126 HAS_LINENO
| HAS_DEBUG
|
127 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
| D_PAGED
),
128 (SEC_HAS_CONTENTS
| SEC_ALLOC
| SEC_LOAD
| SEC_RELOC
), /* section flags */
129 ' ', /* ar_pad_char */
130 16, /* ar_max_namelen */
132 _do_getb64
, _do_putb64
, _do_getb32
, _do_putb32
, _do_getb16
, _do_putb16
, /* data */
133 _do_getb64
, _do_putb64
, _do_getb32
, _do_putb32
, _do_getb16
, _do_putb16
, /* hdrs */
135 {_bfd_dummy_target
, newsos3_object_p
, /* bfd_check_format */
136 bfd_generic_archive_p
, aout_32_core_file_p
},
137 {bfd_false
, aout_32_mkobject
, /* bfd_set_format */
138 _bfd_generic_mkarchive
, bfd_false
},
139 {bfd_false
, newsos3_write_object_contents
, /* bfd_write_contents */
140 _bfd_write_archive_contents
, bfd_false
},