Update to match revised bfd-in.h.
[deliverable/binutils-gdb.git] / bfd / aout-target.h
CommitLineData
582bc90a 1/* Define a target vector and some small routines for a variant of a.out.
e98e6ec1
SC
2 Copyright (C) 1990-1991 Free Software Foundation, Inc.
3
4This file is part of BFD, the Binary File Descriptor library.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
582bc90a
PB
20#include "aout/aout64.h"
21#include "aout/stab_gnu.h"
22#include "aout/ar.h"
23/*#include "libaout.h"*/
24
214f8f23
KR
25extern CONST struct reloc_howto_struct * NAME(aout,reloc_type_lookup) ();
26
e98e6ec1
SC
27/* Set parameters about this a.out file that are machine-dependent.
28 This routine is called from some_aout_object_p just before it returns. */
214f8f23 29#ifndef MY_callback
e98e6ec1
SC
30static bfd_target *
31DEFUN(MY(callback),(abfd),
32 bfd *abfd)
33{
34 struct internal_exec *execp = exec_hdr (abfd);
294eaca4
SC
35
36 /* Calculate the file positions of the parts of a newly read aout header */
e98e6ec1
SC
37 obj_textsec (abfd)->_raw_size = N_TXTSIZE(*execp);
38
39 /* The virtual memory addresses of the sections */
40 obj_textsec (abfd)->vma = N_TXTADDR(*execp);
41 obj_datasec (abfd)->vma = N_DATADDR(*execp);
42 obj_bsssec (abfd)->vma = N_BSSADDR(*execp);
43
44 /* The file offsets of the sections */
45 obj_textsec (abfd)->filepos = N_TXTOFF (*execp);
46 obj_datasec (abfd)->filepos = N_DATOFF (*execp);
47
48 /* The file offsets of the relocation info */
49 obj_textsec (abfd)->rel_filepos = N_TRELOFF(*execp);
50 obj_datasec (abfd)->rel_filepos = N_DRELOFF(*execp);
51
52 /* The file offsets of the string table and symbol table. */
53 obj_sym_filepos (abfd) = N_SYMOFF (*execp);
54 obj_str_filepos (abfd) = N_STROFF (*execp);
55
582bc90a 56 /* Determine the architecture and machine type of the object file. */
e98e6ec1
SC
57#ifdef SET_ARCH_MACH
58 SET_ARCH_MACH(abfd, *execp);
59#else
60 bfd_default_set_arch_mach(abfd, DEFAULT_ARCH, 0);
61#endif
62
294eaca4
SC
63 /* Don't set sizes now -- can't be sure until we know arch & mach.
64 Sizes get set in set_sizes callback, later. */
65#if 0
e98e6ec1
SC
66 adata(abfd).page_size = PAGE_SIZE;
67#ifdef SEGMENT_SIZE
68 adata(abfd).segment_size = SEGMENT_SIZE;
69#else
70 adata(abfd).segment_size = PAGE_SIZE;
71#endif
72 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
294eaca4 73#endif
e98e6ec1
SC
74
75 return abfd->xvec;
76}
214f8f23 77#endif
e98e6ec1
SC
78
79#ifndef MY_object_p
80/* Finish up the reading of an a.out file header */
81
82static bfd_target *
83DEFUN(MY(object_p),(abfd),
84 bfd *abfd)
85{
86 struct external_exec exec_bytes; /* Raw exec header from file */
87 struct internal_exec exec; /* Cleaned-up exec header */
88 bfd_target *target;
89
90 if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
91 != EXEC_BYTES_SIZE) {
92 bfd_error = wrong_format;
93 return 0;
94 }
95
96 exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
97
98 if (N_BADMAG (exec)) return 0;
99
100 NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
101 target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
102
103#ifdef ENTRY_CAN_BE_ZERO
104 /* The NEWSOS3 entry-point is/was 0, which (amongst other lossage)
105 * means that it isn't obvious if EXEC_P should be set.
106 * All of the following must be true for an executable:
107 * There must be no relocations, the bfd can be neither an
108 * archive nor an archive element, and the file must be executable. */
109
110 if (exec.a_trsize + exec.a_drsize == 0
111 && bfd_get_format(abfd) == bfd_object && abfd->my_archive == NULL)
112 {
113 struct stat buf;
114#ifndef S_IXUSR
115#define S_IXUSR 0100 /* Execute by owner. */
116#endif
117 if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR))
118 abfd->flags |= EXEC_P;
119 }
120#endif /* ENTRY_CAN_BE_ZERO */
121
122 return target;
123}
124#define MY_object_p MY(object_p)
125#endif
126
127
128#ifndef MY_mkobject
129static boolean
130DEFUN(MY(mkobject),(abfd),
131 bfd *abfd)
132{
133 if (NAME(aout,mkobject)(abfd) == false)
134 return false;
294eaca4
SC
135#if 0 /* Sizes get set in set_sizes callback, later, after we know
136 the architecture and machine. */
e98e6ec1
SC
137 adata(abfd).page_size = PAGE_SIZE;
138#ifdef SEGMENT_SIZE
139 adata(abfd).segment_size = SEGMENT_SIZE;
140#else
141 adata(abfd).segment_size = PAGE_SIZE;
142#endif
143 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
294eaca4 144#endif
e98e6ec1
SC
145 return true;
146}
147#define MY_mkobject MY(mkobject)
148#endif
149
150/* Write an object file.
151 Section contents have already been written. We write the
152 file header, symbols, and relocation. */
153
154#ifndef MY_write_object_contents
155static boolean
156DEFUN(MY(write_object_contents),(abfd),
157 bfd *abfd)
158{
e98e6ec1
SC
159 struct external_exec exec_bytes;
160 struct internal_exec *execp = exec_hdr (abfd);
161
582bc90a
PB
162#if CHOOSE_RELOC_SIZE
163 CHOOSE_RELOC_SIZE(abfd);
164#else
165 obj_reloc_entry_size (abfd) = RELOC_STD_SIZE;
166#endif
167
e98e6ec1 168 WRITE_HEADERS(abfd, execp);
582bc90a 169
e98e6ec1
SC
170 return true;
171}
172#define MY_write_object_contents MY(write_object_contents)
173#endif
174
294eaca4
SC
175#ifndef MY_set_sizes
176static boolean
177DEFUN(MY(set_sizes),(abfd), bfd *abfd)
178{
179 adata(abfd).page_size = PAGE_SIZE;
180#ifdef SEGMENT_SIZE
181 adata(abfd).segment_size = SEGMENT_SIZE;
182#else
183 adata(abfd).segment_size = PAGE_SIZE;
184#endif
185 adata(abfd).exec_bytes_size = EXEC_BYTES_SIZE;
186 return true;
187}
188#define MY_set_sizes MY(set_sizes)
189#endif
190
191#ifndef MY_backend_data
192static CONST struct aout_backend_data MY(backend_data) = {
193 0, /* zmagic contiguous */
194 0, /* text incl header */
195 0, /* text vma? */
196 MY_set_sizes,
197};
198#define MY_backend_data &MY(backend_data)
199#endif
200
e98e6ec1
SC
201/* We assume BFD generic archive files. */
202#ifndef MY_openr_next_archived_file
203#define MY_openr_next_archived_file bfd_generic_openr_next_archived_file
204#endif
205#ifndef MY_generic_stat_arch_elt
206#define MY_generic_stat_arch_elt bfd_generic_stat_arch_elt
207#endif
208#ifndef MY_slurp_armap
209#define MY_slurp_armap bfd_slurp_bsd_armap
210#endif
211#ifndef MY_slurp_extended_name_table
582bc90a 212#define MY_slurp_extended_name_table _bfd_slurp_extended_name_table
e98e6ec1
SC
213#endif
214#ifndef MY_write_armap
215#define MY_write_armap bsd_write_armap
216#endif
217#ifndef MY_truncate_arname
218#define MY_truncate_arname bfd_bsd_truncate_arname
219#endif
220
221/* No core file defined here -- configure in trad-core.c separately. */
222#ifndef MY_core_file_failing_command
223#define MY_core_file_failing_command _bfd_dummy_core_file_failing_command
224#endif
225#ifndef MY_core_file_failing_signal
226#define MY_core_file_failing_signal _bfd_dummy_core_file_failing_signal
227#endif
228#ifndef MY_core_file_matches_executable_p
229#define MY_core_file_matches_executable_p \
230 _bfd_dummy_core_file_matches_executable_p
231#endif
232#ifndef MY_core_file_p
233#define MY_core_file_p _bfd_dummy_target
234#endif
235
236#ifndef MY_bfd_debug_info_start
237#define MY_bfd_debug_info_start bfd_void
238#endif
239#ifndef MY_bfd_debug_info_end
240#define MY_bfd_debug_info_end bfd_void
241#endif
242#ifndef MY_bfd_debug_info_accumulate
243#define MY_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
244#endif
245
246#ifndef MY_core_file_failing_command
247#define MY_core_file_failing_command NAME(aout,core_file_failing_command)
248#endif
249#ifndef MY_core_file_failing_signal
250#define MY_core_file_failing_signal NAME(aout,core_file_failing_signal)
251#endif
252#ifndef MY_core_file_matches_executable_p
253#define MY_core_file_matches_executable_p NAME(aout,core_file_matches_executable_p)
254#endif
255#ifndef MY_slurp_armap
256#define MY_slurp_armap NAME(aout,slurp_armap)
257#endif
258#ifndef MY_slurp_extended_name_table
259#define MY_slurp_extended_name_table NAME(aout,slurp_extended_name_table)
260#endif
261#ifndef MY_truncate_arname
262#define MY_truncate_arname NAME(aout,truncate_arname)
263#endif
264#ifndef MY_write_armap
265#define MY_write_armap NAME(aout,write_armap)
266#endif
267#ifndef MY_close_and_cleanup
268#define MY_close_and_cleanup NAME(aout,close_and_cleanup)
269#endif
270#ifndef MY_set_section_contents
271#define MY_set_section_contents NAME(aout,set_section_contents)
272#endif
273#ifndef MY_get_section_contents
274#define MY_get_section_contents NAME(aout,get_section_contents)
275#endif
276#ifndef MY_new_section_hook
277#define MY_new_section_hook NAME(aout,new_section_hook)
278#endif
279#ifndef MY_get_symtab_upper_bound
280#define MY_get_symtab_upper_bound NAME(aout,get_symtab_upper_bound)
281#endif
282#ifndef MY_get_symtab
283#define MY_get_symtab NAME(aout,get_symtab)
284#endif
285#ifndef MY_get_reloc_upper_bound
286#define MY_get_reloc_upper_bound NAME(aout,get_reloc_upper_bound)
287#endif
288#ifndef MY_canonicalize_reloc
289#define MY_canonicalize_reloc NAME(aout,canonicalize_reloc)
290#endif
291#ifndef MY_make_empty_symbol
292#define MY_make_empty_symbol NAME(aout,make_empty_symbol)
293#endif
294#ifndef MY_print_symbol
295#define MY_print_symbol NAME(aout,print_symbol)
296#endif
297#ifndef MY_get_lineno
298#define MY_get_lineno NAME(aout,get_lineno)
299#endif
300#ifndef MY_set_arch_mach
301#define MY_set_arch_mach NAME(aout,set_arch_mach)
302#endif
303#ifndef MY_openr_next_archived_file
304#define MY_openr_next_archived_file NAME(aout,openr_next_archived_file)
305#endif
306#ifndef MY_find_nearest_line
307#define MY_find_nearest_line NAME(aout,find_nearest_line)
308#endif
309#ifndef MY_generic_stat_arch_elt
310#define MY_generic_stat_arch_elt NAME(aout,generic_stat_arch_elt)
311#endif
312#ifndef MY_sizeof_headers
313#define MY_sizeof_headers NAME(aout,sizeof_headers)
314#endif
315#ifndef MY_bfd_debug_info_start
316#define MY_bfd_debug_info_start NAME(aout,bfd_debug_info_start)
317#endif
318#ifndef MY_bfd_debug_info_end
319#define MY_bfd_debug_info_end NAME(aout,bfd_debug_info_end)
320#endif
321#ifndef MY_bfd_debug_info_accumulat
322#define MY_bfd_debug_info_accumulat NAME(aout,bfd_debug_info_accumulat)
323#endif
582bc90a 324#ifndef MY_reloc_howto_type_lookup
214f8f23 325#define MY_reloc_howto_type_lookup NAME(aout,reloc_type_lookup)
582bc90a
PB
326#endif
327#ifndef MY_make_debug_symbol
328#define MY_make_debug_symbol 0
329#endif
294eaca4
SC
330
331/* Aout symbols normally have leading underscores */
332#ifndef MY_symbol_leading_char
333#define MY_symbol_leading_char '_'
582bc90a 334#endif
e98e6ec1
SC
335
336bfd_target MY(vec) =
337{
338 TARGETNAME, /* name */
339 bfd_target_aout_flavour,
582bc90a
PB
340#ifdef TARGET_IS_BIG_ENDIAN_P
341 true, /* target byte order (big) */
342 true, /* target headers byte order (big) */
343#else
344 false, /* target byte order (little) */
345 false, /* target headers byte order (little) */
346#endif
e98e6ec1
SC
347 (HAS_RELOC | EXEC_P | /* object flags */
348 HAS_LINENO | HAS_DEBUG |
349 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
350 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
294eaca4 351 MY_symbol_leading_char,
e98e6ec1 352 ' ', /* ar_pad_char */
582bc90a 353 15, /* ar_max_namelen */
e98e6ec1
SC
354 1, /* minimum alignment */
355#ifdef TARGET_IS_BIG_ENDIAN_P
356 _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */
357 _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */
358#else
359 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */
360 _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */
361#endif
362 {_bfd_dummy_target, MY_object_p, /* bfd_check_format */
363 bfd_generic_archive_p, MY_core_file_p},
364 {bfd_false, MY_mkobject, /* bfd_set_format */
365 _bfd_generic_mkarchive, bfd_false},
366 {bfd_false, MY_write_object_contents, /* bfd_write_contents */
367 _bfd_write_archive_contents, bfd_false},
368
369 MY_core_file_failing_command,
370 MY_core_file_failing_signal,
371 MY_core_file_matches_executable_p,
372 MY_slurp_armap,
373 MY_slurp_extended_name_table,
374 MY_truncate_arname,
375 MY_write_armap,
376 MY_close_and_cleanup,
377 MY_set_section_contents,
378 MY_get_section_contents,
379 MY_new_section_hook,
380 MY_get_symtab_upper_bound,
381 MY_get_symtab,
382 MY_get_reloc_upper_bound,
383 MY_canonicalize_reloc,
384 MY_make_empty_symbol,
385 MY_print_symbol,
386 MY_get_lineno,
387 MY_set_arch_mach,
388 MY_openr_next_archived_file,
389 MY_find_nearest_line,
390 MY_generic_stat_arch_elt,
391 MY_sizeof_headers,
392 MY_bfd_debug_info_start,
393 MY_bfd_debug_info_end,
394 MY_bfd_debug_info_accumulate,
582bc90a
PB
395 bfd_generic_get_relocated_section_contents,
396 bfd_generic_relax_section,
397 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* COFF stuff?! */
398 MY_reloc_howto_type_lookup,
399 MY_make_debug_symbol,
400 (PTR) MY_backend_data,
e98e6ec1 401};
This page took 0.053392 seconds and 4 git commands to generate.