Commit | Line | Data |
---|---|---|
a42ceb32 JG |
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 | ||
7ed4093a SC |
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 | ||
a42ceb32 | 29 | #include <ansidecl.h> |
7ed4093a | 30 | #include <sysdep.h> |
a42ceb32 JG |
31 | #include "bfd.h" |
32 | #include "libbfd.h" | |
7ed4093a | 33 | #include "aout64.h" |
6f715d66 SC |
34 | |
35 | /**From: bothner@cs.wisc.edu***********************************************/ | |
36 | #undef N_TXTOFF | |
37 | #define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? PAGE_SIZE : EXEC_BYTES_SIZE) | |
38 | /**************************************************************************/ | |
39 | ||
7ed4093a SC |
40 | #include "stab.gnu.h" |
41 | #include "ar.h" | |
359f1dee | 42 | #include "libaout.h" /* BFD a.out internal data structures */ |
6f715d66 | 43 | #if 0 |
a42ceb32 JG |
44 | int vfprintf(file, format, args) /* Temporary crock! */ |
45 | FILE *file; char *format; char *args; | |
46 | { | |
47 | return _doprnt (format, args, file); | |
48 | } | |
6f715d66 | 49 | #endif |
a42ceb32 | 50 | |
a42ceb32 JG |
51 | |
52 | bfd_target *newsos3_callback (); | |
53 | ||
54 | bfd_target * | |
7ed4093a SC |
55 | DEFUN(newsos3_object_p,(abfd), |
56 | bfd *abfd) | |
a42ceb32 | 57 | { |
6f715d66 | 58 | unsigned char magicbuf[4]; /* Raw bytes of magic number from file */ |
a42ceb32 JG |
59 | unsigned long magic; /* Swapped magic number */ |
60 | ||
61 | bfd_error = system_call_error; | |
62 | ||
63 | if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) != | |
64 | sizeof (magicbuf)) | |
65 | return 0; | |
7ed4093a | 66 | magic = bfd_h_get_32 (abfd, magicbuf); |
a42ceb32 | 67 | |
7ed4093a | 68 | if (N_BADMAG (*((struct internal_exec *) &magic))) return 0; |
a42ceb32 | 69 | |
7ed4093a | 70 | return aout_32_some_aout_object_p (abfd, newsos3_callback); |
a42ceb32 JG |
71 | } |
72 | ||
73 | /* Finish up the reading of a NEWS-OS a.out file header */ | |
74 | bfd_target * | |
7ed4093a SC |
75 | DEFUN(newsos3_callback,(abfd), |
76 | bfd *abfd) | |
a42ceb32 | 77 | { |
7ed4093a SC |
78 | struct internal_exec *execp = exec_hdr (abfd); |
79 | ||
80 | WORK_OUT_FILE_POSITIONS(abfd, execp) ; | |
81 | ||
a42ceb32 JG |
82 | /* Determine the architecture and machine type of the object file. */ |
83 | abfd->obj_arch = bfd_arch_m68k; | |
84 | abfd->obj_machine = 0; | |
85 | ||
86 | return abfd->xvec; | |
87 | } | |
88 | ||
89 | /* Write an object file in NEWS-OS format. | |
90 | Section contents have already been written. We write the | |
91 | file header, symbols, and relocation. */ | |
92 | ||
93 | boolean | |
7ed4093a SC |
94 | DEFUN(newsos3_write_object_contents,(abfd), |
95 | bfd *abfd) | |
a42ceb32 | 96 | { |
7ed4093a SC |
97 | bfd_size_type data_pad = 0; |
98 | struct external_exec exec_bytes; | |
99 | struct internal_exec *execp = exec_hdr (abfd); | |
100 | ||
101 | WRITE_HEADERS(abfd, execp); | |
a42ceb32 JG |
102 | return true; |
103 | } | |
104 | \f | |
105 | /* Transfer vectors for NEWS-OS version 3 */ | |
106 | ||
107 | /* We use BFD generic archive files. */ | |
6f715d66 SC |
108 | #define newsos_openr_next_archived_file bfd_generic_openr_next_archived_file |
109 | #define newsos_generic_stat_arch_elt bfd_generic_stat_arch_elt | |
110 | #define newsos_slurp_armap bfd_slurp_bsd_armap | |
111 | #define newsos_slurp_extended_name_table bfd_true | |
112 | #define newsos_write_armap bsd_write_armap | |
113 | #define newsos_truncate_arname bfd_bsd_truncate_arname | |
a42ceb32 JG |
114 | |
115 | /* We don't support core files yet. FIXME. */ | |
6f715d66 SC |
116 | #define newsos_core_file_failing_command _bfd_dummy_core_file_failing_command |
117 | #define newsos_core_file_failing_signal _bfd_dummy_core_file_failing_signal | |
118 | #define newsos_core_file_matches_executable_p \ | |
a42ceb32 | 119 | _bfd_dummy_core_file_matches_executable_p |
6f715d66 SC |
120 | #define newsos_core_file_p _bfd_dummy_target |
121 | ||
122 | #define newsos_bfd_debug_info_start bfd_void | |
123 | #define newsos_bfd_debug_info_end bfd_void | |
124 | #define newsos_bfd_debug_info_accumulate bfd_void | |
125 | ||
126 | #define newsos_mkobject aout_32_mkobject | |
127 | #define newsos_close_and_cleanup aout_32_close_and_cleanup | |
128 | #define newsos_set_section_contents aout_32_set_section_contents | |
129 | #define newsos_get_section_contents aout_32_get_section_contents | |
130 | #define newsos_new_section_hook aout_32_new_section_hook | |
131 | #define newsos_get_symtab_upper_bound aout_32_get_symtab_upper_bound | |
132 | #define newsos_get_symtab aout_32_get_symtab | |
133 | #define newsos_get_reloc_upper_bound aout_32_get_reloc_upper_bound | |
134 | #define newsos_canonicalize_reloc aout_32_canonicalize_reloc | |
135 | #define newsos_make_empty_symbol aout_32_make_empty_symbol | |
136 | #define newsos_print_symbol aout_32_print_symbol | |
137 | #define newsos_get_lineno aout_32_get_lineno | |
138 | #define newsos_set_arch_mach aout_32_set_arch_mach | |
139 | #define newsos_find_nearest_line aout_32_find_nearest_line | |
140 | #define newsos_sizeof_headers aout_32_sizeof_headers | |
141 | ||
a42ceb32 JG |
142 | |
143 | /* We define our own versions of these routines. */ | |
144 | ||
145 | ||
146 | bfd_target newsos3_vec = /* Sony 68k-based machines running newos3 */ | |
147 | { | |
148 | "a.out-newos3", /* name */ | |
149 | bfd_target_aout_flavour_enum, | |
150 | true, /* target byte order */ | |
151 | true, /* target headers byte order */ | |
152 | (HAS_RELOC | EXEC_P | /* object flags */ | |
153 | HAS_LINENO | HAS_DEBUG | | |
154 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), | |
155 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
156 | ' ', /* ar_pad_char */ | |
157 | 16, /* ar_max_namelen */ | |
6f715d66 | 158 | 1, /* minimum alignment */ |
7ed4093a SC |
159 | _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ |
160 | _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ | |
a42ceb32 | 161 | |
7ed4093a | 162 | {_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */ |
6f715d66 SC |
163 | bfd_generic_archive_p, newsos_core_file_p}, |
164 | {bfd_false, newsos_mkobject, /* bfd_set_format */ | |
7ed4093a SC |
165 | _bfd_generic_mkarchive, bfd_false}, |
166 | {bfd_false, newsos3_write_object_contents, /* bfd_write_contents */ | |
167 | _bfd_write_archive_contents, bfd_false}, | |
a42ceb32 | 168 | |
6f715d66 | 169 | JUMP_TABLE(newsos) |
7ed4093a | 170 | }; |