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