OSDN Git Service

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