*** empty log message ***
[deliverable/binutils-gdb.git] / bfd / newsos3.c
1 /*** bfd backend for NewsOS3 (Sony, 68k) binaries */
2
3 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
4
5 This file is part of BFD, the Binary File Diddler.
6
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)
10 any later version.
11
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.
16
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. */
20
21 #define TARGET_BYTE_ORDER_BIG_P 1
22
23 #define PAGE_SIZE 4096
24 #define SEGMENT_SIZE PAGE_SIZE
25 #define TEXT_START_ADDR 0
26 #define ARCH 32
27 #define BYTES_IN_WORD 4
28
29 #include <ansidecl.h>
30 #include <sysdep.h>
31 #include "bfd.h"
32 #include "libbfd.h"
33 #include "aout64.h"
34 #include "stab.gnu.h"
35 #include "ar.h"
36 #include "liba.out.h" /* BFD a.out internal data structures */
37
38 int vfprintf(file, format, args) /* Temporary crock! */
39 FILE *file; char *format; char *args;
40 {
41 return _doprnt (format, args, file);
42 }
43
44
45
46 bfd_target *newsos3_callback ();
47
48 bfd_target *
49 DEFUN(newsos3_object_p,(abfd),
50 bfd *abfd)
51 {
52 unsigned char magicbuf[LONG_SIZE]; /* Raw bytes of magic number from file */
53 unsigned long magic; /* Swapped magic number */
54
55 bfd_error = system_call_error;
56
57 if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
58 sizeof (magicbuf))
59 return 0;
60 magic = bfd_h_get_32 (abfd, magicbuf);
61
62 if (N_BADMAG (*((struct internal_exec *) &magic))) return 0;
63
64 return aout_32_some_aout_object_p (abfd, newsos3_callback);
65 }
66
67 /* Finish up the reading of a NEWS-OS a.out file header */
68 bfd_target *
69 DEFUN(newsos3_callback,(abfd),
70 bfd *abfd)
71 {
72 struct internal_exec *execp = exec_hdr (abfd);
73
74 WORK_OUT_FILE_POSITIONS(abfd, execp) ;
75
76 /* Determine the architecture and machine type of the object file. */
77 abfd->obj_arch = bfd_arch_m68k;
78 abfd->obj_machine = 0;
79
80 return abfd->xvec;
81 }
82
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. */
86
87 boolean
88 DEFUN(newsos3_write_object_contents,(abfd),
89 bfd *abfd)
90 {
91 bfd_size_type data_pad = 0;
92 struct external_exec exec_bytes;
93 struct internal_exec *execp = exec_hdr (abfd);
94
95 WRITE_HEADERS(abfd, execp);
96 return true;
97 }
98 \f
99 /* Transfer vectors for NEWS-OS version 3 */
100
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
108
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
115
116 /* We define our own versions of these routines. */
117
118
119 bfd_target newsos3_vec = /* Sony 68k-based machines running newos3 */
120 {
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 */
131
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 */
134
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},
141
142 JUMP_TABLE(aout_32)
143 };
This page took 0.035331 seconds and 5 git commands to generate.