1991-09-27 02:40:30 +08:00
|
|
|
|
/* BFD back-end for NewsOS3 (Sony, 68k) binaries.
|
|
|
|
|
Copyright (C) 1990-1991 Free Software Foundation, Inc.
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
1991-09-27 02:40:30 +08:00
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
1991-09-27 02:40:30 +08:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
1991-05-11 09:46:31 +09:00
|
|
|
|
it under the terms of the GNU General Public License as published by
|
1991-09-27 02:40:30 +08:00
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
1991-09-27 02:40:30 +08:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
1991-05-11 09:46:31 +09:00
|
|
|
|
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
|
1991-09-27 02:40:30 +08:00
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
1991-05-21 09:14:16 +09:00
|
|
|
|
#define PAGE_SIZE 4096
|
|
|
|
|
#define SEGMENT_SIZE PAGE_SIZE
|
|
|
|
|
#define TEXT_START_ADDR 0
|
|
|
|
|
#define ARCH 32
|
|
|
|
|
#define BYTES_IN_WORD 4
|
|
|
|
|
|
1991-05-11 09:46:31 +09:00
|
|
|
|
#include "bfd.h"
|
1991-10-11 18:11:37 +08:00
|
|
|
|
#include "sysdep.h"
|
1991-05-11 09:46:31 +09:00
|
|
|
|
#include "libbfd.h"
|
1991-05-21 09:14:16 +09:00
|
|
|
|
#include "aout64.h"
|
1991-07-05 01:52:56 +09:00
|
|
|
|
|
|
|
|
|
/**From: bothner@cs.wisc.edu***********************************************/
|
|
|
|
|
#undef N_TXTOFF
|
|
|
|
|
#define N_TXTOFF(x) ( (N_MAGIC((x)) == ZMAGIC) ? PAGE_SIZE : EXEC_BYTES_SIZE)
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
1991-05-21 09:14:16 +09:00
|
|
|
|
#include "stab.gnu.h"
|
|
|
|
|
#include "ar.h"
|
1991-05-29 11:44:10 +09:00
|
|
|
|
#include "libaout.h" /* BFD a.out internal data structures */
|
1991-07-05 01:52:56 +09:00
|
|
|
|
#if 0
|
1991-05-11 09:46:31 +09:00
|
|
|
|
int vfprintf(file, format, args) /* Temporary crock! */
|
|
|
|
|
FILE *file; char *format; char *args;
|
|
|
|
|
{
|
|
|
|
|
return _doprnt (format, args, file);
|
|
|
|
|
}
|
1991-07-05 01:52:56 +09:00
|
|
|
|
#endif
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bfd_target *newsos3_callback ();
|
|
|
|
|
|
|
|
|
|
bfd_target *
|
1991-05-21 09:14:16 +09:00
|
|
|
|
DEFUN(newsos3_object_p,(abfd),
|
|
|
|
|
bfd *abfd)
|
1991-05-11 09:46:31 +09:00
|
|
|
|
{
|
1991-10-11 12:51:42 +08:00
|
|
|
|
struct external_exec exec_bytes;
|
|
|
|
|
struct internal_exec exec;
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
1991-10-11 12:51:42 +08:00
|
|
|
|
if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
|
|
|
|
|
!= EXEC_BYTES_SIZE) {
|
|
|
|
|
bfd_error = wrong_format;
|
1991-05-11 09:46:31 +09:00
|
|
|
|
return 0;
|
1991-10-11 12:51:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
1991-10-11 12:51:42 +08:00
|
|
|
|
if (N_BADMAG (exec)) return 0;
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
1991-10-11 12:51:42 +08:00
|
|
|
|
NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
|
|
|
|
|
return aout_32_some_aout_object_p (abfd, &exec, newsos3_callback);
|
1991-05-11 09:46:31 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Finish up the reading of a NEWS-OS a.out file header */
|
|
|
|
|
bfd_target *
|
1991-05-21 09:14:16 +09:00
|
|
|
|
DEFUN(newsos3_callback,(abfd),
|
|
|
|
|
bfd *abfd)
|
1991-05-11 09:46:31 +09:00
|
|
|
|
{
|
1991-05-21 09:14:16 +09:00
|
|
|
|
struct internal_exec *execp = exec_hdr (abfd);
|
|
|
|
|
|
|
|
|
|
WORK_OUT_FILE_POSITIONS(abfd, execp) ;
|
|
|
|
|
|
* bfd.c: Remove strerror() to libiberty.
* elf.c: Remove elf_set_section_contents, use generic one. Lint.
* libbfd-in.h, libbfd.c: Add bfd_generic_set_section_contents.
* libbfd.c (bfd_generic_{get,set}_section_contents): Check that
last byte of transfer, not first byte, is within the section.
* host-aout.c: Remove `BSD' archive support. Lint.
* archures.c: Rename `struct bfd_arch_info_struct' to `struct
bfd_arch_info'. Rename `typedef bfd_arch_info_struct_type' to
`bfd_arch_info_type'. All uses changed.
* reloc.c: Rename `bfd_reloc_status_enum_type' to
`bfd_reloc_status_type'. Rename `bfd_reloc_code_enum_real_type'
to `bfd_reloc_code_real_type'. (This seems to be a misnomer,
it needs a better name.) All uses changed.
* targets.c: Rename `enum target_flavour_enum' to `enum
target_flavour', and remove the `_enum' from all of the enum
values themselves. All uses changed.
* configure.in, config/h-i386mach: i386 mach host.
* config/t-i386-aout: Use host-aout.c.
* trad-core.c: Give it its own xvec's to make it independent
of other file formats.
* ecoff.c, host-aout.c: Remove refs to trad-core.
* config/t-dec3100, t-hp300bsd, t-tahoe, t-vax: Define TRAD_CORE.
* targets.c: #ifdef TRAD_CORE, include it in the vector.
1991-10-05 13:18:08 +08:00
|
|
|
|
/* Determine the architecture and machine type of the object file.
|
|
|
|
|
*/
|
|
|
|
|
bfd_default_set_arch_mach(abfd, bfd_arch_m68k, 0);
|
|
|
|
|
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
|
|
|
|
return abfd->xvec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write an object file in NEWS-OS format.
|
|
|
|
|
Section contents have already been written. We write the
|
|
|
|
|
file header, symbols, and relocation. */
|
|
|
|
|
|
|
|
|
|
boolean
|
1991-05-21 09:14:16 +09:00
|
|
|
|
DEFUN(newsos3_write_object_contents,(abfd),
|
|
|
|
|
bfd *abfd)
|
1991-05-11 09:46:31 +09:00
|
|
|
|
{
|
1991-05-21 09:14:16 +09:00
|
|
|
|
bfd_size_type data_pad = 0;
|
|
|
|
|
struct external_exec exec_bytes;
|
|
|
|
|
struct internal_exec *execp = exec_hdr (abfd);
|
|
|
|
|
|
|
|
|
|
WRITE_HEADERS(abfd, execp);
|
1991-05-11 09:46:31 +09:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Transfer vectors for NEWS-OS version 3 */
|
|
|
|
|
|
|
|
|
|
/* We use BFD generic archive files. */
|
1991-07-05 01:52:56 +09:00
|
|
|
|
#define newsos_openr_next_archived_file bfd_generic_openr_next_archived_file
|
|
|
|
|
#define newsos_generic_stat_arch_elt bfd_generic_stat_arch_elt
|
|
|
|
|
#define newsos_slurp_armap bfd_slurp_bsd_armap
|
|
|
|
|
#define newsos_slurp_extended_name_table bfd_true
|
|
|
|
|
#define newsos_write_armap bsd_write_armap
|
|
|
|
|
#define newsos_truncate_arname bfd_bsd_truncate_arname
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
|
|
|
|
/* We don't support core files yet. FIXME. */
|
1991-07-05 01:52:56 +09:00
|
|
|
|
#define newsos_core_file_failing_command _bfd_dummy_core_file_failing_command
|
|
|
|
|
#define newsos_core_file_failing_signal _bfd_dummy_core_file_failing_signal
|
|
|
|
|
#define newsos_core_file_matches_executable_p \
|
1991-05-11 09:46:31 +09:00
|
|
|
|
_bfd_dummy_core_file_matches_executable_p
|
1991-07-05 01:52:56 +09:00
|
|
|
|
#define newsos_core_file_p _bfd_dummy_target
|
|
|
|
|
|
|
|
|
|
#define newsos_bfd_debug_info_start bfd_void
|
|
|
|
|
#define newsos_bfd_debug_info_end bfd_void
|
1991-09-27 02:40:30 +08:00
|
|
|
|
#define newsos_bfd_debug_info_accumulate (PROTO(void,(*),(bfd*, struct sec *))) bfd_void
|
1991-07-05 01:52:56 +09:00
|
|
|
|
|
|
|
|
|
#define newsos_mkobject aout_32_mkobject
|
|
|
|
|
#define newsos_close_and_cleanup aout_32_close_and_cleanup
|
|
|
|
|
#define newsos_set_section_contents aout_32_set_section_contents
|
|
|
|
|
#define newsos_get_section_contents aout_32_get_section_contents
|
|
|
|
|
#define newsos_new_section_hook aout_32_new_section_hook
|
|
|
|
|
#define newsos_get_symtab_upper_bound aout_32_get_symtab_upper_bound
|
|
|
|
|
#define newsos_get_symtab aout_32_get_symtab
|
|
|
|
|
#define newsos_get_reloc_upper_bound aout_32_get_reloc_upper_bound
|
|
|
|
|
#define newsos_canonicalize_reloc aout_32_canonicalize_reloc
|
|
|
|
|
#define newsos_make_empty_symbol aout_32_make_empty_symbol
|
|
|
|
|
#define newsos_print_symbol aout_32_print_symbol
|
|
|
|
|
#define newsos_get_lineno aout_32_get_lineno
|
|
|
|
|
#define newsos_set_arch_mach aout_32_set_arch_mach
|
|
|
|
|
#define newsos_find_nearest_line aout_32_find_nearest_line
|
|
|
|
|
#define newsos_sizeof_headers aout_32_sizeof_headers
|
|
|
|
|
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
|
|
|
|
/* We define our own versions of these routines. */
|
|
|
|
|
|
|
|
|
|
|
1991-09-27 02:40:30 +08:00
|
|
|
|
bfd_target newsos3_vec = /* Sony 68k-based machines running newsos3 */
|
1991-05-11 09:46:31 +09:00
|
|
|
|
{
|
1991-09-27 02:40:30 +08:00
|
|
|
|
"a.out-newsos3", /* name */
|
* bfd.c: Remove strerror() to libiberty.
* elf.c: Remove elf_set_section_contents, use generic one. Lint.
* libbfd-in.h, libbfd.c: Add bfd_generic_set_section_contents.
* libbfd.c (bfd_generic_{get,set}_section_contents): Check that
last byte of transfer, not first byte, is within the section.
* host-aout.c: Remove `BSD' archive support. Lint.
* archures.c: Rename `struct bfd_arch_info_struct' to `struct
bfd_arch_info'. Rename `typedef bfd_arch_info_struct_type' to
`bfd_arch_info_type'. All uses changed.
* reloc.c: Rename `bfd_reloc_status_enum_type' to
`bfd_reloc_status_type'. Rename `bfd_reloc_code_enum_real_type'
to `bfd_reloc_code_real_type'. (This seems to be a misnomer,
it needs a better name.) All uses changed.
* targets.c: Rename `enum target_flavour_enum' to `enum
target_flavour', and remove the `_enum' from all of the enum
values themselves. All uses changed.
* configure.in, config/h-i386mach: i386 mach host.
* config/t-i386-aout: Use host-aout.c.
* trad-core.c: Give it its own xvec's to make it independent
of other file formats.
* ecoff.c, host-aout.c: Remove refs to trad-core.
* config/t-dec3100, t-hp300bsd, t-tahoe, t-vax: Define TRAD_CORE.
* targets.c: #ifdef TRAD_CORE, include it in the vector.
1991-10-05 13:18:08 +08:00
|
|
|
|
bfd_target_aout_flavour,
|
1991-05-11 09:46:31 +09:00
|
|
|
|
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 */
|
1991-09-27 02:40:30 +08:00
|
|
|
|
1, /* minimum alignment */
|
1991-05-21 09:14:16 +09:00
|
|
|
|
_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 */
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
1991-05-21 09:14:16 +09:00
|
|
|
|
{_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */
|
1991-07-05 01:52:56 +09:00
|
|
|
|
bfd_generic_archive_p, newsos_core_file_p},
|
|
|
|
|
{bfd_false, newsos_mkobject, /* bfd_set_format */
|
1991-05-21 09:14:16 +09:00
|
|
|
|
_bfd_generic_mkarchive, bfd_false},
|
|
|
|
|
{bfd_false, newsos3_write_object_contents, /* bfd_write_contents */
|
|
|
|
|
_bfd_write_archive_contents, bfd_false},
|
1991-05-11 09:46:31 +09:00
|
|
|
|
|
1991-07-05 01:52:56 +09:00
|
|
|
|
JUMP_TABLE(newsos)
|
1991-09-27 02:40:30 +08:00
|
|
|
|
};
|