]>
Commit | Line | Data |
---|---|---|
ac0167e8 PB |
1 | /* BFD back-end for NewsOS3 (Sony, 68k) binaries. |
2 | Copyright (C) 1990-1991 Free Software Foundation, Inc. | |
a42ceb32 | 3 | |
ac0167e8 | 4 | This file is part of BFD, the Binary File Descriptor library. |
a42ceb32 | 5 | |
ac0167e8 | 6 | This program is free software; you can redistribute it and/or modify |
a42ceb32 | 7 | it under the terms of the GNU General Public License as published by |
ac0167e8 PB |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | |
a42ceb32 | 10 | |
ac0167e8 | 11 | This program is distributed in the hope that it will be useful, |
a42ceb32 JG |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
ac0167e8 PB |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
a42ceb32 | 19 | |
7ed4093a SC |
20 | #define PAGE_SIZE 4096 |
21 | #define SEGMENT_SIZE PAGE_SIZE | |
22 | #define TEXT_START_ADDR 0 | |
23 | #define ARCH 32 | |
24 | #define BYTES_IN_WORD 4 | |
25 | ||
a42ceb32 | 26 | #include "bfd.h" |
bbc8d484 | 27 | #include "sysdep.h" |
a42ceb32 | 28 | #include "libbfd.h" |
7ed4093a | 29 | #include "aout64.h" |
6f715d66 SC |
30 | |
31 | /**From: [email protected]***********************************************/ | |
32 | #undef N_TXTOFF | |
33 | #define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? PAGE_SIZE : EXEC_BYTES_SIZE) | |
34 | /**************************************************************************/ | |
35 | ||
7ed4093a SC |
36 | #include "stab.gnu.h" |
37 | #include "ar.h" | |
359f1dee | 38 | #include "libaout.h" /* BFD a.out internal data structures */ |
6f715d66 | 39 | #if 0 |
a42ceb32 JG |
40 | int vfprintf(file, format, args) /* Temporary crock! */ |
41 | FILE *file; char *format; char *args; | |
42 | { | |
43 | return _doprnt (format, args, file); | |
44 | } | |
6f715d66 | 45 | #endif |
a42ceb32 | 46 | |
a42ceb32 JG |
47 | |
48 | bfd_target *newsos3_callback (); | |
49 | ||
50 | bfd_target * | |
7ed4093a SC |
51 | DEFUN(newsos3_object_p,(abfd), |
52 | bfd *abfd) | |
a42ceb32 | 53 | { |
6a469027 JG |
54 | struct external_exec exec_bytes; |
55 | struct internal_exec exec; | |
a42ceb32 | 56 | |
6a469027 JG |
57 | if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) |
58 | != EXEC_BYTES_SIZE) { | |
59 | bfd_error = wrong_format; | |
a42ceb32 | 60 | return 0; |
6a469027 JG |
61 | } |
62 | ||
63 | exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info); | |
a42ceb32 | 64 | |
6a469027 | 65 | if (N_BADMAG (exec)) return 0; |
a42ceb32 | 66 | |
6a469027 JG |
67 | NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); |
68 | return aout_32_some_aout_object_p (abfd, &exec, newsos3_callback); | |
a42ceb32 JG |
69 | } |
70 | ||
71 | /* Finish up the reading of a NEWS-OS a.out file header */ | |
72 | bfd_target * | |
7ed4093a SC |
73 | DEFUN(newsos3_callback,(abfd), |
74 | bfd *abfd) | |
a42ceb32 | 75 | { |
7ed4093a SC |
76 | struct internal_exec *execp = exec_hdr (abfd); |
77 | ||
78 | WORK_OUT_FILE_POSITIONS(abfd, execp) ; | |
79 | ||
9e2dad8e JG |
80 | /* Determine the architecture and machine type of the object file. |
81 | */ | |
82 | bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0); | |
83 | ||
a42ceb32 JG |
84 | |
85 | return abfd->xvec; | |
86 | } | |
87 | ||
88 | /* Write an object file in NEWS-OS format. | |
89 | Section contents have already been written. We write the | |
90 | file header, symbols, and relocation. */ | |
91 | ||
92 | boolean | |
7ed4093a SC |
93 | DEFUN(newsos3_write_object_contents,(abfd), |
94 | bfd *abfd) | |
a42ceb32 | 95 | { |
7ed4093a SC |
96 | bfd_size_type data_pad = 0; |
97 | struct external_exec exec_bytes; | |
98 | struct internal_exec *execp = exec_hdr (abfd); | |
99 | ||
100 | WRITE_HEADERS(abfd, execp); | |
a42ceb32 JG |
101 | return true; |
102 | } | |
103 | \f | |
104 | /* Transfer vectors for NEWS-OS version 3 */ | |
105 | ||
106 | /* We use BFD generic archive files. */ | |
6f715d66 SC |
107 | #define newsos_openr_next_archived_file bfd_generic_openr_next_archived_file |
108 | #define newsos_generic_stat_arch_elt bfd_generic_stat_arch_elt | |
109 | #define newsos_slurp_armap bfd_slurp_bsd_armap | |
110 | #define newsos_slurp_extended_name_table bfd_true | |
111 | #define newsos_write_armap bsd_write_armap | |
112 | #define newsos_truncate_arname bfd_bsd_truncate_arname | |
a42ceb32 JG |
113 | |
114 | /* We don't support core files yet. FIXME. */ | |
6f715d66 SC |
115 | #define newsos_core_file_failing_command _bfd_dummy_core_file_failing_command |
116 | #define newsos_core_file_failing_signal _bfd_dummy_core_file_failing_signal | |
117 | #define newsos_core_file_matches_executable_p \ | |
a42ceb32 | 118 | _bfd_dummy_core_file_matches_executable_p |
6f715d66 SC |
119 | #define newsos_core_file_p _bfd_dummy_target |
120 | ||
121 | #define newsos_bfd_debug_info_start bfd_void | |
122 | #define newsos_bfd_debug_info_end bfd_void | |
ac0167e8 | 123 | #define newsos_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void |
6f715d66 SC |
124 | |
125 | #define newsos_mkobject aout_32_mkobject | |
126 | #define newsos_close_and_cleanup aout_32_close_and_cleanup | |
127 | #define newsos_set_section_contents aout_32_set_section_contents | |
128 | #define newsos_get_section_contents aout_32_get_section_contents | |
129 | #define newsos_new_section_hook aout_32_new_section_hook | |
130 | #define newsos_get_symtab_upper_bound aout_32_get_symtab_upper_bound | |
131 | #define newsos_get_symtab aout_32_get_symtab | |
132 | #define newsos_get_reloc_upper_bound aout_32_get_reloc_upper_bound | |
133 | #define newsos_canonicalize_reloc aout_32_canonicalize_reloc | |
134 | #define newsos_make_empty_symbol aout_32_make_empty_symbol | |
135 | #define newsos_print_symbol aout_32_print_symbol | |
136 | #define newsos_get_lineno aout_32_get_lineno | |
137 | #define newsos_set_arch_mach aout_32_set_arch_mach | |
138 | #define newsos_find_nearest_line aout_32_find_nearest_line | |
139 | #define newsos_sizeof_headers aout_32_sizeof_headers | |
140 | ||
a42ceb32 JG |
141 | |
142 | /* We define our own versions of these routines. */ | |
143 | ||
144 | ||
ac0167e8 | 145 | bfd_target newsos3_vec = /* Sony 68k-based machines running newsos3 */ |
a42ceb32 | 146 | { |
ac0167e8 | 147 | "a.out-newsos3", /* name */ |
9e2dad8e | 148 | bfd_target_aout_flavour, |
a42ceb32 JG |
149 | true, /* target byte order */ |
150 | true, /* target headers byte order */ | |
151 | (HAS_RELOC | EXEC_P | /* object flags */ | |
152 | HAS_LINENO | HAS_DEBUG | | |
153 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), | |
154 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
155 | ' ', /* ar_pad_char */ | |
156 | 16, /* ar_max_namelen */ | |
ac0167e8 | 157 | 1, /* minimum alignment */ |
7ed4093a SC |
158 | _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ |
159 | _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ | |
a42ceb32 | 160 | |
7ed4093a | 161 | {_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */ |
6f715d66 SC |
162 | bfd_generic_archive_p, newsos_core_file_p}, |
163 | {bfd_false, newsos_mkobject, /* bfd_set_format */ | |
7ed4093a SC |
164 | _bfd_generic_mkarchive, bfd_false}, |
165 | {bfd_false, newsos3_write_object_contents, /* bfd_write_contents */ | |
166 | _bfd_write_archive_contents, bfd_false}, | |
a42ceb32 | 167 | |
6f715d66 | 168 | JUMP_TABLE(newsos) |
ac0167e8 | 169 | }; |