Subject: binutils-2.5.1 patches for NetBSD on m68k machines
To: None <tech-ports@netbsd.org>
From: None <mikeb@snow.datametrics.com>
List: tech-ports
Date: 10/28/1994 09:58:58
These diffs are based off the patches from Andrew Cagney
<cagney@highland.com.au> which can be gotten from:

mippet.ci.com.au:/pub/cagney/binutils-2.5.1+nbsd-0.05.diff.gz

His patches MUST be applied to binutils-2.5.1 before the following patches.

Also, ld does not work yet, I am currently working on the shared library
support which which be done RSN, but if I start giving dates, it'll
probably take longer (a programmers life story :-) Anyhow, there are a
couple patches to the ld tree, but I have left out
binutils-2.5.1/ld/emultempl/nbsd.em which is the heart of it all, so don't
try to use the ld, although it does currently compile, it does not work!!!

---
*** /dev/null	Fri Oct 28 09:00:40 1994
--- binutils-2.5.1/bfd/config/m68k-nbsd.mt	Wed Oct 26 14:33:25 1994
***************
*** 0 ****
--- 1,5 ----
+ # Target:  Motorola 680x0 running netbsd, using (modified) a.out
+ 
+ DEFAULT_VECTOR=bfd_netbsd_m68k_vec
+ SELECT_VECS=hp300bsd_vec sunos_big_vec
+ SELECT_ARCHITECTURES=bfd_m68k_arch
*** /dev/null	Fri Oct 28 09:36:44 1994
--- binutils-2.5.1/bfd/hosts/m68knbsd.h	Fri Oct 28 09:38:48 1994
***************
*** 0 ****
--- 1,15 ----
+ /* Motorola 680x0 running NetBSD */
+ 
+ #ifndef	hosts_m68knbsd_H
+ #define hosts_m68knbsd_H
+ 
+ #include "hosts/nbsd.h"
+ 
+ #define	HOST_MACHINE_ARCH	bfd_arch_m68k
+ #define HOST_BIG_ENDIAN_P
+ 
+ #define TRAD_UNIX_CORE_FILE_FAILING_SIGNAL(core_bfd) \
+   ((core_bfd)->tdata.trad_core_data->u.u_sig)
+ #define u_comm u_kproc.kp_proc.p_comm
+ #endif
+ 
*** binutils-2.5.1/bfd/Makefile.in.orig	Fri Oct 28 08:56:41 1994
--- binutils-2.5.1/bfd/Makefile.in	Fri Oct 28 07:57:37 1994
***************
*** 164,169 ****
--- 164,170 ----
  	m88kmach3.o \
  	mipsbsd.o \
  	nbsd-i386.o \
+ 	nbsd-m68k.o \
  	nbsd-ns32k.o \
  	nbsd-ppc.o \
  	nbsd-sparc.o \
***************
*** 255,261 ****
  	 i386lynx.c cf-i386lynx.c m68klynx.c cf-m68klynx.c \
  	 sparclynx.c cf-sparclynx.c aix386-core.c hpux-core.c \
  	 irix-core.c lynx-core.c osf-core.c hash.c linker.c cofflink.c \
! 	 nbsd-i386.c nbsd-ns32k.c  nbsd-ppc.c nbsd-sparc.c
  
  HFILES = aout-target.h aoutf1.h aoutx.h coffcode.h \
  	 coffswap.h ecoffswap.h elf32-hppa.h elf32-target.h elf64-target.h \
--- 256,262 ----
  	 i386lynx.c cf-i386lynx.c m68klynx.c cf-m68klynx.c \
  	 sparclynx.c cf-sparclynx.c aix386-core.c hpux-core.c \
  	 irix-core.c lynx-core.c osf-core.c hash.c linker.c cofflink.c \
! 	 nbsd-m68k.c nbsd-ns32k.c nbsd-sparc.c nbsd-i386.c nbsd-ppc.c
  
  HFILES = aout-target.h aoutf1.h aoutx.h coffcode.h \
  	 coffswap.h ecoffswap.h elf32-hppa.h elf32-target.h elf64-target.h \
***************
*** 763,775 ****
  nbsd-i386.o: nbsd-i386.c nbsd.h libaout.h $(INCDIR)/bfdlink.h \
    aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
    $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
