From: Ian Lance Taylor Date: Tue, 14 Jun 1994 22:04:54 +0000 (+0000) Subject: * libaout.h (struct aoutdata): Add q_magic_format to subformat X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f5419a59085477c1839bb5c0f74de178070d536e;p=binutils-gdb.git * libaout.h (struct aoutdata): Add q_magic_format to subformat enum. * aout-target.h (MY_bfd_copy_private_bfd_data): Define as function if not already defined. Copy subformat information. (MY_text_includes_header): Define as 0 if not already defined. (MY(backend_data)): Use MY_text_includes_header rather than 0. (MY_final_link_callback): Rename from final_link_callback, and define only if MY_final_link_callback is not already defined. (MY_bfd_final_link): Rename use of final_link_callback to MY_final_link_callback. * aoutx.h (NAME(aout,some_aout_object_p)): Handle QMAGIC like ZMAGIC, but set the subformat to q_magic_format. Abort if the magic number if not recognized. (adjust_z_magic): Use QMAGIC if q_magic_format. * i386linux.c (MY_text_includes_header): Define as 1. (i386linux_bfd_final_link): New static function. (MY_bfd_final_link): Define as i386linux_bfd_final_link. * aoutx.h (translate_to_native_sym_flags): Check both section and output_section against sections of abfd. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8e7fc5a1731..66b9d3fb986 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,26 @@ Tue Jun 14 13:00:04 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + * libaout.h (struct aoutdata): Add q_magic_format to subformat + enum. + * aout-target.h (MY_bfd_copy_private_bfd_data): Define as function + if not already defined. Copy subformat information. + (MY_text_includes_header): Define as 0 if not already defined. + (MY(backend_data)): Use MY_text_includes_header rather than 0. + (MY_final_link_callback): Rename from final_link_callback, and + define only if MY_final_link_callback is not already defined. + (MY_bfd_final_link): Rename use of final_link_callback to + MY_final_link_callback. + * aoutx.h (NAME(aout,some_aout_object_p)): Handle QMAGIC like + ZMAGIC, but set the subformat to q_magic_format. Abort if the + magic number if not recognized. + (adjust_z_magic): Use QMAGIC if q_magic_format. + * i386linux.c (MY_text_includes_header): Define as 1. + (i386linux_bfd_final_link): New static function. + (MY_bfd_final_link): Define as i386linux_bfd_final_link. + + * aoutx.h (translate_to_native_sym_flags): Check both section and + output_section against sections of abfd. + * libecoff.h (struct ecoff_link_hash_entry): Change type of written from boolean to char. Add new field small. * ecoff.c (ecoff_link_hash_newfunc): Initialize written to 0 diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 68cda6c5f62..2ee6ff43f3d 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -1,5 +1,5 @@ /* Define a target vector and some small routines for a variant of a.out. - Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc. + Copyright (C) 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -155,6 +155,28 @@ MY(mkobject) (abfd) #define MY_mkobject MY(mkobject) #endif +#ifndef MY_bfd_copy_private_section_data + +/* Copy private section data. This actually does nothing with the + sections. It copies the subformat field. We copy it here, because + we know whether this is a QMAGIC file before we set the section + contents, and copy_private_bfd_data is not called until after the + section contents have been set. */ + +/*ARGSUSED*/ +static boolean +MY_bfd_copy_private_section_data (ibfd, isec, obfd, osec) + bfd *ibfd; + asection *isec; + bfd *obfd; + asection *osec; +{ + obj_aout_subformat (obfd) = obj_aout_subformat (ibfd); + return true; +} + +#endif + /* Write an object file. Section contents have already been written. We write the file header, symbols, and relocation. */ @@ -197,37 +219,60 @@ MY(set_sizes) (abfd) #define MY_set_sizes MY(set_sizes) #endif +#ifndef MY_exec_hdr_flags +#define MY_exec_hdr_flags 0 +#endif + #ifndef MY_backend_data -#ifndef MY_read_dynamic_symbols -#define MY_read_dynamic_symbols 0 +#ifndef MY_text_includes_header +#define MY_text_includes_header 0 +#endif +#ifndef MY_add_dynamic_symbols +#define MY_add_dynamic_symbols 0 +#endif +#ifndef MY_add_one_symbol +#define MY_add_one_symbol 0 +#endif +#ifndef MY_link_dynamic_object +#define MY_link_dynamic_object 0 +#endif +#ifndef MY_write_dynamic_symbol +#define MY_write_dynamic_symbol 0 +#endif +#ifndef MY_check_dynamic_reloc +#define MY_check_dynamic_reloc 0 #endif -#ifndef MY_read_dynamic_relocs -#define MY_read_dynamic_relocs 0 +#ifndef MY_finish_dynamic_link +#define MY_finish_dynamic_link 0 #endif static CONST struct aout_backend_data MY(backend_data) = { 0, /* zmagic contiguous */ - 0, /* text incl header */ + MY_text_includes_header, + MY_exec_hdr_flags, 0, /* text vma? */ MY_set_sizes, 0, /* exec header is counted */ - MY_read_dynamic_symbols, - MY_read_dynamic_relocs + MY_add_dynamic_symbols, + MY_add_one_symbol, + MY_link_dynamic_object, + MY_write_dynamic_symbol, + MY_check_dynamic_reloc, + MY_finish_dynamic_link }; #define MY_backend_data &MY(backend_data) #endif -#ifndef MY_bfd_final_link +#ifndef MY_final_link_callback -/* Final link routine. We need to use a call back to get the correct - offsets in the output file. */ +/* Callback for the final_link routine to set the section offsets. */ -static void final_link_callback +static void MY_final_link_callback PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *)); static void -final_link_callback (abfd, ptreloff, pdreloff, psymoff) +MY_final_link_callback (abfd, ptreloff, pdreloff, psymoff) bfd *abfd; file_ptr *ptreloff; file_ptr *pdreloff; @@ -240,12 +285,19 @@ final_link_callback (abfd, ptreloff, pdreloff, psymoff) *psymoff = N_SYMOFF (*execp); } +#endif + +#ifndef MY_bfd_final_link + +/* Final link routine. We need to use a call back to get the correct + offsets in the output file. */ + static boolean MY_bfd_final_link (abfd, info) bfd *abfd; struct bfd_link_info *info; { - return NAME(aout,final_link) (abfd, info, final_link_callback); + return NAME(aout,final_link) (abfd, info, MY_final_link_callback); } #endif @@ -367,10 +419,6 @@ MY_bfd_final_link (abfd, info) #define MY_bfd_link_add_symbols NAME(aout,link_add_symbols) #endif -#ifndef MY_bfd_copy_private_section_data -#define MY_bfd_copy_private_section_data \ - _bfd_generic_bfd_copy_private_section_data -#endif #ifndef MY_bfd_copy_private_bfd_data #define MY_bfd_copy_private_bfd_data _bfd_generic_bfd_copy_private_bfd_data #endif @@ -387,6 +435,23 @@ MY_bfd_final_link (abfd, info) #define MY_close_and_cleanup MY_bfd_free_cached_info #endif +#ifndef MY_get_dynamic_symtab_upper_bound +#define MY_get_dynamic_symtab_upper_bound \ + _bfd_nodynamic_get_dynamic_symtab_upper_bound +#endif +#ifndef MY_canonicalize_dynamic_symtab +#define MY_canonicalize_dynamic_symtab \ + _bfd_nodynamic_canonicalize_dynamic_symtab +#endif +#ifndef MY_get_dynamic_reloc_upper_bound +#define MY_get_dynamic_reloc_upper_bound \ + _bfd_nodynamic_get_dynamic_reloc_upper_bound +#endif +#ifndef MY_canonicalize_dynamic_reloc +#define MY_canonicalize_dynamic_reloc \ + _bfd_nodynamic_canonicalize_dynamic_reloc +#endif + /* Aout symbols normally have leading underscores */ #ifndef MY_symbol_leading_char #define MY_symbol_leading_char '_' @@ -447,6 +512,7 @@ bfd_target MY(vec) = BFD_JUMP_TABLE_RELOCS (MY), BFD_JUMP_TABLE_WRITE (MY), BFD_JUMP_TABLE_LINK (MY), + BFD_JUMP_TABLE_DYNAMIC (MY), (PTR) MY_backend_data, }; diff --git a/bfd/aoutx.h b/bfd/aoutx.h index dcee1faad5c..1dd7a81ef6e 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -436,16 +436,28 @@ NAME(aout,some_aout_object_p) (abfd, execp, callback_to_real_object_p) if (N_MAGIC (*execp) == ZMAGIC) { - abfd->flags |= D_PAGED|WP_TEXT; - adata(abfd).magic = z_magic; + abfd->flags |= D_PAGED | WP_TEXT; + adata (abfd).magic = z_magic; + } + else if (N_MAGIC (*execp) == QMAGIC) + { + abfd->flags |= D_PAGED | WP_TEXT; + adata (abfd).magic = z_magic; + adata (abfd).subformat = q_magic_format; } else if (N_MAGIC (*execp) == NMAGIC) { abfd->flags |= WP_TEXT; - adata(abfd).magic = n_magic; + adata (abfd).magic = n_magic; } + else if (N_MAGIC (*execp) == OMAGIC) + adata (abfd).magic = o_magic; else - adata(abfd).magic = o_magic; + { + /* Should have been checked with N_BADMAG before this routine + was called. */ + abort (); + } bfd_get_start_address (abfd) = execp->a_entry; @@ -833,7 +845,10 @@ adjust_z_magic (abfd, execp) execp->a_text = obj_textsec(abfd)->_raw_size; if (ztih && (!abdp || (abdp && !abdp->exec_header_not_counted))) execp->a_text += adata(abfd).exec_bytes_size; - N_SET_MAGIC (*execp, ZMAGIC); + if (obj_aout_subformat (abfd) == q_magic_format) + N_SET_MAGIC (*execp, QMAGIC); + else + N_SET_MAGIC (*execp, ZMAGIC); /* Spec says data section should be rounded up to page boundary. */ obj_datasec(abfd)->_raw_size @@ -916,7 +931,8 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end) if (! NAME(aout,make_sections) (abfd)) return false; - if (adata(abfd).magic != undecided_magic) return true; + if (adata(abfd).magic != undecided_magic) + return true; obj_textsec(abfd)->_raw_size = align_power(obj_textsec(abfd)->_raw_size, @@ -941,7 +957,6 @@ NAME(aout,adjust_sizes_and_vmas) (abfd, text_size, text_end) if (abfd->flags & D_PAGED) /* Whether or not WP_TEXT is set -- let D_PAGED override. */ - /* @@ What about QMAGIC? */ adata(abfd).magic = z_magic; else if (abfd->flags & WP_TEXT) adata(abfd).magic = n_magic; @@ -1425,11 +1440,17 @@ translate_to_native_sym_flags (abfd, cache_ptr, sym_pointer) if (bfd_get_section (cache_ptr) == &bfd_abs_section) sym_pointer->e_type[0] |= N_ABS; - else if (bfd_get_section (cache_ptr) == obj_textsec (abfd)) + else if (bfd_get_section (cache_ptr) == obj_textsec (abfd) + || (bfd_get_section (cache_ptr)->output_section + == obj_textsec (abfd))) sym_pointer->e_type[0] |= N_TEXT; - else if (bfd_get_section (cache_ptr) == obj_datasec (abfd)) + else if (bfd_get_section (cache_ptr) == obj_datasec (abfd) + || (bfd_get_section (cache_ptr)->output_section + == obj_datasec (abfd))) sym_pointer->e_type[0] |= N_DATA; - else if (bfd_get_section (cache_ptr) == obj_bsssec (abfd)) + else if (bfd_get_section (cache_ptr) == obj_bsssec (abfd) + || (bfd_get_section (cache_ptr)->output_section + == obj_bsssec (abfd))) sym_pointer->e_type[0] |= N_BSS; else if (bfd_get_section (cache_ptr) == &bfd_und_section) sym_pointer->e_type[0] = N_UNDF | N_EXT; diff --git a/bfd/i386linux.c b/bfd/i386linux.c new file mode 100644 index 00000000000..3f428923449 --- /dev/null +++ b/bfd/i386linux.c @@ -0,0 +1,55 @@ +/* BFD back-end for linux flavored i386 a.out binaries. + Copyright (C) 1990, 1991 Free Software Foundation, Inc. +This file is part of BFD, the Binary File Descriptor library. +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#define PAGE_SIZE 4096 +#define ZMAGIC_DISK_BLOCK_SIZE 1024 +#define SEGMENT_SIZE 4096 +#define TEXT_START_ADDR 0x0 +#define N_SHARED_LIB(x) 0 +#define ARCH 32 +#define BYTES_IN_WORD 4 + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" +#include "aout/aout64.h" +#include "aout/stab_gnu.h" +#include "aout/ar.h" +#include "libaout.h" /* BFD a.out internal data structures */ + +#define DEFAULT_ARCH bfd_arch_i386 +#define MY(OP) CAT(i386linux_,OP) +#define MY_text_includes_header 1 +#define TARGETNAME "a.out-i386-linux" + +/* We always generate QMAGIC files in preference to ZMAGIC files. It + would be possible to make this a linker option, if that ever + becomes important. */ + +static void MY_final_link_callback + PARAMS ((bfd *, file_ptr *, file_ptr *, file_ptr *)); + +static boolean +i386linux_bfd_final_link (abfd, info) + bfd *abfd; + struct bfd_link_info *info; +{ + obj_aout_subformat (abfd) = q_magic_format; + return NAME(aout,final_link) (abfd, info, MY_final_link_callback); +} + +#define MY_bfd_final_link i386linux_bfd_final_link + +#include "aout-target.h" diff --git a/bfd/libaout.h b/bfd/libaout.h index 71b699e21b8..fc4e3c5d27b 100644 --- a/bfd/libaout.h +++ b/bfd/libaout.h @@ -299,15 +299,22 @@ struct aoutdata { unsigned vma_adjusted : 1; /* used when a bfd supports several highly similar formats */ - enum { - default_format = 0, - gnu_encap_format } subformat; - - enum { - undecided_magic = 0, - z_magic, - o_magic, - n_magic } magic; + enum + { + default_format = 0, + /* Used on HP 9000/300 running HP/UX. See hp300hpux.c. */ + gnu_encap_format, + /* Used on Linux, 386BSD, etc. See include/aout/aout64.h. */ + q_magic_format + } subformat; + + enum + { + undecided_magic = 0, + z_magic, + o_magic, + n_magic + } magic; /* The external symbol information. */ struct external_nlist *external_syms;