binutils-gdb/bfd/newsos3.c

144 lines
4.4 KiB
C
Raw Normal View History

1991-05-11 02:46:31 +02:00
/*** bfd backend for NewsOS3 (Sony, 68k) binaries */
/* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Diddler.
BFD 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.
BFD 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. */
#define TARGET_BYTE_ORDER_BIG_P 1
1991-05-21 02:14:16 +02: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 02:46:31 +02:00
#include <ansidecl.h>
1991-05-21 02:14:16 +02:00
#include <sysdep.h>
1991-05-11 02:46:31 +02:00
#include "bfd.h"
#include "libbfd.h"
1991-05-21 02:14:16 +02:00
#include "aout64.h"
#include "stab.gnu.h"
#include "ar.h"
#include "liba.out.h" /* BFD a.out internal data structures */
1991-05-11 02:46:31 +02:00
int vfprintf(file, format, args) /* Temporary crock! */
FILE *file; char *format; char *args;
{
return _doprnt (format, args, file);
}
bfd_target *newsos3_callback ();
bfd_target *
1991-05-21 02:14:16 +02:00
DEFUN(newsos3_object_p,(abfd),
bfd *abfd)
1991-05-11 02:46:31 +02:00
{
unsigned char magicbuf[LONG_SIZE]; /* Raw bytes of magic number from file */
unsigned long magic; /* Swapped magic number */
bfd_error = system_call_error;
if (bfd_read ((PTR)magicbuf, 1, sizeof (magicbuf), abfd) !=
sizeof (magicbuf))
return 0;
1991-05-21 02:14:16 +02:00
magic = bfd_h_get_32 (abfd, magicbuf);
1991-05-11 02:46:31 +02:00
1991-05-21 02:14:16 +02:00
if (N_BADMAG (*((struct internal_exec *) &magic))) return 0;
1991-05-11 02:46:31 +02:00
1991-05-21 02:14:16 +02:00
return aout_32_some_aout_object_p (abfd, newsos3_callback);
1991-05-11 02:46:31 +02:00
}
/* Finish up the reading of a NEWS-OS a.out file header */
bfd_target *
1991-05-21 02:14:16 +02:00
DEFUN(newsos3_callback,(abfd),
bfd *abfd)
1991-05-11 02:46:31 +02:00
{
1991-05-21 02:14:16 +02:00
struct internal_exec *execp = exec_hdr (abfd);
WORK_OUT_FILE_POSITIONS(abfd, execp) ;
1991-05-11 02:46:31 +02:00
/* Determine the architecture and machine type of the object file. */
abfd->obj_arch = bfd_arch_m68k;
abfd->obj_machine = 0;
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 02:14:16 +02:00
DEFUN(newsos3_write_object_contents,(abfd),
bfd *abfd)
1991-05-11 02:46:31 +02:00
{
1991-05-21 02:14:16 +02: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 02:46:31 +02:00
return true;
}
/* Transfer vectors for NEWS-OS version 3 */
/* We use BFD generic archive files. */
1991-05-21 02:14:16 +02:00
#define aout_32_openr_next_archived_file bfd_generic_openr_next_archived_file
#define aout_32_generic_stat_arch_elt bfd_generic_stat_arch_elt
#define aout_32_slurp_armap bfd_slurp_bsd_armap
#define aout_32_slurp_extended_name_table bfd_true
#define aout_32_write_armap bsd_write_armap
#define aout_32_truncate_arname bfd_bsd_truncate_arname
1991-05-11 02:46:31 +02:00
/* We don't support core files yet. FIXME. */
1991-05-21 02:14:16 +02:00
#define aout_32_core_file_failing_command _bfd_dummy_core_file_failing_command
#define aout_32_core_file_failing_signal _bfd_dummy_core_file_failing_signal
#define aout_32_core_file_matches_executable_p \
1991-05-11 02:46:31 +02:00
_bfd_dummy_core_file_matches_executable_p
1991-05-21 02:14:16 +02:00
#define aout_32_core_file_p _bfd_dummy_target
1991-05-11 02:46:31 +02:00
/* We define our own versions of these routines. */
bfd_target newsos3_vec = /* Sony 68k-based machines running newos3 */
{
"a.out-newos3", /* name */
bfd_target_aout_flavour_enum,
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-05-21 02:14:16 +02: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 02:46:31 +02:00
1991-05-21 02:14:16 +02:00
{_bfd_dummy_target, newsos3_object_p, /* bfd_check_format */
bfd_generic_archive_p, aout_32_core_file_p},
{bfd_false, aout_32_mkobject, /* bfd_set_format */
_bfd_generic_mkarchive, bfd_false},
{bfd_false, newsos3_write_object_contents, /* bfd_write_contents */
_bfd_write_archive_contents, bfd_false},
1991-05-11 02:46:31 +02:00
1991-05-21 02:14:16 +02:00
JUMP_TABLE(aout_32)
};