! nbsd-ns32k.o: nbsd-ns32k.c nbsd.h libaout.h $(INCDIR)/bfdlink.h \
    aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
    $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
! nbsd-ppc.o: nbsd-ppc.c nbsd.h libaout.h $(INCDIR)/bfdlink.h \
    aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
    $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
  nbsd-sparc.o: nbsd-sparc.c nbsd.h libaout.h $(INCDIR)/bfdlink.h \
    aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
    $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
  
--- 764,779 ----
  nbsd-i386.o: nbsd-i386.c nbsd.h libaout.h $(INCDIR)/bfdlink.h \
    aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
    $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
! nbsd-m68k.o: nbsd-m68k.c nbsd.h libaout.h $(INCDIR)/bfdlink.h \
    aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
    $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
! nbsd-ns32k.o: nbsd-ns32k.c nbsd.h libaout.h $(INCDIR)/bfdlink.h \
    aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
    $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
  nbsd-sparc.o: nbsd-sparc.c nbsd.h libaout.h $(INCDIR)/bfdlink.h \
+   aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
+   $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
+ nbsd-ppc.o: nbsd-ppc.c nbsd.h libaout.h $(INCDIR)/bfdlink.h \
    aout-target.h $(INCDIR)/aout/aout64.h $(INCDIR)/aout/stab_gnu.h \
    $(INCDIR)/aout/stab.def $(INCDIR)/aout/ar.h
  
*** binutils-2.5.1/bfd/config.bfd.orig	Fri Oct 28 08:56:41 1994
--- binutils-2.5.1/bfd/config.bfd	Wed Oct 26 13:47:18 1994
***************
*** 74,79 ****
--- 74,80 ----
    m68*-*-coff*)		bfd_name=m68k-coff ;;
    m68*-*-hpux*)		bfd_name=hp300hpux strip_underscore=yes ;;
    m68*-*-lynxos*)	bfd_name=m68k-lynx ;;
+   m68*-*-netbsd*)	bfd_name=m68k-nbsd strip_underscore=yes;;
    m68*-*-os68k*)	bfd_name=m68k-aout strip_underscore=yes ;;
    m68*-*-sunos*)	bfd_name=m68k-aout strip_underscore=yes ;;
    m68*-*-sysv4*)	bfd_name=m68k-elf ;;
*** binutils-2.5.1/bfd/configure.in.orig	Fri Oct 28 08:56:42 1994
--- binutils-2.5.1/bfd/configure.in	Wed Oct 26 13:52:39 1994
***************
*** 161,166 ****
--- 161,167 ----
      bfd_elf64_sparc_vec)	tb="$tb elf64-sparc.o elf64.o elf.o"
  				target64=true ;;
      bfd_netbsd_i386_vec)	tb="$tb nbsd-i386.o aout32.o stab-syms.o" ;;
+     bfd_netbsd_m68k_vec)	tb="$tb nbsd-m68k.o aout32.o stab-syms.o" ;;
      bfd_netbsd_ns32k_vec)	tb="$tb nbsd-ns32k.o aout-ns32k.o stab-syms.o" ;;
      bfd_netbsd_ppc_vec)		tb="$tb nbsd-ppc.o aout32.o stab-syms.o" ;;
      bfd_netbsd_rs6k_vec)	tb="$tb nbsd-ppc.o aout32.o stab-syms.o" ;;
*** binutils-2.5.1/bfd/libaout.h.orig	Fri Oct 28 08:56:43 1994
--- binutils-2.5.1/bfd/libaout.h	Wed Oct 26 14:23:43 1994
***************
*** 270,275 ****
--- 270,276 ----
    M_386_DYNIX = 102,	/* Sequent running dynix */
    M_ARM = 103,		/* Advanced Risc Machines ARM */
    M_386_NETBSD = 134,	/* NetBSD/386 binary */
+   M_68K_NETBSD = 135,	/* NetBSD/68k binary */
    M_532_NETBSD = 137,	/* NetBSD/532 binary */
    M_MIPS1 = 151,        /* MIPS R2000/R3000 binary */
    M_MIPS2 = 152,        /* MIPS R4000/R6000 binary */
