From 6a469027327f00bc96ad8bb3d17d15d8c41ab20f Mon Sep 17 00:00:00 2001 From: John Gilmore Date: Fri, 11 Oct 1991 04:51:42 +0000 Subject: [PATCH] * Makefile.in: Rename XDEPFILES. * trad-core.c: Document how to use it nowadays. * i386aout.c, newsos3.c: Clean up. * i386coff.c: Allow 386 coff files to be used as core files too (for reading core files from embedded systems). --- bfd/ChangeLog | 18 +++++++ bfd/Makefile.in | 11 ++-- bfd/coff-i386.c | 56 ++++++++++---------- bfd/i386aout.c | 158 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bfd/newsos3.c | 22 ++++---- bfd/trad-core.c | 129 ++++++++++++++++++++++++++++++++++++++++----- 6 files changed, 336 insertions(+), 58 deletions(-) create mode 100644 bfd/i386aout.c diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 29159ea..446fd96 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,21 @@ +Thu Oct 10 17:54:08 1991 John Gilmore (gnu at cygnus.com) + + * config/*: trad-core support is HOST dependent, not target + dependent. Target config files only set DEFAULT_VECTOR and/or + other vector elements. Exception: when host-aout.c is in use, + in which case we're forced to assume we're native (hp, vax, + tahoe). Rename XDEPFILES to HDEPFILES. + * Makefile.in: Rename XDEPFILES. + * config/h-sun*: Don't force static linking. + * trad-core.c: Document how to use it nowadays. + * i386aout.c, newsos3.c: Clean up. + * i386coff.c: Allow 386 coff files to be used as core files too + (for reading core files from embedded systems). + +Tue Oct 8 15:30:39 1991 John Gilmore (gnu at cygnus.com) + + * Add i386aout.c for a.out support on the i386. + Tue Oct 8 12:18:54 1991 Roland H. Pesch (pesch at cygnus.com) * reloc.c, section.c, syms.c, targets.c: correct info-node diff --git a/bfd/Makefile.in b/bfd/Makefile.in index ed2d78d..c37da45 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -22,7 +22,7 @@ srcdir = . destdir = /usr/local -libdir = $(destdir)/lib +libdir = $(destdir)/H-$(host_alias)/T-independent/lib docdir = $(srcdir)/doc RANLIB = ranlib @@ -69,8 +69,8 @@ STAGESTUFF = $(TARGETLIB) $(OFILES) all: $(TARGETLIB) -# XDEPFILES comes from the host config; TDEPFILES from the target config. -OFILES = $(BFD_LIBS) $(BFD_BACKENDS) $(BFD_MACHINES) $(XDEPFILES) $(TDEPFILES) +# HDEPFILES comes from the host config; TDEPFILES from the target config. +OFILES = $(BFD_LIBS) $(BFD_BACKENDS) $(BFD_MACHINES) $(HDEPFILES) $(TDEPFILES) $(TARGETLIB): $(OFILES) rm -f $(TARGETLIB) @@ -166,8 +166,9 @@ roll: force: install: - install -c libbfd.a $(libdir) - $(RANLIB) $(libdir)/libbfd.a + cp libbfd.a $(libdir)/libbfd.a.new + $(RANLIB) $(libdir)/libbfd.a.new + mv -f $(libdir)/libbfd.a.new $(libdir)/libbfd.a # Target to uncomment host-specific lines in this makefile. Such lines must # have the following string beginning in column 1: #____# diff --git a/bfd/coff-i386.c b/bfd/coff-i386.c index 72990b3..c5c3dd6 100644 --- a/bfd/coff-i386.c +++ b/bfd/coff-i386.c @@ -1,21 +1,22 @@ -/* Copyright (C) 1990, 1991 Free Software Foundation, Inc. +/* BFD back-end for Intel 386 COFF files. + Copyright (C) 1990-1991 Free Software Foundation, Inc. + Written by Cygnus Support. -This file is part of BFD, the Binary File Diddler. +This file is part of BFD, the Binary File Descriptor library. -BFD is free software; you can redistribute it and/or modify +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 1, or (at your option) -any later version. +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. -BFD is distributed in the hope that it will be useful, +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 BFD; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* $Id$ */ @@ -26,6 +27,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "libbfd.h" #include "obstack.h" #include "i386coff.h" +#include "internalcoff.h" #include "libcoff.h" @@ -54,14 +56,12 @@ static reloc_howto_type howto_table[] = HOWTO(R_PCRLONG, 0, 2, 32, true, 0, false, true,0,"DISP32", true, 0xffffffff,0xffffffff, false), }; - /* Turn a howto into a reloc nunmber */ #define SELECT_RELOC(x,howto) { x = howto->type; } #define BADMAG(x) I386BADMAG(x) #include "coffcode.h" - #define coff_write_armap bsd_write_armap bfd_target *i3coff_object_p(a) @@ -70,10 +70,10 @@ bfd *a ; bfd_target i386coff_vec = { - "i386coff", /* name */ - bfd_target_coff_flavour_enum, - false, /* data byte order is big */ - false, /* header byte order is big */ + "i386coff", /* name */ + bfd_target_coff_flavour, + false, /* data byte order is little */ + false, /* header byte order is little */ (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | @@ -83,20 +83,18 @@ bfd_target i386coff_vec = '/', /* ar_pad_char */ 15, /* ar_max_namelen */ -_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ -_do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */ - - {_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */ - bfd_generic_archive_p, _bfd_dummy_target}, - {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ - bfd_false}, - {bfd_false, coff_write_object_contents, /* bfd_write_contents */ - _bfd_write_archive_contents, bfd_false}, + 2, /* minimum alignment power */ + _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ + _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */ - JUMP_TABLE(coff), - COFF_SWAP_TABLE +/* Note that we allow an object file to be treated as a core file as well. */ + {_bfd_dummy_target, i3coff_object_p, /* bfd_check_format */ + bfd_generic_archive_p, i3coff_object_p}, + {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */ + bfd_false}, + {bfd_false, coff_write_object_contents, /* bfd_write_contents */ + _bfd_write_archive_contents, bfd_false}, + JUMP_TABLE(coff), + COFF_SWAP_TABLE }; - - - diff --git a/bfd/i386aout.c b/bfd/i386aout.c new file mode 100644 index 0000000..8ca7941 --- /dev/null +++ b/bfd/i386aout.c @@ -0,0 +1,158 @@ +/* BFD back-end for 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 SEGMENT_SIZE PAGE_SIZE +#define TEXT_START_ADDR 0x8000 +#define ARCH 32 +#define BYTES_IN_WORD 4 + +#include +#include +#include "bfd.h" +#include "libbfd.h" +#include "aout64.h" + +/**From: bothner@cs.wisc.edu***********************************************/ +#undef N_TXTOFF +#define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? PAGE_SIZE : EXEC_BYTES_SIZE) +/**************************************************************************/ + +#include "stab.gnu.h" +#include "ar.h" +#include "libaout.h" /* BFD a.out internal data structures */ + +bfd_target *aout386_callback (); + +bfd_target * +DEFUN(aout386_object_p,(abfd), + bfd *abfd) +{ + struct external_exec exec_bytes; + struct internal_exec exec; + + if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) + != EXEC_BYTES_SIZE) { + bfd_error = wrong_format; + return 0; + } + + exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info); + + if (N_BADMAG (exec)) return 0; + + NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); + return aout_32_some_aout_object_p (abfd, &exec, aout386_callback); +} + +/* Finish up the reading of the file header */ +bfd_target * +DEFUN(aout386_callback,(abfd), + bfd *abfd) +{ + struct internal_exec *execp = exec_hdr (abfd); + + WORK_OUT_FILE_POSITIONS(abfd, execp) ; + + /* Determine the architecture and machine type of the object file. */ + bfd_default_set_arch_mach(abfd, bfd_arch_i386, 0); + + return abfd->xvec; +} + +/* Write an object file. + Section contents have already been written. We write the + file header, symbols, and relocation. */ + +boolean +DEFUN(aout386_write_object_contents,(abfd), + bfd *abfd) +{ + bfd_size_type data_pad = 0; + struct external_exec exec_bytes; + struct internal_exec *execp = exec_hdr (abfd); + + WRITE_HEADERS(abfd, execp); + return true; +} + +/* Transfer vector */ + +/* We use BSD archive files. */ +#define aout386_openr_next_archived_file bfd_generic_openr_next_archived_file +#define aout386_generic_stat_arch_elt bfd_generic_stat_arch_elt +#define aout386_slurp_armap bfd_slurp_bsd_armap +#define aout386_slurp_extended_name_table bfd_true +#define aout386_write_armap bsd_write_armap +#define aout386_truncate_arname bfd_bsd_truncate_arname + +/* We don't support core files here. */ +#define aout386_core_file_failing_command _bfd_dummy_core_file_failing_command +#define aout386_core_file_failing_signal _bfd_dummy_core_file_failing_signal +#define aout386_core_file_matches_executable_p \ + _bfd_dummy_core_file_matches_executable_p +#define aout386_core_file_p _bfd_dummy_target + +#define aout386_bfd_debug_info_start bfd_void +#define aout386_bfd_debug_info_end bfd_void +#define aout386_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void + +#define aout386_mkobject aout_32_mkobject +#define aout386_close_and_cleanup aout_32_close_and_cleanup +#define aout386_set_section_contents aout_32_set_section_contents +#define aout386_get_section_contents aout_32_get_section_contents +#define aout386_new_section_hook aout_32_new_section_hook +#define aout386_get_symtab_upper_bound aout_32_get_symtab_upper_bound +#define aout386_get_symtab aout_32_get_symtab +#define aout386_get_reloc_upper_bound aout_32_get_reloc_upper_bound +#define aout386_canonicalize_reloc aout_32_canonicalize_reloc +#define aout386_make_empty_symbol aout_32_make_empty_symbol +#define aout386_print_symbol aout_32_print_symbol +#define aout386_get_lineno aout_32_get_lineno +#define aout386_set_arch_mach aout_32_set_arch_mach +#define aout386_find_nearest_line aout_32_find_nearest_line +#define aout386_sizeof_headers aout_32_sizeof_headers + +bfd_target i386aout_vec = /* Intel 386 running a.out, embedded. */ +{ + "a.out-i386", /* name */ + bfd_target_aout_flavour, + false, /* target byte order */ + false, /* target headers byte order */ + (HAS_RELOC | EXEC_P | /* object flags */ + HAS_LINENO | HAS_DEBUG | + HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ + ' ', /* ar_pad_char */ + 16, /* ar_max_namelen */ + 1, /* minimum alignment */ + /* data swap routines */ + _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, + /* header swap routines */ + _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, + + {_bfd_dummy_target, aout386_object_p, /* bfd_check_format */ + bfd_generic_archive_p, aout386_core_file_p}, + {bfd_false, aout386_mkobject, /* bfd_set_format */ + _bfd_generic_mkarchive, bfd_false}, + {bfd_false, aout386_write_object_contents, /* bfd_write_contents */ + _bfd_write_archive_contents, bfd_false}, + + JUMP_TABLE(aout386) +}; diff --git a/bfd/newsos3.c b/bfd/newsos3.c index 588e56b..1a35109 100644 --- a/bfd/newsos3.c +++ b/bfd/newsos3.c @@ -17,8 +17,6 @@ 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 TARGET_BYTE_ORDER_BIG_P 1 - #define PAGE_SIZE 4096 #define SEGMENT_SIZE PAGE_SIZE #define TEXT_START_ADDR 0 @@ -54,19 +52,21 @@ bfd_target * DEFUN(newsos3_object_p,(abfd), bfd *abfd) { - unsigned char magicbuf[4]; /* Raw bytes of magic number from file */ - unsigned long magic; /* Swapped magic number */ - - bfd_error = system_call_error; + struct external_exec exec_bytes; + struct internal_exec exec; - if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) != - sizeof (magicbuf)) + if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd) + != EXEC_BYTES_SIZE) { + bfd_error = wrong_format; return 0; - magic = bfd_h_get_32 (abfd, magicbuf); + } + + exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info); - if (N_BADMAG (*((struct internal_exec *) &magic))) return 0; + if (N_BADMAG (exec)) return 0; - return aout_32_some_aout_object_p (abfd, newsos3_callback); + NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec); + return aout_32_some_aout_object_p (abfd, &exec, newsos3_callback); } /* Finish up the reading of a NEWS-OS a.out file header */ diff --git a/bfd/trad-core.c b/bfd/trad-core.c index a4f13e3..7442666 100644 --- a/bfd/trad-core.c +++ b/bfd/trad-core.c @@ -18,13 +18,18 @@ 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. */ -/* This file does not define a particular back-end, but it defines routines - that can be used by other back-ends. */ +/* To use this file on a particular host, configure the host with these + parameters in the config/h-HOST file: + + HDEFINES=-DHOST_SYS=WHATEVER_SYS -DTRAD_CORE + HDEPFILES=trad-core.o + + */ + #include #include "bfd.h" #include #include "libbfd.h" - #include "libaout.h" /* BFD a.out internal data structures */ #include @@ -38,13 +43,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include -/* need this cast b/c ptr is really void * */ -#define core_hdr(bfd) (((struct core_data *) (bfd->tdata))->hdr) -#define core_datasec(bfd) (((struct core_data *) ((bfd)->tdata))->data_section) -#define core_stacksec(bfd) (((struct core_data*)((bfd)->tdata))->stack_section) -#define core_regsec(bfd) (((struct core_data *) ((bfd)->tdata))->reg_section) -#define core_upage(bfd) (((struct core_data *) ((bfd)->tdata))->upage) - /* These are stored in the bfd's tdata */ struct core_data { struct user *upage; /* core file header */ @@ -53,6 +51,12 @@ struct core_data { asection *reg_section; }; +#define core_hdr(bfd) (((struct core_data *) (bfd->tdata))->hdr) +#define core_upage(bfd) (((struct core_data *) ((bfd)->tdata))->upage) +#define core_datasec(bfd) (((struct core_data *) ((bfd)->tdata))->data_section) +#define core_stacksec(bfd) (((struct core_data*)((bfd)->tdata))->stack_section) +#define core_regsec(bfd) (((struct core_data *) ((bfd)->tdata))->reg_section) + /* ARGSUSED */ bfd_target * trad_unix_core_file_p (abfd) @@ -119,9 +123,9 @@ loser2: core_datasec (abfd)->name = ".data"; core_regsec (abfd)->name = ".reg"; - core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD; - core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD; - core_regsec (abfd)->flags = SEC_ALLOC; + core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; + core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS; + core_regsec (abfd)->flags = SEC_ALLOC + SEC_HAS_CONTENTS; core_datasec (abfd)->size = NBPG * u.u_dsize; core_stacksec (abfd)->size = NBPG * u.u_ssize; @@ -180,3 +184,102 @@ trad_unix_core_file_matches_executable_p (core_bfd, exec_bfd) { return true; /* FIXME, We have no way of telling at this point */ } + +/* No archive file support via this BFD */ +#define trad_unix_openr_next_archived_file bfd_generic_openr_next_archived_file +#define trad_unix_generic_stat_arch_elt bfd_generic_stat_arch_elt +#define trad_unix_slurp_armap bfd_false +#define trad_unix_slurp_extended_name_table bfd_true +#define trad_unix_write_armap (PROTO (boolean, (*), \ + (bfd *arch, unsigned int elength, struct orl *map, int orl_count, \ + int stridx))) bfd_false +#define trad_unix_truncate_arname bfd_dont_truncate_arname +#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file + +#define trad_unix_close_and_cleanup bfd_generic_close_and_cleanup +#define trad_unix_set_section_contents (PROTO(boolean, (*), \ + (bfd *abfd, asection *section, PTR data, file_ptr offset, \ + bfd_size_type count))) bfd_false +#define trad_unix_get_section_contents bfd_generic_get_section_contents +#define trad_unix_new_section_hook (PROTO (boolean, (*), \ + (bfd *, sec_ptr))) bfd_true +#define trad_unix_get_symtab_upper_bound bfd_0u +#define trad_unix_get_symtab (PROTO (unsigned int, (*), \ + (bfd *, struct symbol_cache_entry **))) bfd_0u +#define trad_unix_get_reloc_upper_bound (PROTO (unsigned int, (*), \ + (bfd *, sec_ptr))) bfd_0u +#define trad_unix_canonicalize_reloc (PROTO (unsigned int, (*), \ + (bfd *, sec_ptr, arelent **, struct symbol_cache_entry**))) bfd_0u +#define trad_unix_make_empty_symbol (PROTO ( \ + struct symbol_cache_entry *, (*), (bfd *))) bfd_false +#define trad_unix_print_symbol (PROTO (void, (*), \ + (bfd *, PTR, struct symbol_cache_entry *, \ + bfd_print_symbol_type))) bfd_false +#define trad_unix_get_lineno (PROTO (alent *, (*), \ + (bfd *, struct symbol_cache_entry *))) bfd_nullvoidptr +#define trad_unix_set_arch_mach (PROTO (boolean, (*), \ + (bfd *, enum bfd_architecture, unsigned long))) bfd_false +#define trad_unix_find_nearest_line (PROTO (boolean, (*), \ + (bfd *abfd, struct sec *section, \ + struct symbol_cache_entry **symbols,bfd_vma offset, \ + CONST char **file, CONST char **func, unsigned int *line))) bfd_false +#define trad_unix_sizeof_headers (PROTO (int, (*), \ + (bfd *, boolean))) bfd_0 + +#define trad_unix_bfd_debug_info_start bfd_void +#define trad_unix_bfd_debug_info_end bfd_void +#define trad_unix_bfd_debug_info_accumulate (PROTO (void, (*), \ + (bfd *, struct sec *))) bfd_void + + +bfd_target trad_core_big_vec = + { + "trad-core-big", + bfd_target_unknown_flavour, + true, /* target byte order */ + true, /* target headers byte order */ + (HAS_RELOC | EXEC_P | /* object flags */ + HAS_LINENO | HAS_DEBUG | + HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ + ' ', /* ar_pad_char */ + 16, /* ar_max_namelen */ + 3, /* minimum alignment power */ + _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* data */ + _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ + + {_bfd_dummy_target, _bfd_dummy_target, + _bfd_dummy_target, trad_unix_core_file_p}, + {bfd_false, bfd_false, /* bfd_create_object */ + bfd_false, bfd_false}, + {bfd_false, bfd_false, /* bfd_write_contents */ + bfd_false, bfd_false}, + + JUMP_TABLE(trad_unix) +}; + +bfd_target trad_core_little_vec = +{ + "trad-core-little", + bfd_target_unknown_flavour, + false, /* target byte order */ + false, /* target headers byte order */ + (HAS_RELOC | EXEC_P | /* object flags */ + HAS_LINENO | HAS_DEBUG | + HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), + (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ + ' ', /* ar_pad_char */ + 16, /* ar_max_namelen */ + 3, /* minimum alignment power */ + _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putb16, + _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, + + {_bfd_dummy_target, _bfd_dummy_target, + _bfd_dummy_target, trad_unix_core_file_p}, + {bfd_false, bfd_false, /* bfd_create_object */ + bfd_false, bfd_false}, + {bfd_false, bfd_false, /* bfd_write_contents */ + bfd_false, bfd_false}, + + JUMP_TABLE(trad_unix) +}; -- 2.7.4