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