*** binutils-2.5.1/bfd/targets.c.orig	Fri Oct 28 08:56:44 1994
--- binutils-2.5.1/bfd/targets.c	Wed Oct 26 13:41:28 1994
***************
*** 445,450 ****
--- 445,451 ----
  extern const bfd_target bfd_elf64_little_generic_vec;
  extern const bfd_target bfd_elf64_sparc_vec;
  extern const bfd_target bfd_netbsd_i386_vec;
+ extern const bfd_target bfd_netbsd_m68k_vec;
  extern const bfd_target bfd_netbsd_ns32k_vec;
  extern const bfd_target bfd_netbsd_sparc_vec;
  extern const bfd_target bfd_netbsd_ppc_vec;
***************
*** 560,565 ****
--- 561,567 ----
  	&bfd_elf64_sparc_vec,
  #endif
  	&bfd_netbsd_i386_vec,
+ 	&bfd_netbsd_m68k_vec,
          &bfd_netbsd_ns32k_vec,
  	&bfd_netbsd_sparc_vec,
  	&bfd_netbsd_ppc_vec,
*** /dev/null	Fri Oct 28 09:02:46 1994
--- binutils-2.5.1/bfd/nbsd-m68k.c	Fri Oct 28 09:32:31 1994
***************
*** 0 ****
--- 1,35 ----
+ /* BFD back-end for NetBSD/m68k 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.  */
+ 
+ 
+ #define DEFAULT_ARCH		bfd_arch_m68k
+ #define MY(OP)                  CAT(bfd_netbsd_m68k_,OP)
+ #define TARGETNAME              "a.out-m68k-netbsd"
+ #define TARGET_IS_BIG_ENDIAN_P  1
+ #define BYTES_IN_WORD           4
+ #define ARCH_SIZE               32
+ #define PAGE_SIZE               4096
+ 
+ #define MY_MACHINE_TYPE         M_68K_NETBSD
+ #define MACHTYPE_OK(mtype)      ((mtype) == M_68020 || (mtype) == M_68K_NETBSD || (mtype) == M_UNKNOWN)
+ 
+ 
+ #include "nbsd.h"
+ #include "aout-target.h"
+ 
*** binutils-2.5.1/gas/config/tc-m68k.h.orig	Fri Oct 28 09:13:50 1994
--- binutils-2.5.1/gas/config/tc-m68k.h	Fri Oct 28 09:45:32 1994
***************
*** 24,32 ****
--- 24,36 ----
  #ifdef TE_SUN3
  #define TARGET_FORMAT "a.out-sunos-big"
  #else
+ #ifdef TE_NetBSD
+ #define TARGET_FORMAT	"a.out-m68k-netbsd"
+ #else
  #define TARGET_FORMAT "a.out-zero-big"
  #endif
  #endif
+ #endif
  
  #ifdef TE_APOLLO
  #define COFF_MAGIC		APOLLOM68KMAGIC
***************
*** 100,105 ****
--- 104,110 ----
  #endif
  
  #ifdef BFD_ASSEMBLER
+ #define TARGET_ARCH	bfd_arch_m68k
  #define tc_frob_symbol(sym,punt) \
      if (S_GET_SEGMENT (sym) == reg_section) punt = 1
  #endif
*** binutils-2.5.1/gas/configure.orig	Fri Oct 28 08:56:45 1994
--- binutils-2.5.1/gas/configure	Fri Oct 28 09:17:20 1994
***************
*** 634,639 ****
--- 634,640 ----
    m68k-*-hpux)		obj_format=hp300 emulation=hp300 ;;
    m68k-*-lynxos*)	obj_format=coff gas_target=m68kcoff
  			 emulation=lynx ;;
+   m68k-*-netbsd*)	obj_format=aout emulation=nbsd bfd_gas=yes ;;
  
    m88k-*-coff*)		obj_format=coff gas_target=m88kcoff ;;
  
*** binutils-2.5.1/gas/configure.in.orig	Fri Oct 28 08:56:45 1994
--- binutils-2.5.1/gas/configure.in	Fri Oct 28 09:18:14 1994
***************
*** 123,128 ****
--- 123,129 ----
    m68k-*-hpux)		obj_format=hp300 emulation=hp300 ;;
    m68k-*-lynxos*)	obj_format=coff gas_target=m68kcoff
  			 emulation=lynx ;;
