1 /* Define a target vector for a variant of a.out.
2 Copyright (C) 1990-1991 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 /* Set parameters about this a.out file that are machine-dependent.
21 This routine is called from some_aout_object_p just before it returns. */
23 DEFUN(MY(callback),(abfd),
26 struct internal_exec *execp = exec_hdr (abfd);
28 /* Calculate the file positions of the parts of a newly read aout header */
29 obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
31 /* The virtual memory addresses of the sections */
32 obj_textsec (abfd)->vma = N_TXTADDR(*execp);
33 obj_datasec (abfd)->vma = N_DATADDR(*execp);
34 obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
36 /* The file offsets of the sections */
37 obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
38 obj_datasec (abfd)->filepos = N_DATOFF (*execp);
40 /* The file offsets of the relocation info */
41 obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
42 obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
44 /* The file offsets of the string table and symbol table. */
45 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
46 obj_str_filepos (abfd) = N_STROFF (*execp);
48 /* Determine the architecture and machine type of the object file.
51 SET_ARCH_MACH(abfd, *execp);
53 bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
56 adata(abfd).page_size = PAGE_SIZE;
58 adata(abfd).segment_size = SEGMENT_SIZE;
60 adata(abfd).segment_size = PAGE_SIZE;
62 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
68 /* Finish up the reading of an a.out file header */
71 DEFUN(MY(object_p),(abfd),
74 struct external_exec exec_bytes; /* Raw exec header from file */
75 struct internal_exec exec; /* Cleaned-up exec header */
78 if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
80 bfd_error = wrong_format;
84 exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
86 if (N_BADMAG (exec)) return 0;
88 NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
89 target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
91 #ifdef ENTRY_CAN_BE_ZERO
92 /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
93 * means that it isn't obvious if EXEC_P should be set.
94 * All of the following must be true for an executable:
95 * There must be no relocations, the bfd can be neither an
96 * archive nor an archive element, and the file must be executable. */
98 if (exec.a_trsize + exec.a_drsize == 0
99 && bfd_get_format(abfd) == bfd_object && abfd->my_archive == NULL)
103 #define S_IXUSR 0100 /* Execute by owner. */
105 if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
106 abfd->flags |= EXEC_P;
108 #endif /* ENTRY_CAN_BE_ZERO */
112 #define MY_object_p MY(object_p)
118 DEFUN(MY(mkobject),(abfd),
121 if (NAME(aout,mkobject)(abfd) == false)
123 adata(abfd).page_size = PAGE_SIZE;
125 adata(abfd).segment_size = SEGMENT_SIZE;
127 adata(abfd).segment_size = PAGE_SIZE;
129 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
132 #define MY_mkobject MY(mkobject)
135 /* Write an object file.
136 Section contents have already been written. We write the
137 file header, symbols, and relocation. */
139 #ifndef MY_write_object_contents
141 DEFUN(MY(write_object_contents),(abfd),
144 bfd_size_type data_pad = 0;
145 struct external_exec exec_bytes;
146 struct internal_exec *execp = exec_hdr (abfd);
148 WRITE_HEADERS(abfd, execp);
151 #define MY_write_object_contents MY(write_object_contents)
154 /* We assume BFD generic archive files. */
155 #ifndef MY_openr_next_archived_file
156 #define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
158 #ifndef MY_generic_stat_arch_elt
159 #define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
161 #ifndef MY_slurp_armap
162 #define MY_slurp_armap bfd_slurp_bsd_armap
164 #ifndef MY_slurp_extended_name_table
165 #define MY_slurp_extended_name_table bfd_true
167 #ifndef MY_write_armap
168 #define MY_write_armap bsd_write_armap
170 #ifndef MY_truncate_arname
171 #define MY_truncate_arname bfd_bsd_truncate_arname
174 /* No core file defined here -- configure in trad-core.c separately. */
175 #ifndef MY_core_file_failing_command
176 #define MY_core_file_failing_command _bfd_dummy_core_file_failing_command
178 #ifndef MY_core_file_failing_signal
179 #define MY_core_file_failing_signal _bfd_dummy_core_file_failing_signal
181 #ifndef MY_core_file_matches_executable_p
182 #define MY_core_file_matches_executable_p \
183 _bfd_dummy_core_file_matches_executable_p
185 #ifndef MY_core_file_p
186 #define MY_core_file_p _bfd_dummy_target
189 #ifndef MY_bfd_debug_info_start
190 #define MY_bfd_debug_info_start bfd_void
192 #ifndef MY_bfd_debug_info_end
193 #define MY_bfd_debug_info_end bfd_void
195 #ifndef MY_bfd_debug_info_accumulate
196 #define MY_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
199 #ifndef MY_core_file_failing_command
200 #define MY_core_file_failing_command NAME(aout,core_file_failing_command)
202 #ifndef MY_core_file_failing_signal
203 #define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
205 #ifndef MY_core_file_matches_executable_p
206 #define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
208 #ifndef MY_slurp_armap
209 #define MY_slurp_armap NAME(aout,slurp_armap)
211 #ifndef MY_slurp_extended_name_table
212 #define MY_slurp_extended_name_table NAME(aout,slurp_extended_name_table)
214 #ifndef MY_truncate_arname
215 #define MY_truncate_arname NAME(aout,truncate_arname)
217 #ifndef MY_write_armap
218 #define MY_write_armap NAME(aout,write_armap)
220 #ifndef MY_close_and_cleanup
221 #define MY_close_and_cleanup NAME(aout,close_and_cleanup)
223 #ifndef MY_set_section_contents
224 #define MY_set_section_contents NAME(aout,set_section_contents)
226 #ifndef MY_get_section_contents
227 #define MY_get_section_contents NAME(aout,get_section_contents)
229 #ifndef MY_new_section_hook
230 #define MY_new_section_hook NAME(aout,new_section_hook)
232 #ifndef MY_get_symtab_upper_bound
233 #define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
235 #ifndef MY_get_symtab
236 #define MY_get_symtab NAME(aout,get_symtab)
238 #ifndef MY_get_reloc_upper_bound
239 #define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
241 #ifndef MY_canonicalize_reloc
242 #define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
244 #ifndef MY_make_empty_symbol
245 #define MY_make_empty_symbol NAME(aout,make_empty_symbol)
247 #ifndef MY_print_symbol
248 #define MY_print_symbol NAME(aout,print_symbol)
250 #ifndef MY_get_lineno
251 #define MY_get_lineno NAME(aout,get_lineno)
253 #ifndef MY_set_arch_mach
254 #define MY_set_arch_mach NAME(aout,set_arch_mach)
256 #ifndef MY_openr_next_archived_file
257 #define MY_openr_next_archived_file NAME(aout,openr_next_archived_file)
259 #ifndef MY_find_nearest_line
260 #define MY_find_nearest_line NAME(aout,find_nearest_line)
262 #ifndef MY_generic_stat_arch_elt
263 #define MY_generic_stat_arch_elt NAME(aout,generic_stat_arch_elt)
265 #ifndef MY_sizeof_headers
266 #define MY_sizeof_headers NAME(aout,sizeof_headers)
268 #ifndef MY_bfd_debug_info_start
269 #define MY_bfd_debug_info_start NAME(aout,bfd_debug_info_start)
271 #ifndef MY_bfd_debug_info_end
272 #define MY_bfd_debug_info_end NAME(aout,bfd_debug_info_end)
274 #ifndef MY_bfd_debug_info_accumulat
275 #define MY_bfd_debug_info_accumulat NAME(aout,bfd_debug_info_accumulat)
280 TARGETNAME, /* name */
281 bfd_target_aout_flavour,
282 true, /* target byte order */
283 true, /* target headers byte order */
284 (HAS_RELOC | EXEC_P | /* object flags */
285 HAS_LINENO | HAS_DEBUG |
286 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
287 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
288 ' ', /* ar_pad_char */
289 16, /* ar_max_namelen */
290 1, /* minimum alignment */
291 #ifdef TARGET_IS_BIG_ENDIAN_P
292 _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
293 _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
295 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
296 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */
298 {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
299 bfd_generic_archive_p, MY_core_file_p},
300 {bfd_false, MY_mkobject, /* bfd_set_format */
301 _bfd_generic_mkarchive, bfd_false},
302 {bfd_false, MY_write_object_contents, /* bfd_write_contents */
303 _bfd_write_archive_contents, bfd_false},
305 MY_core_file_failing_command,
306 MY_core_file_failing_signal,
307 MY_core_file_matches_executable_p,
309 MY_slurp_extended_name_table,
312 MY_close_and_cleanup,
313 MY_set_section_contents,
314 MY_get_section_contents,
316 MY_get_symtab_upper_bound,
318 MY_get_reloc_upper_bound,
319 MY_canonicalize_reloc,
320 MY_make_empty_symbol,
324 MY_openr_next_archived_file,
325 MY_find_nearest_line,
326 MY_generic_stat_arch_elt,
328 MY_bfd_debug_info_start,
329 MY_bfd_debug_info_end,
330 MY_bfd_debug_info_accumulate,
331 bfd_generic_get_relocated_section_contents