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