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