source: vendor/binutils/current/bfd/libaout.h

Last change on this file was 609, checked in by bird, 22 years ago

binutils v2.14 - offical sources.

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