+   m68k-*-netbsd*)	obj_format=aout emulation=nbsd bfd_gas=yes ;;
  
    m88k-*-coff*)		obj_format=coff gas_target=m88kcoff ;;
  
*** /dev/null	Fri Oct 28 09:20:49 1994
--- binutils-2.5.1/ld/config/m68k-nbsd.mt	Wed Oct 26 15:11:52 1994
***************
*** 0 ****
--- 1 ----
+ EMUL=nbsd_m68k
*** /dev/null	Fri Oct 28 09:21:48 1994
--- binutils-2.5.1/ld/emulparams/nbsd_m68k.sh	Wed Oct 26 15:15:48 1994
***************
*** 0 ****
--- 1,5 ----
+ SCRIPT_NAME=aout
+ TEXT_START_ADDR=0x1020
+ OUTPUT_FORMAT="a.out-m68k-netbsd"
+ PAGE_SIZE=0x1000
+ ARCH=m68k
*** binutils-2.5.1/ld/Makefile.in.orig	Fri Oct 28 08:56:47 1994
--- binutils-2.5.1/ld/Makefile.in	Wed Oct 26 14:57:29 1994
***************
*** 204,210 ****
  	ei386lynx.o em68klynx.o esparclynx.o ecoff_sparc.o \
  	eelf32ppc.o ei386go32.o em68kaout.o ei386linux.o \
  	eelf32_sparc.o eelf64_sparc.o eriscix.o eelf32bmip.o eelf32lmip.o \
! 	enbsd_i386.o enbsd_ppc.o enbsd_rs6k enbsd_ns32k
  
  CFILES = ldctor.c ldemul.c ldexp.c ldfile.c ldlang.c \
  	ldmain.c ldmisc.c ldver.c ldwrite.c lexsup.c \
--- 204,210 ----
  	ei386lynx.o em68klynx.o esparclynx.o ecoff_sparc.o \
  	eelf32ppc.o ei386go32.o em68kaout.o ei386linux.o \
  	eelf32_sparc.o eelf64_sparc.o eriscix.o eelf32bmip.o eelf32lmip.o \
! 	enbsd_i386.o enbsd_m68k.o enbsd_ppc.o enbsd_rs6k enbsd_ns32k
  
  CFILES = ldctor.c ldemul.c ldexp.c ldfile.c ldlang.c \
  	ldmain.c ldmisc.c ldver.c ldwrite.c lexsup.c \
***************
*** 443,448 ****
--- 443,452 ----
  enbsd_i386.c: $(srcdir)/emulparams/nbsd_i386.sh \
    $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
  	${GENSCRIPTS} nbsd_i386
+ 
+ enbsd_m68k.c: $(srcdir)/emulparams/nbsd_m68k.sh \
+   $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
+ 	${GENSCRIPTS} nbsd_m68k
  
  enbsd_ppc.c: $(srcdir)/emulparams/nbsd_ppc.sh \
    $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS}
*** binutils-2.5.1/ld/configure.in.orig	Fri Oct 28 08:56:47 1994
--- binutils-2.5.1/ld/configure.in	Fri Oct 28 09:25:30 1994
***************
*** 96,101 ****
--- 96,102 ----
    m68*-*-coff)		ld_target=m68k-coff ;;
    m68*-*-hpux*)		ld_target=hp300hpux ;;
    m68*-*-lynxos*)	ld_target=m68k-lynx ;;
+   m68*-*-netbsd*)	ld_target=m68k-nbsd ;;
    m68*-*-*)
      echo '***' "Unknown m68k target vendor for ld:" ${target_vendor} 1>&2
  			exit 1 ;;
*** binutils-2.5.1/config.guess.orig	Thu Oct  6 21:05:57 1994
--- binutils-2.5.1/config.guess	Wed Oct 26 18:01:15 1994
***************
*** 54,59 ****
--- 54,62 ----
  	# 1.2 uses "1.2" for uname -r.
  	echo alpha-dec-osf${UNAME_RELEASE}
          exit 0 ;;
+     amiga:NetBSD:*:*)
+ 	echo m68k-amiga-netbsd
+ 	exit 0 ;;
      arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
  	echo arm-acorn-riscix${UNAME_RELEASE}
  	exit 0;;