1 @section a.out backends 2 3 4 BFD supports a number of different flavours of a.out format, 5 though the major differences are only the sizes of the 6 structures on disk, and the shape of the relocation 7 information. 8 9 The support is split into a basic support file @file{aoutx.h} 10 and other files which derive functions from the base. One 11 derivation file is @file{aoutf1.h} (for a.out flavour 1), and 12 adds to the basic a.out functions support for sun3, sun4, and 13 386 a.out files, to create a target jump vector for a specific 14 target. 15 16 This information is further split out into more specific files 17 for each machine, including @file{sunos.c} for sun3 and sun4, 18 and @file{demo64.c} for a demonstration of a 64 bit a.out format. 19 20 The base file @file{aoutx.h} defines general mechanisms for 21 reading and writing records to and from disk and various 22 other methods which BFD requires. It is included by 23 @file{aout32.c} and @file{aout64.c} to form the names 24 @code{aout_32_swap_exec_header_in}, @code{aout_64_swap_exec_header_in}, etc. 25 26 As an example, this is what goes on to make the back end for a 27 sun4, from @file{aout32.c}: 28 29 @example 30 #define ARCH_SIZE 32 31 #include "aoutx.h" 32 @end example 33 34 Which exports names: 35 36 @example 37 ... 38 aout_32_canonicalize_reloc 39 aout_32_find_nearest_line 40 aout_32_get_lineno 41 aout_32_get_reloc_upper_bound 42 ... 43 @end example 44 45 from @file{sunos.c}: 46 47 @example 48 #define TARGET_NAME "a.out-sunos-big" 49 #define VECNAME sparc_aout_sunos_be_vec 50 #include "aoutf1.h" 51 @end example 52 53 requires all the names from @file{aout32.c}, and produces the jump vector 54 55 @example 56 sparc_aout_sunos_be_vec 57 @end example 58 59 The file @file{host-aout.c} is a special case. It is for a large set 60 of hosts that use ``more or less standard'' a.out files, and 61 for which cross-debugging is not interesting. It uses the 62 standard 32-bit a.out support routines, but determines the 63 file offsets and addresses of the text, data, and BSS 64 sections, the machine architecture and machine type, and the 65 entry point address, in a host-dependent manner. Once these 66 values have been determined, generic code is used to handle 67 the object file. 68 69 When porting it to run on a new system, you must supply: 70 71 @example 72 HOST_PAGE_SIZE 73 HOST_SEGMENT_SIZE 74 HOST_MACHINE_ARCH (optional) 75 HOST_MACHINE_MACHINE (optional) 76 HOST_TEXT_START_ADDR 77 HOST_STACK_END_ADDR 78 @end example 79 80 in the file @file{../include/sys/h-@var{XXX}.h} (for your host). These 81 values, plus the structures and macros defined in @file{a.out.h} on 82 your host system, will produce a BFD target that will access 83 ordinary a.out files on your host. To configure a new machine 84 to use @file{host-aout.c}, specify: 85 86 @example 87 TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vec 88 TDEPFILES= host-aout.o trad-core.o 89 @end example 90 91 in the @file{config/@var{XXX}.mt} file, and modify @file{configure.ac} 92 to use the 93 @file{@var{XXX}.mt} file (by setting "@code{bfd_target=XXX}") when your 94 configuration is selected. 95 96 @subsection Relocations 97 98 99 The file @file{aoutx.h} provides for both the @emph{standard} 100 and @emph{extended} forms of a.out relocation records. 101 102 The standard records contain only an address, a symbol index, 103 and a type field. The extended records also have a full 104 integer for an addend. 105 106 @subsection Internal entry points 107 108 109 @file{aoutx.h} exports several routines for accessing the 110 contents of an a.out file, which are gathered and exported in 111 turn by various format specific files (eg sunos.c). 112 113 @findex aout_@var{size}_swap_exec_header_in 114 @subsubsection @code{aout_@var{size}_swap_exec_header_in} 115 @deftypefn {Function} void aout_@var{size}_swap_exec_header_in, (bfd *abfd, struct external_exec *bytes, struct internal_exec *execp); 116 Swap the information in an executable header @var{raw_bytes} taken 117 from a raw byte stream memory image into the internal exec header 118 structure @var{execp}. 119 120 @end deftypefn 121 @findex aout_@var{size}_swap_exec_header_out 122 @subsubsection @code{aout_@var{size}_swap_exec_header_out} 123 @deftypefn {Function} bool aout_@var{size}_swap_exec_header_out (bfd *abfd, struct internal_exec *execp, struct external_exec *raw_bytes); 124 Swap the information in an internal exec header structure 125 @var{execp} into the buffer @var{raw_bytes} ready for writing to disk. 126 127 @end deftypefn 128 @findex aout_@var{size}_some_aout_object_p 129 @subsubsection @code{aout_@var{size}_some_aout_object_p} 130 @deftypefn {Function} bfd_cleanup aout_@var{size}_some_aout_object_p (bfd *abfd, struct internal_exec *execp, bfd_cleanup (*callback_to_real_object_p) (bfd *)); 131 Some a.out variant thinks that the file open in @var{abfd} 132 checking is an a.out file. Do some more checking, and set up 133 for access if it really is. Call back to the calling 134 environment's "finish up" function just before returning, to 135 handle any last-minute setup. 136 137 @end deftypefn 138 @findex aout_@var{size}_mkobject 139 @subsubsection @code{aout_@var{size}_mkobject} 140 @deftypefn {Function} bool aout_@var{size}_mkobject, (bfd *abfd); 141 Initialize BFD @var{abfd} for use with a.out files. 142 143 @end deftypefn 144 @findex aout_@var{size}_machine_type 145 @subsubsection @code{aout_@var{size}_machine_type} 146 @deftypefn {Function} enum machine_type aout_@var{size}_machine_type (enum bfd_architecture arch, unsigned long machine, bool *unknown); 147 Keep track of machine architecture and machine type for 148 a.out's. Return the @code{machine_type} for a particular 149 architecture and machine, or @code{M_UNKNOWN} if that exact architecture 150 and machine can't be represented in a.out format. 151 152 If the architecture is understood, machine type 0 (default) 153 is always understood. 154 155 @end deftypefn 156 @findex aout_@var{size}_set_arch_mach 157 @subsubsection @code{aout_@var{size}_set_arch_mach} 158 @deftypefn {Function} bool aout_@var{size}_set_arch_mach, (bfd *, enum bfd_architecture arch, unsigned long machine); 159 Set the architecture and the machine of the BFD @var{abfd} to the 160 values @var{arch} and @var{machine}. Verify that @var{abfd}'s format 161 can support the architecture required. 162 163 @end deftypefn 164 @findex aout_@var{size}_new_section_hook 165 @subsubsection @code{aout_@var{size}_new_section_hook} 166 @deftypefn {Function} bool aout_@var{size}_new_section_hook, (bfd *abfd, asection *newsect); 167 Called by the BFD in response to a @code{bfd_make_section} 168 request. 169 170 @end deftypefn 171