Subject: New (?) bfd/ns32knbsd.c (nee nbsd-ns32k.c) ...
To: J.T. Conklin <dall@HFRD.DSTO.GOV.AU>
From: Andrew Cagney <cagney@highland.com.au>
List: tech-ports
Date: 10/30/1994 12:48:03
Hello,
Below is a version of ns32knbsd.c (nee nbsd-ns32k.c (nee ns32knetbsd.c
:-)) for binutils-2.5.1 + my patches. It is a `blind' port. It
compiles, links and runs (on empty .s files) but that doesn't really
tell us if it is correct. I'll give it a bit more of a try when I've
found my old ns32k manual ...
[JT, enjoy :-]
Andrew
PS: Doing a word count shows:
214 /home/cagney/build/ns32k/bfd/ns32knetbsd.c
97 nbsd-ns32k.c
so I must be doing something right, it's less then half the size :-)
----
/* BFD back-end for NetBSD/ns32k a.out-ish binaries.
Copyright (C) 1990, 1991, 1992 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.
$Id: ns32knetbsd.c,v 1.2 1994/09/20 20:20:42 jtc Exp $
*/
/* This file was completely wrong in the 2.5.1 release. Reverted to an earlier
* version.
* This files should include netbsd.h except that
* a) we need to put some ns32k specific stuff in the middle
* of what netbsd.h does, b) netbsd.h doesn`t define N_SET_FLAGS
* properly, c) netbsd.h doesn`t define WRITE_HEADERS. We need WRITE
* headers so the INFO fields get set properly. d) N_TXTADDR isn`t defined
* properly e) N_TXTOFF, N_DATADDR and N_DATOFF are wrong and/or unnecessary.
*
* Why are the macros different in so many places from the netbsd.h macros?
* My theory is that it is because the netbsd linker etc has some things
* like allowing for the size of the header in the text segment hard coded.
* In bfd we have to make the macros smart enough. -- IWD
*
* [This might be better now - Noid]
*/
/*
* Created by Ian Dall
* 5-Jun-94
*/
#define DEFAULT_ARCH bfd_arch_ns32k
#define MY(OP) CAT(bfd_netbsd_ns32k_,OP)
#define TARGETNAME "a.out-ns32k-netbsd"
#define BYTES_IN_WORD 4
#define ARCH_SIZE 32
#define PAGE_SIZE 0x1000
/*#define MY_MACHINE_TYPE M_532_NETBSD -- Don't define as want custom */
#define MACHTYPE_OK(mtype) ((mtype) == M_532_NETBSD)
#if 0
#include "aout-ns32k.h"
#else
/* Must be the same as aout-ns32k.c */
#define NAME(x,y) CAT3(ns32kaout,_32_,y)
#endif
#include "nbsd.h"
/* Adjust the outgoing header to include the magic number */
static void
MY(fix_outgoing_header) (abfd, internal_execp, raw_bytes)
bfd *abfd;
struct internal_exec *internal_execp;
struct external_exec *raw_bytes;
{
struct internal_exec execp = *internal_execp;
BFD_ASSERT(bfd_get_arch(abfd) == bfd_arch_ns32k);
BFD_ASSERT(bfd_get_mach(abfd) == 32532);
N_SET_MACHTYPE (execp, M_532_NETBSD);
bfd_putb32(execp.a_info, raw_bytes->e_info);
}
/* We can`t use the MYNS macro here for cpp reasons too subtle
* for me -- IWD
*/
#define MY_bfd_reloc_type_lookup ns32kaout_bfd_reloc_type_lookup
CONST struct reloc_howto_struct *
MY_bfd_reloc_type_lookup
PARAMS((bfd *abfd AND
bfd_reloc_code_real_type code));
/* use generic get_section_contents */
#define MY_get_section_contents aout_32_get_section_contents
#include "aout-target.h"