OSDN Git Service

* Makefile.am (ALL_MACHINES): Add cpu-cris.lo.
[pf3gnuchains/pf3gnuchains3x.git] / bfd / libaout.h
1 /* BFD back-end data structures for a.out (and similar) files.
2    Copyright 1990, 91, 92, 93, 94, 95, 96, 97, 1998
3    Free Software Foundation, Inc.
4    Written by Cygnus Support.
5
6 This file is part of BFD, the Binary File Descriptor library.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
21
22 #ifndef LIBAOUT_H
23 #define LIBAOUT_H
24
25 /* We try to encapsulate the differences in the various a.out file
26    variants in a few routines, and otherwise share large masses of code.
27    This means we only have to fix bugs in one place, most of the time.  */
28
29 #include "bfdlink.h"
30
31 /* Parameterize the a.out code based on whether it is being built
32    for a 32-bit architecture or a 64-bit architecture.  */
33 #if ARCH_SIZE==64
34 #define GET_WORD bfd_h_get_64
35 #define GET_SWORD bfd_h_get_signed_64
36 #define PUT_WORD bfd_h_put_64
37 #ifndef NAME
38 #define NAME(x,y) CAT3(x,_64_,y)
39 #endif
40 #define JNAME(x) CAT(x,_64)
41 #define BYTES_IN_WORD 8
42 #else /* ARCH_SIZE == 32 */
43 #define GET_WORD bfd_h_get_32
44 #define GET_SWORD bfd_h_get_signed_32
45 #define PUT_WORD bfd_h_put_32
46 #ifndef NAME
47 #define NAME(x,y) CAT3(x,_32_,y)
48 #endif
49 #define JNAME(x) CAT(x,_32)
50 #define BYTES_IN_WORD 4
51 #endif /* ARCH_SIZE==32 */
52
53 /* Declare at file level, since used in parameter lists, which have
54    weird scope.  */
55 struct external_exec;
56 struct external_nlist;
57 struct reloc_ext_external;
58 struct reloc_std_external;
59 \f
60 /* a.out backend linker hash table entries.  */
61
62 struct aout_link_hash_entry
63 {
64   struct bfd_link_hash_entry root;
65   /* Whether this symbol has been written out.  */
66   boolean written;
67   /* Symbol index in output file.  */
68   int indx;
69 };
70
71 /* a.out backend linker hash table.  */
72
73 struct aout_link_hash_table
74 {
75   struct bfd_link_hash_table root;
76 };
77
78 /* Look up an entry in an a.out link hash table.  */
79
80 #define aout_link_hash_lookup(table, string, create, copy, follow) \
81   ((struct aout_link_hash_entry *) \
82    bfd_link_hash_lookup (&(table)->root, (string), (create), (copy), (follow)))
83
84 /* Traverse an a.out link hash table.  */
85
86 #define aout_link_hash_traverse(table, func, info)                      \
87   (bfd_link_hash_traverse                                               \
88    (&(table)->root,                                                     \
89     (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func),  \
90     (info)))
91
92 /* Get the a.out link hash table from the info structure.  This is
93    just a cast.  */
94
95 #define aout_hash_table(p) ((struct aout_link_hash_table *) ((p)->hash))
96 \f
97 /* Back-end information for various a.out targets.  */
98 struct aout_backend_data
99 {
100   /* Are ZMAGIC files mapped contiguously?  If so, the text section may
101      need more padding, if the segment size (granularity for memory access
102      control) is larger than the page size.  */
103   unsigned char zmagic_mapped_contiguous;
104   /* If this flag is set, ZMAGIC/NMAGIC file headers get mapped in with the
105      text section, which starts immediately after the file header.
106      If not, the text section starts on the next page.  */
107   unsigned char text_includes_header;
108
109   /* If this flag is set, then if the entry address is not in the
110      first SEGMENT_SIZE bytes of the text section, it is taken to be
111      the address of the start of the text section.  This can be useful
112      for kernels.  */
113   unsigned char entry_is_text_address;
114
115   /* The value to pass to N_SET_FLAGS.  */
116   unsigned char exec_hdr_flags;
117
118   /* If the text section VMA isn't specified, and we need an absolute
119      address, use this as the default.  If we're producing a relocatable
120      file, zero is always used.  */
121   /* ?? Perhaps a callback would be a better choice?  Will this do anything
122      reasonable for a format that handles multiple CPUs with different
123      load addresses for each?  */
124   bfd_vma default_text_vma;
125
126   /* Callback for setting the page and segment sizes, if they can't be
127      trivially determined from the architecture.  */
128   boolean (*set_sizes) PARAMS ((bfd *));
129
130   /* zmagic files only. For go32, the length of the exec header contributes
131      to the size of the text section in the file for alignment purposes but
132      does *not* get counted in the length of the text section. */
133   unsigned char exec_header_not_counted;
134
135   /* Callback from the add symbols phase of the linker code to handle
136      a dynamic object.  */
137   boolean (*add_dynamic_symbols) PARAMS ((bfd *, struct bfd_link_info *,
138                                           struct external_nlist **,
139                                           bfd_size_type *, char **));
140
141   /* Callback from the add symbols phase of the linker code to handle
142      adding a single symbol to the global linker hash table.  */
143   boolean (*add_one_symbol) PARAMS ((struct bfd_link_info *, bfd *,
144                                      const char *, flagword, asection *,
145                                      bfd_vma, const char *, boolean,
146                                      boolean,
147                                      struct bfd_link_hash_entry **));
148
149   /* Called to handle linking a dynamic object.  */
150   boolean (*link_dynamic_object) PARAMS ((struct bfd_link_info *, bfd *));
151
152   /* Called for each global symbol being written out by the linker.
153      This should write out the dynamic symbol information.  */
154   boolean (*write_dynamic_symbol) PARAMS ((bfd *, struct bfd_link_info *,
155                                            struct aout_link_hash_entry *));
156
157   /* If this callback is not NULL, the linker calls it for each reloc.
158      RELOC is a pointer to the unswapped reloc.  If *SKIP is set to
159      true, the reloc will be skipped.  *RELOCATION may be changed to
160      change the effects of the relocation.  */
161   boolean (*check_dynamic_reloc) PARAMS ((struct bfd_link_info *info,
162                                           bfd *input_bfd,
163                                           asection *input_section,
164                                           struct aout_link_hash_entry *h,
165                                           PTR reloc, bfd_byte *contents,
166                                           boolean *skip,
167                                           bfd_vma *relocation));
168
169   /* Called at the end of a link to finish up any dynamic linking
170      information.  */
171   boolean (*finish_dynamic_link) PARAMS ((bfd *, struct bfd_link_info *));
172 };
173 #define aout_backend_info(abfd) \
174         ((CONST struct aout_backend_data *)((abfd)->xvec->backend_data))
175
176 /* This is the layout in memory of a "struct exec" while we process it.
177    All 'lengths' are given as a number of bytes.
178    All 'alignments' are for relinkable files only;  an alignment of
179         'n' indicates the corresponding segment must begin at an
180         address that is a multiple of (2**n).  */
181
182 struct internal_exec
183 {
184     long a_info;                /* Magic number and flags, packed */
185     bfd_vma a_text;             /* length of text, in bytes  */
186     bfd_vma a_data;             /* length of data, in bytes  */
187     bfd_vma a_bss;              /* length of uninitialized data area in mem */
188     bfd_vma a_syms;             /* length of symbol table data in file */
189     bfd_vma a_entry;            /* start address */
190     bfd_vma a_trsize;           /* length of text's relocation info, in bytes */
191     bfd_vma a_drsize;           /* length of data's relocation info, in bytes */
192     /* Added for i960 */
193     bfd_vma a_tload;            /* Text runtime load address */
194     bfd_vma a_dload;            /* Data runtime load address */
195     unsigned char a_talign;     /* Alignment of text segment */
196     unsigned char a_dalign;     /* Alignment of data segment */
197     unsigned char a_balign;     /* Alignment of bss segment */
198     char a_relaxable;           /* Enough info for linker relax */
199 };
200
201 /* Magic number is written 
202 < MSB          >
203 3130292827262524232221201918171615141312111009080706050403020100
204 < FLAGS        >< MACHINE TYPE ><  MAGIC NUMBER                >
205 */
206 /* Magic number for NetBSD is
207 <MSB           >
208 3130292827262524232221201918171615141312111009080706050403020100
209 < FLAGS    >< MACHINE TYPE     ><  MAGIC NUMBER                >
210 */
211
212 enum machine_type {
213   M_UNKNOWN = 0,
214   M_68010 = 1,
215   M_68020 = 2,
216   M_SPARC = 3,
217   /* skip a bunch so we don't run into any of suns numbers */
218   /* make these up for the ns32k*/
219   M_NS32032 = (64),             /* ns32032 running ? */
220   M_NS32532 = (64 + 5),         /* ns32532 running mach */
221
222   M_386 = 100,
223   M_29K = 101,          /* AMD 29000 */
224   M_386_DYNIX = 102,    /* Sequent running dynix */
225   M_ARM = 103,          /* Advanced Risc Machines ARM */
226   M_SPARCLET = 131,     /* SPARClet = M_SPARC + 128 */
227   M_386_NETBSD = 134,   /* NetBSD/i386 binary */
228   M_68K_NETBSD = 135,   /* NetBSD/m68k binary */
229   M_68K4K_NETBSD = 136, /* NetBSD/m68k4k binary */
230   M_532_NETBSD = 137,   /* NetBSD/ns32k binary */
231   M_SPARC_NETBSD = 138, /* NetBSD/sparc binary */
232   M_PMAX_NETBSD = 139,  /* NetBSD/pmax (MIPS little-endian) binary */
233   M_VAX_NETBSD = 140,   /* NetBSD/vax binary */
234   M_ALPHA_NETBSD = 141, /* NetBSD/alpha binary */
235   M_ARM6_NETBSD = 143,  /* NetBSD/arm32 binary */
236   M_SPARCLET_1 = 147,   /* 0x93, reserved */
237   M_MIPS1 = 151,        /* MIPS R2000/R3000 binary */
238   M_MIPS2 = 152,        /* MIPS R4000/R6000 binary */
239   M_SPARCLET_2 = 163,   /* 0xa3, reserved */
240   M_SPARCLET_3 = 179,   /* 0xb3, reserved */
241   M_SPARCLET_4 = 195,   /* 0xc3, reserved */
242   M_HP200 = 200,        /* HP 200 (68010) BSD binary */
243   M_HP300 = (300 % 256), /* HP 300 (68020+68881) BSD binary */
244   M_HPUX = (0x20c % 256), /* HP 200/300 HPUX binary */
245   M_SPARCLET_5 = 211,   /* 0xd3, reserved */
246   M_SPARCLET_6 = 227,   /* 0xe3, reserved */
247   /*  M_SPARCLET_7 = 243        / * 0xf3, reserved */
248   M_SPARCLITE_LE = 243,
249   M_CRIS = 255          /* Axis CRIS binary.  */
250 };
251
252 #define N_DYNAMIC(exec) ((exec).a_info & 0x80000000)
253
254 #ifndef N_MAGIC
255 # define N_MAGIC(exec) ((exec).a_info & 0xffff)
256 #endif
257
258 #ifndef N_MACHTYPE
259 # define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
260 #endif
261
262 #ifndef N_FLAGS
263 # define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
264 #endif
265
266 #ifndef N_SET_INFO
267 # define N_SET_INFO(exec, magic, type, flags) \
268 ((exec).a_info = ((magic) & 0xffff) \
269  | (((int)(type) & 0xff) << 16) \
270  | (((flags) & 0xff) << 24))
271 #endif
272
273 #ifndef N_SET_DYNAMIC
274 # define N_SET_DYNAMIC(exec, dynamic) \
275 ((exec).a_info = (dynamic) ? ((exec).a_info | 0x80000000) : \
276 ((exec).a_info & 0x7fffffff))
277 #endif
278
279 #ifndef N_SET_MAGIC
280 # define N_SET_MAGIC(exec, magic) \
281 ((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
282 #endif
283
284 #ifndef N_SET_MACHTYPE
285 # define N_SET_MACHTYPE(exec, machtype) \
286 ((exec).a_info = \
287  ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
288 #endif
289
290 #ifndef N_SET_FLAGS
291 # define N_SET_FLAGS(exec, flags) \
292 ((exec).a_info = \
293  ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
294 #endif
295
296 typedef struct aout_symbol {
297   asymbol symbol;
298   short desc;
299   char other;
300   unsigned char type;
301 } aout_symbol_type;
302
303 /* The `tdata' struct for all a.out-like object file formats.
304    Various things depend on this struct being around any time an a.out
305    file is being handled.  An example is dbxread.c in GDB.  */
306
307 struct aoutdata {
308   struct internal_exec *hdr;            /* exec file header */
309   aout_symbol_type *symbols;            /* symtab for input bfd */
310   
311   /* For ease, we do this */
312   asection *textsec;
313   asection *datasec;
314   asection *bsssec;
315
316   /* We remember these offsets so that after check_file_format, we have
317      no dependencies on the particular format of the exec_hdr.  */
318   file_ptr sym_filepos;
319   file_ptr str_filepos;
320
321   /* Size of a relocation entry in external form */
322   unsigned reloc_entry_size;
323
324   /* Size of a symbol table entry in external form */
325   unsigned symbol_entry_size;
326
327   /* Page size - needed for alignment of demand paged files. */
328   unsigned long page_size;
329
330   /* Segment size - needed for alignment of demand paged files. */
331   unsigned long segment_size;
332
333   /* Zmagic disk block size - need to align the start of the text
334      section in ZMAGIC binaries.  Normally the same as page_size.  */
335   unsigned long zmagic_disk_block_size;
336
337   unsigned exec_bytes_size;
338   unsigned vma_adjusted : 1;
339
340   /* used when a bfd supports several highly similar formats */
341   enum
342     {
343       default_format = 0,
344       /* Used on HP 9000/300 running HP/UX.  See hp300hpux.c.  */
345       gnu_encap_format,
346       /* Used on Linux, 386BSD, etc.  See include/aout/aout64.h.  */
347       q_magic_format
348     } subformat;
349
350   enum
351     {
352       undecided_magic = 0,
353       z_magic,
354       o_magic,
355       n_magic
356     } magic;
357
358   /* A buffer for find_nearest_line.  */
359   char *line_buf;
360
361   /* The external symbol information.  */
362   struct external_nlist *external_syms;
363   bfd_size_type external_sym_count;
364   bfd_window sym_window;
365   char *external_strings;
366   bfd_size_type external_string_size;
367   bfd_window string_window;
368   struct aout_link_hash_entry **sym_hashes;
369
370   /* A pointer for shared library information.  */
371   PTR dynamic_info;
372
373   /* A mapping from local symbols to offsets into the global offset
374      table, used when linking on SunOS.  This is indexed by the symbol
375      index.  */
376   bfd_vma *local_got_offsets;
377 };
378
379 struct  aout_data_struct {
380     struct aoutdata a;
381     struct internal_exec e;
382 };
383
384 #define adata(bfd)              ((bfd)->tdata.aout_data->a)
385 #define exec_hdr(bfd)           (adata(bfd).hdr)
386 #define obj_aout_symbols(bfd)   (adata(bfd).symbols)
387 #define obj_textsec(bfd)        (adata(bfd).textsec)
388 #define obj_datasec(bfd)        (adata(bfd).datasec)
389 #define obj_bsssec(bfd)         (adata(bfd).bsssec)
390 #define obj_sym_filepos(bfd)    (adata(bfd).sym_filepos)
391 #define obj_str_filepos(bfd)    (adata(bfd).str_filepos)
392 #define obj_reloc_entry_size(bfd) (adata(bfd).reloc_entry_size)
393 #define obj_symbol_entry_size(bfd) (adata(bfd).symbol_entry_size)
394 #define obj_aout_subformat(bfd) (adata(bfd).subformat)
395 #define obj_aout_external_syms(bfd) (adata(bfd).external_syms)
396 #define obj_aout_external_sym_count(bfd) (adata(bfd).external_sym_count)
397 #define obj_aout_sym_window(bfd) (adata(bfd).sym_window)
398 #define obj_aout_external_strings(bfd) (adata(bfd).external_strings)
399 #define obj_aout_external_string_size(bfd) (adata(bfd).external_string_size)
400 #define obj_aout_string_window(bfd) (adata(bfd).string_window)
401 #define obj_aout_sym_hashes(bfd) (adata(bfd).sym_hashes)
402 #define obj_aout_dynamic_info(bfd) (adata(bfd).dynamic_info)
403
404 /* We take the address of the first element of an asymbol to ensure that the
405    macro is only ever applied to an asymbol */
406 #define aout_symbol(asymbol) ((aout_symbol_type *)(&(asymbol)->the_bfd))
407
408 /* Information we keep for each a.out section.  This is currently only
409    used by the a.out backend linker.  */
410
411 struct aout_section_data_struct
412 {
413   /* The unswapped relocation entries for this section.  */
414   PTR relocs;
415 };
416
417 #define aout_section_data(s) \
418   ((struct aout_section_data_struct *) (s)->used_by_bfd)
419
420 #define set_aout_section_data(s,v) \
421   ((s)->used_by_bfd = (PTR)&(v)->relocs)
422
423 /* Prototype declarations for functions defined in aoutx.h  */
424
425 boolean
426 NAME(aout,squirt_out_relocs) PARAMS ((bfd *abfd, asection *section));
427
428 boolean
429 NAME(aout,make_sections) PARAMS ((bfd *));
430
431 const bfd_target *
432 NAME(aout,some_aout_object_p) PARAMS ((bfd *abfd,
433                                        struct internal_exec *execp,
434                                        const bfd_target *(*callback)(bfd *)));
435
436 boolean
437 NAME(aout,mkobject) PARAMS ((bfd *abfd));
438
439 enum machine_type
440 NAME(aout,machine_type) PARAMS ((enum bfd_architecture arch,
441                                  unsigned long machine,
442                                  boolean *unknown));
443
444 boolean
445 NAME(aout,set_arch_mach) PARAMS ((bfd *abfd, enum bfd_architecture arch,
446                                   unsigned long machine));
447
448 boolean
449 NAME(aout,new_section_hook) PARAMS ((bfd *abfd, asection *newsect));
450
451 boolean
452 NAME(aout,set_section_contents) PARAMS ((bfd *abfd, sec_ptr section,
453                          PTR location, file_ptr offset, bfd_size_type count));
454
455 asymbol *
456 NAME(aout,make_empty_symbol) PARAMS ((bfd *abfd));
457
458 boolean
459 NAME(aout,translate_symbol_table) PARAMS ((bfd *, aout_symbol_type *,
460                                            struct external_nlist *,
461                                            bfd_size_type, char *,
462                                            bfd_size_type,
463                                            boolean dynamic));
464
465 boolean
466 NAME(aout,slurp_symbol_table) PARAMS ((bfd *abfd));
467
468 boolean
469 NAME(aout,write_syms) PARAMS ((bfd *abfd));
470
471 void
472 NAME(aout,reclaim_symbol_table) PARAMS ((bfd *abfd));
473
474 long
475 NAME(aout,get_symtab_upper_bound) PARAMS ((bfd *abfd));
476
477 long
478 NAME(aout,get_symtab) PARAMS ((bfd *abfd, asymbol **location));
479
480 void
481 NAME(aout,swap_ext_reloc_in) PARAMS ((bfd *, struct reloc_ext_external *,
482                                       arelent *, asymbol **, bfd_size_type));
483 void
484 NAME(aout,swap_std_reloc_in) PARAMS ((bfd *, struct reloc_std_external *,
485                                       arelent *, asymbol **, bfd_size_type));
486
487 reloc_howto_type *
488 NAME(aout,reloc_type_lookup) PARAMS ((bfd *abfd,
489                                       bfd_reloc_code_real_type code));
490
491 boolean
492 NAME(aout,slurp_reloc_table) PARAMS ((bfd *abfd, sec_ptr asect,
493                                       asymbol **symbols));
494
495 long
496 NAME(aout,canonicalize_reloc) PARAMS ((bfd *abfd, sec_ptr section,
497                                        arelent **relptr, asymbol **symbols));
498
499 long
500 NAME(aout,get_reloc_upper_bound) PARAMS ((bfd *abfd, sec_ptr asect));
501
502 void
503 NAME(aout,reclaim_reloc) PARAMS ((bfd *ignore_abfd, sec_ptr ignore));
504
505 alent *
506 NAME(aout,get_lineno) PARAMS ((bfd *ignore_abfd, asymbol *ignore_symbol));
507
508 void
509 NAME(aout,print_symbol) PARAMS ((bfd *ignore_abfd, PTR file,
510                             asymbol *symbol, bfd_print_symbol_type how));
511
512 void
513 NAME(aout,get_symbol_info) PARAMS ((bfd *ignore_abfd,
514                            asymbol *symbol, symbol_info *ret));
515
516 boolean
517 NAME(aout,find_nearest_line) PARAMS ((bfd *abfd, asection *section,
518       asymbol **symbols, bfd_vma offset, CONST char **filename_ptr,
519       CONST char **functionname_ptr, unsigned int *line_ptr));
520
521 long
522 NAME(aout,read_minisymbols) PARAMS ((bfd *, boolean, PTR *, unsigned int *));
523
524 asymbol *
525 NAME(aout,minisymbol_to_symbol) PARAMS ((bfd *, boolean, const PTR,
526                                          asymbol *));
527
528 int
529 NAME(aout,sizeof_headers) PARAMS ((bfd *abfd, boolean exec));
530
531 boolean
532 NAME(aout,adjust_sizes_and_vmas) PARAMS ((bfd *abfd,
533        bfd_size_type *text_size, file_ptr *text_end));
534
535 void
536 NAME(aout,swap_exec_header_in) PARAMS ((bfd *abfd,
537        struct external_exec *raw_bytes, struct internal_exec *execp));
538
539 void
540 NAME(aout,swap_exec_header_out) PARAMS ((bfd *abfd,
541        struct internal_exec *execp, struct external_exec *raw_bytes));
542
543 struct bfd_hash_entry *
544 NAME(aout,link_hash_newfunc)
545   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
546
547 boolean
548 NAME(aout,link_hash_table_init)
549      PARAMS ((struct aout_link_hash_table *, bfd *,
550               struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
551                                           struct bfd_hash_table *,
552                                           const char *)));
553
554 struct bfd_link_hash_table *
555 NAME(aout,link_hash_table_create) PARAMS ((bfd *));
556
557 boolean
558 NAME(aout,link_add_symbols) PARAMS ((bfd *, struct bfd_link_info *));
559
560 boolean
561 NAME(aout,final_link) PARAMS ((bfd *, struct bfd_link_info *,
562                                void (*) (bfd *, file_ptr *, file_ptr *,
563                                          file_ptr *)));
564
565 boolean
566 NAME(aout,bfd_free_cached_info) PARAMS ((bfd *));
567
568 /* A.out uses the generic versions of these routines... */
569
570 #define aout_32_get_section_contents    _bfd_generic_get_section_contents
571
572 #define aout_64_get_section_contents    _bfd_generic_get_section_contents
573 #ifndef NO_WRITE_HEADER_KLUDGE
574 #define NO_WRITE_HEADER_KLUDGE 0
575 #endif
576
577 #ifndef aout_32_bfd_is_local_label_name
578 #define aout_32_bfd_is_local_label_name bfd_generic_is_local_label_name
579 #endif
580
581 #ifndef WRITE_HEADERS
582 #define WRITE_HEADERS(abfd, execp)                                            \
583       {                                                                       \
584         bfd_size_type text_size; /* dummy vars */                             \
585         file_ptr text_end;                                                    \
586         if (adata(abfd).magic == undecided_magic)                             \
587           NAME(aout,adjust_sizes_and_vmas) (abfd, &text_size, &text_end);     \
588                                                                               \
589         execp->a_syms = bfd_get_symcount (abfd) * EXTERNAL_NLIST_SIZE;        \
590         execp->a_entry = bfd_get_start_address (abfd);                        \
591                                                                               \
592         execp->a_trsize = ((obj_textsec (abfd)->reloc_count) *                \
593                            obj_reloc_entry_size (abfd));                      \
594         execp->a_drsize = ((obj_datasec (abfd)->reloc_count) *                \
595                            obj_reloc_entry_size (abfd));                      \
596         NAME(aout,swap_exec_header_out) (abfd, execp, &exec_bytes);           \
597                                                                               \
598         if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) return false;       \
599         if (bfd_write ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)           \
600             != EXEC_BYTES_SIZE)                                               \
601           return false;                                                       \
602         /* Now write out reloc info, followed by syms and strings */          \
603                                                                               \
604         if (bfd_get_outsymbols (abfd) != (asymbol **) NULL                    \
605             && bfd_get_symcount (abfd) != 0)                                  \
606           {                                                                   \
607             if (bfd_seek (abfd, (file_ptr)(N_SYMOFF(*execp)), SEEK_SET) != 0) \
608               return false;                                                   \
609                                                                               \
610             if (! NAME(aout,write_syms)(abfd)) return false;                  \
611           }                                                                   \
612                                                                               \
613         if (bfd_seek (abfd, (file_ptr)(N_TRELOFF(*execp)), SEEK_SET) != 0)    \
614           return false;                                                       \
615         if (!NAME(aout,squirt_out_relocs) (abfd, obj_textsec (abfd)))         \
616           return false;                                                       \
617                                                                               \
618         if (bfd_seek (abfd, (file_ptr)(N_DRELOFF(*execp)), SEEK_SET) != 0)    \
619           return false;                                                       \
620         if (!NAME(aout,squirt_out_relocs)(abfd, obj_datasec (abfd)))          \
621           return false;                                                       \
622       }                                                                       
623 #endif
624
625 #endif /* ! defined (LIBAOUT_H) */