1 /* BFD back-end data structures for a.out (and similar) files.
3 We try to encapsulate the differences in a few routines, and otherwise
4 share large masses of code. This means we only have to fix bugs in
5 one place, most of the time. */
7 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
9 This file is part of BFD, the Binary File Diddler.
11 BFD is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 1, or (at your option)
16 BFD is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with BFD; see the file COPYING. If not, write to
23 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
27 #define adata(bfd) ((struct aoutdata *) ((bfd)->tdata))
28 #define exec_hdr(bfd) (adata(bfd)->hdr)
29 #define obj_textsec(bfd) (adata(bfd)->textsec)
30 #define obj_datasec(bfd) (adata(bfd)->datasec)
31 #define obj_bsssec(bfd) (adata(bfd)->bsssec)
32 #define obj_sym_filepos(bfd) (adata(bfd)->sym_filepos)
33 #define obj_str_filepos(bfd) (adata(bfd)->str_filepos)
35 #define obj_reloc_entry_size(bfd) (adata(bfd)->reloc_entry_size)
37 typedef struct aout_symbol {
45 struct exec *hdr; /* exec file header */
46 aout_symbol_type *symbols; /* symtab for input bfd */
49 /* For ease, we do this */
54 /* We remember these offsets so that after check_file_format, we have
55 no dependencies on the particular format of the exec_hdr. */
59 /* Size of a relocation entry */
60 unsigned reloc_entry_size;
64 #define obj_outsymbols(bfd) ((PTR)(((struct aoutdata *) ((bfd)->tdata))->outsymbols))
67 /* We take the address of the first element of an asymbol to ensure that the
68 * macro is only ever applied to an asymbol */
69 #define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd))
71 /*#define obj_symbols(bfd) ((((struct aoutdata *) ((bfd)->tdata))->symbols))*/
72 #define obj_aout_symbols(bfd) ((((struct aoutdata *) (bfd)->tdata))->symbols)
73 #define obj_arch_flags(bfd) ((((struct aoutdata *) (bfd)->tdata))->arch_flags)
75 #define get_tdata(x) ((struct aoutdata *)((x)->tdata))
77 /* Prototype declarations for functions defined in aout.c. */
79 PROTO (boolean, aout_squirt_out_relocs,(bfd *abfd, asection *section));
81 PROTO (bfd_target *, some_aout_object_p, (bfd *abfd,
82 bfd_target *(*callback)()));
83 PROTO (boolean, aout_mkobject, (bfd *abfd));
84 PROTO (enum machine_type, aout_machine_type, (enum bfd_architecture arch,
85 unsigned long machine));
86 PROTO (boolean, aout_set_arch_mach, (bfd *abfd, enum bfd_architecture arch,
87 unsigned long machine));
89 PROTO (boolean, aout_new_section_hook, (bfd *abfd, asection *newsect));
90 PROTO (boolean, aout_set_section_contents, (bfd *abfd, sec_ptr section,
91 PTR location, file_ptr offset, int count));
93 PROTO (asymbol *, aout_make_empty_symbol, (bfd *abfd));
94 PROTO (boolean, aout_slurp_symbol_table, (bfd *abfd));
95 PROTO (void, aout_write_syms, (bfd *abfd));
96 PROTO (void, aout_reclaim_symbol_table, (bfd *abfd));
97 PROTO (unsigned int, aout_get_symtab_upper_bound, (bfd *abfd));
98 PROTO (unsigned int, aout_get_symtab, (bfd *abfd, asymbol **location));
99 PROTO (boolean, aout_slurp_reloc_table, (bfd *abfd, sec_ptr asect,
101 PROTO (unsigned int, aout_canonicalize_reloc, (bfd *abfd, sec_ptr section,
102 arelent **relptr, asymbol **symbols));
103 PROTO (unsigned int, aout_get_reloc_upper_bound, (bfd *abfd, sec_ptr asect));
104 PROTO (void, aout_reclaim_reloc, (bfd *ignore_abfd, sec_ptr ignore));
105 PROTO (alent *, aout_get_lineno, (bfd *ignore_abfd, asymbol *ignore_symbol));
106 PROTO (void, aout_print_symbol, (bfd *ignore_abfd, PTR file,
107 asymbol *symbol, bfd_print_symbol_enum_type how));
108 PROTO (boolean, aout_close_and_cleanup, (bfd *abfd));
109 PROTO (boolean, aout_find_nearest_line, (bfd *abfd, asection *section,
110 asymbol **symbols, bfd_vma offset, CONST char **filename_ptr,
111 CONST char **functionname_ptr, unsigned int *line_ptr));
112 PROTO (int, aout_sizeof_headers, (bfd *ignore_abfd));
114 /* Helper routines in aout.c. */
116 PROTO (void, bfd_aout_swap_exec_header_in, (bfd *abfd,
117 unsigned char *raw_bytes, struct exec *execp));
119 PROTO (void, bfd_aout_swap_exec_header_out,(bfd *abfd, struct exec *execp,
120 unsigned char *raw_bytes));
122 /* A.out uses the generic versions of these routines... */
124 #define aout_get_section_contents bfd_generic_get_section_contents
125 #define aout_close_and_cleanup bfd_generic_close_and_cleanup