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