$NetBSD: patch-aa,v 1.1 2001/01/30 03:08:59 minoura Exp $

diff -urN gcc-2.95.2/gcc/collect2.c gcc-patched/gcc/collect2.c
--- gcc/collect2.c	Wed Oct 13 06:16:52 1999
+++ gcc/collect2.c	Thu Dec 14 20:00:19 2000
@@ -53,7 +53,6 @@
 #define obstack_chunk_alloc xmalloc
 #define obstack_chunk_free free
 
-extern char *make_temp_file PROTO ((char *));
 
 /* On certain systems, we have code that works by scanning the object file
    directly.  But this code uses system-specific header files and library
diff -urN gcc-2.95.2/gcc/config/elfos.h gcc-patched/gcc/config/elfos.h
--- gcc/config/elfos.h	Fri Mar 26 19:45:26 1999
+++ gcc/config/elfos.h	Thu Dec 14 20:00:19 2000
@@ -48,6 +48,7 @@
 
 /* Output #ident as a .ident.  */
 
+#undef ASM_OUTPUT_IDENT
 #define ASM_OUTPUT_IDENT(FILE, NAME) \
   fprintf (FILE, "\t%s\t\"%s\"\n", IDENT_ASM_OP, NAME);
 
@@ -92,6 +93,10 @@
 #undef SET_ASM_OP
 #define SET_ASM_OP	".set"
 
+/* We want local labels to start with period if made with asm_fprintf. */
+#undef LOCAL_LABEL_PREFIX
+#define LOCAL_LABEL_PREFIX "."
+
 /* This is how to begin an assembly language file.  Most svr4 assemblers want
    at least a .file directive to come first, and some want to see a .version
    directive come right after that.  Here we just establish a default
@@ -130,7 +135,7 @@
 #undef ASM_OUTPUT_INTERNAL_LABEL
 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM)			\
 do {									\
-  fprintf (FILE, ".%s%d:\n", PREFIX, NUM);				\
+  fprintf (FILE, "%s%s%d:\n", LOCAL_LABEL_PREFIX, PREFIX, NUM);		\
 } while (0)
 
 /* This is how to store into the string LABEL
@@ -144,7 +149,7 @@
 #undef ASM_GENERATE_INTERNAL_LABEL
 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM)			\
 do {									\
-  sprintf (LABEL, "*.%s%d", PREFIX, NUM);				\
+  sprintf (LABEL, "*%s%s%d", LOCAL_LABEL_PREFIX, PREFIX, NUM);		\
 } while (0)
 
 /* Output the label which precedes a jumptable.  Note that for all svr4
@@ -461,6 +466,7 @@
 
 /* This is how we tell the assembler that a symbol is weak.  */
 
+#undef ASM_WEAKEN_LABEL
 #define ASM_WEAKEN_LABEL(FILE,NAME) \
   do { fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
        fputc ('\n', FILE); } while (0)
diff -urN gcc-2.95.2/gcc/config/i386/netbsd-elf.h gcc-patched/gcc/config/i386/netbsd-elf.h
--- gcc/config/i386/netbsd-elf.h	Thu Jan  1 09:00:00 1970
+++ gcc/config/i386/netbsd-elf.h	Thu Dec 14 20:00:18 2000
@@ -0,0 +1,161 @@
+/* Definitions of target machine for GNU compiler,
+   for i386 NetBSD systems.
+   Copyright (C) 1998 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC 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, or (at your option)
+any later version.
+
+GNU CC 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 GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+/* This is used on i386 platforms that use the ELF format.
+   This was taken from the NetBSD/alpha configuration, and modified
+   for NetBSD/i386 by Christos Zoulas <christos@netbsd.org> */
+
+/* Get generic i386 definitions. */
+
+/* This goes away when the math-emulator is fixed */
+#define TARGET_CPU_DEFAULT 0400		/* TARGET_NO_FANCY_MATH_387 */
+
+#include <i386/gstabs.h>
+
+/* Get perform_* macros to build libgcc.a.  */
+#include <i386/perform.h>
+
+/* Get generic NetBSD ELF definitions.  We will override these if necessary. */
+
+#define NETBSD_ELF
+#include <netbsd.h>
+
+#undef ASM_FINAL_SPEC
+
+/* Names to predefine in the preprocessor for this target machine. */
+
+#undef CPP_PREDEFINES
+#define CPP_PREDEFINES "\
+-Dunix -Di386 -D__NetBSD__ -D__ELF__ \
+-Asystem(unix) -Asystem(NetBSD) -Acpu(i386) -Amachine(i386)"
+
+/* Make gcc agree with <machine/ansi.h> */
+
+#undef SIZE_TYPE
+#define SIZE_TYPE "unsigned int"
+
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "int"
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef WCHAR_UNSIGNED
+#define WCHAR_UNSIGNED 0
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+/* Output assembler code to FILE to increment profiler label # LABELNO
+   for profiling a function entry.  Under NetBSD/i386, the assembler does
+   nothing special with -pg. */
+
+#undef ASM_APP_ON
+#define ASM_APP_ON "#APP\n"
+
+#undef ASM_APP_OFF
+#define ASM_APP_OFF "#NO_APP\n"
+
+#define bsd4_4
+#undef HAS_INIT_SECTION
+
+/* Provide a LINK_SPEC appropriate for a NetBSD/alpha ELF target.  Only
+   the linker emulation is i386-specific.  The rest are
+   common to all ELF targets, except for the name of the start function. */
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "-m elf_i386 \
+  %{assert*} %{R*} \
+  %{shared:-shared} \
+  %{!shared: \
+    -dc -dp \
+    %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
+    %{static:-static}}"
+
+#undef DEFAULT_VTABLE_THUNKS
+#define DEFAULT_VTABLE_THUNKS 1
+
+#undef ASM_OUTPUT_ALIGN
+#define ASM_OUTPUT_ALIGN(FILE,LOG) \
+  if ((LOG)!=0) fprintf ((FILE), "\t.align %d\n", 1 << (LOG))
+
+/* This is how we tell the assembler that two symbols have the same value.  */
+
+#define ASM_OUTPUT_DEF(FILE,NAME1,NAME2) \
+  do { assemble_name(FILE, NAME1); 	 \
+       fputs(" = ", FILE);		 \
+       assemble_name(FILE, NAME2);	 \
+       fputc('\n', FILE); } while (0)
+
+/*
+ * We always use gas here, so we don't worry about ECOFF assembler problems.
+ */
+#undef TARGET_GAS
+#define TARGET_GAS	(1)
+
+/* The following macros are stolen from i386v4.h */
+/* These have to be defined to get PIC code correct */
+
+/* This is how to output an element of a case-vector that is relative.
+   This is only used for PIC code.  See comments by the `casesi' insn in
+   i386.md for an explanation of the expression this outputs. */
+
+#undef ASM_OUTPUT_ADDR_DIFF_ELT
+#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
+  fprintf (FILE, "\t.long _GLOBAL_OFFSET_TABLE_+[.-%s%d]\n", LPREFIX, VALUE)
+
+/* Indicate that jump tables go in the text section.  This is
+   necessary when compiling PIC code.  */
+
+#define JUMP_TABLES_IN_TEXT_SECTION 1
+
+/* Default to pcc-struct-return, because this is the ELF abi and
+   we don't care about compatibility with older gcc versions.  */
+#define DEFAULT_PCC_STRUCT_RETURN 1
+
+/* Profiling routines, partially copied from i386/osfrose.h.  */
+
+/* Redefine this to use %eax instead of %edx.  */
+#undef FUNCTION_PROFILER
+#define FUNCTION_PROFILER(FILE, LABELNO)  \
+{									\
+  if (flag_pic)								\
+    {									\
+      fprintf (FILE, "\tcall __mcount@PLT\n");				\
+    }									\
+  else									\
+    {									\
+      fprintf (FILE, "\tcall __mcount\n");				\
+    }									\
+}
+
+/* Put relocations in the constant pool in the writable data section.  */
+#undef SELECT_RTX_SECTION
+#define SELECT_RTX_SECTION(MODE,RTX)					\
+{									\
+  if (flag_pic && symbolic_operand (RTX))				\
+    data_section ();							\
+  else									\
+    readonly_data_section ();						\
+}
diff -urN gcc-2.95.2/gcc/config/i386/xm-netbsd.h gcc-patched/gcc/config/i386/xm-netbsd.h
--- gcc/config/i386/xm-netbsd.h	Thu Jan  1 09:00:00 1970
+++ gcc/config/i386/xm-netbsd.h	Thu Dec 14 20:00:18 2000
@@ -0,0 +1,23 @@
+/* Configuration file for i386 hosts running NetBSD.
+   Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC 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, or (at your option)
+any later version.
+
+GNU CC 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 GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#include <xm-netbsd.h>
+#include <i386/xm-i386.h>
+
diff -urN gcc-2.95.2/gcc/config/netbsd.h gcc-patched/gcc/config/netbsd.h
--- gcc/config/netbsd.h	Thu Dec 17 05:59:58 1998
+++ gcc/config/netbsd.h	Thu Dec 14 20:00:19 2000
@@ -48,17 +48,31 @@
 #define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}"
 
 /* Provide a LIB_SPEC appropriate for NetBSD.  Just select the appropriate
-   libc, depending on whether we're doing profiling.  */
+   libc, depending on whether we're doing profiling; if `-posix' is specified,
+   link against the appropriate libposix first.  */
 
 #undef LIB_SPEC
-#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
+#define LIB_SPEC							\
+  "%{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}}		\
+   %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
+
+/* #ifdef NETBSD_AOUT */
+
+/* Provide a STARTFILE_SPEC appropriate for NetBSD a.out.  Here we
+   provide support for the special GCC option -static.  */
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC \
+  "%{!shared:%{pg:gcrt0%O%s}%{!pg:%{p:mcrt0%O%s}%{!p:%{!static:crt0%O%s}%{static:scrt0%O%s}}}} %{shared:c++rt0%O%s}"
 
 /* Provide a LINK_SPEC appropriate for NetBSD.  Here we provide support
    for the special GCC options -static, -assert, and -nostdlib.  */
 
 #undef LINK_SPEC
 #define LINK_SPEC \
-  "%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} %{static:-Bstatic} %{assert*}"
+  "%{nostdlib:-nostdlib} %{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{static:-Bstatic}} %{shared:-Bshareable} %{R*} %{assert*}"
+
+/* #endif NETBSD_AOUT */
 
 /* This defines which switch letters take arguments. */
 #undef SWITCH_TAKES_ARG
@@ -127,6 +141,9 @@
    entries in an ELF object file under SVR4.  These macros also output
    the starting labels for the relevant functions/objects.  */
 
+/* XXX.  This is WRONG for alpha.  Needs to be verified on other ELF ports. */
+#ifndef NETBSD_ELF
+
 /* Write the extra assembler code needed to declare a function properly.
    Some svr4 assemblers need to also have something extra said about the
    function's return value.  We allow for that here.  */
@@ -207,3 +224,54 @@
 	putc ('\n', FILE);						\
       }									\
   } while (0)
+
+#endif /* ! NETBSD_ELF */
+
+/* NetBSD ELF support begins here. */
+
+#ifdef NETBSD_ELF
+
+/* Start with generic ELF definitions. */
+#include "elfos.h"
+
+#undef DWARF_DEBUGGING_INFO	/* XXX */
+#undef DWARF2_DEBUGGING_INFO	/* XXX */
+
+/* Provide a STARTFILE_SPEC appropriate for NetBSD ELF targets.  Here we
+   provide support for the special GCC option -static.  On ELF targets,
+   we also add the crtbegin.o file which provides part of the support
+   for getting C++ file-scope static objects constructed before entering
+   `main'. */
+
+#undef STARTFILE_SPEC
+#define	STARTFILE_SPEC \
+ "%{!shared: \
+     %{pg:gcrt0%O%s} \
+     %{!pg: \
+        %{p:gcrt0%O%s} \
+        %{!p:crt0%O%s}}} \
+   %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}"
+
+/* Provide an ENDFILE_SPEC appropriate for NetBSD ELF targets.  Here we
+   add crtend.o, which provides part of the support for getting C++
+   file-scope static objects deconstructed after exiting `main'. */
+
+#undef ENDFILE_SPEC
+#define	ENDFILE_SPEC \
+ "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
+
+/* Provide a LINK_SPEC appropriate for a NetBSD ELF target.  */
+
+#undef LINK_SPEC
+#define	LINK_SPEC \
+ "%{assert*} \
+  %{shared:-shared} \
+  %{!shared: \
+    -dc -dp \
+    %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
+    %{static:-static}}"
+
+#endif /* NETBSD_ELF */
diff -urN gcc-2.95.2/gcc/config/sparc/netbsd-elf.h gcc-patched/gcc/config/sparc/netbsd-elf.h
--- gcc/config/sparc/netbsd-elf.h	Thu Jan  1 09:00:00 1970
+++ gcc/config/sparc/netbsd-elf.h	Thu Dec 14 20:00:18 2000
@@ -0,0 +1,42 @@
+/* NetBSD/sparc ELF configuration */
+
+/*
+ * Pull in generic SPARC ELF configuration, and then clean up
+ * afterwards
+ */
+#include <sparc/elf.h>
+
+/* Name the target CPU. */
+#ifndef TARGET_CPU_DEFAULT
+#define TARGET_CPU_DEFAULT	TARGET_CPU_sparc
+#endif
+
+#undef MULDI3_LIBCALL
+#undef DIVDI3_LIBCALL
+#undef UDIVDI3_LIBCALL
+#undef MODDI3_LIBCALL
+#undef UMODDI3_LIBCALL
+#undef INIT_SUBTARGET_OPTABS  
+#define INIT_SUBTARGET_OPTABS  
+
+#undef CPP_SUBTARGET_SPEC
+#define CPP_SUBTARGET_SPEC "-D__sparc"
+
+#include <sparc/netbsd-elf-common.h>
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "-m elf32_sparc \
+  %{assert*} %{R*} \
+  %{shared:-shared} \
+  %{!shared: \
+    -dy -dc -dp \
+    %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
+    %{static:-static}}"
+
+/* Name the port. */
+#undef TARGET_NAME
+#define TARGET_NAME     "sparc-netbsdelf"
diff -urN gcc-2.95.2/gcc/config/sparc/netbsd64.h gcc-patched/gcc/config/sparc/netbsd64.h
--- gcc/config/sparc/netbsd64.h	Thu Jan  1 09:00:00 1970
+++ gcc/config/sparc/netbsd64.h	Thu Dec 14 20:00:18 2000
@@ -0,0 +1,169 @@
+/* NetBSD/sparc64 ELF configuration */
+
+/*
+ * Pull in generic SPARC64 ELF configuration, and then clean up
+ * afterwards
+ */
+
+/* Let us output 32 bit code as well */
+#define SPARC_BI_ARCH
+
+/* Name the target CPU.  This must be before <sparc/sparc.h>. */
+#ifndef TARGET_CPU_DEFAULT
+#define TARGET_CPU_DEFAULT    TARGET_CPU_ultrasparc
+#endif
+
+#include <sparc/sp64-elf.h>
+
+#include <sparc/netbsd-elf-common.h>
+
+#undef CPP_SUBTARGET_SPEC
+#define CPP_SUBTARGET_SPEC "-D__sparc64__"
+
+#undef LINK_SPEC64
+#define LINK_SPEC64 \
+ "-m elf64_sparc \
+  %{assert*} %{R*} \
+  %{shared:-shared} \
+  %{!shared: \
+    -dy -dc -dp \
+    %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
+    %{static:-static}}"
+
+#undef LINK_SPEC
+#define LINK_SPEC LINK_SPEC64
+
+#ifdef SPARC_BI_ARCH
+
+#undef STARTFILE_SPEC64
+#define	STARTFILE_SPEC64 \
+ "%{!shared: \
+     %{pg:gcrt0%O%s} \
+     %{!pg: \
+        %{p:gcrt0%O%s} \
+        %{!p:crt0%O%s}}} \
+   %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}"
+
+#undef STARTFILE_SPEC32
+#define	STARTFILE_SPEC32 \
+ "%{!shared: \
+     %{pg:/emul/netbsd32/usr/lib/gcrt0%O%s} \
+     %{!pg: \
+        %{p:/emul/netbsd32/usr/lib/gcrt0%O%s} \
+        %{!p:/emul/netbsd32/usr/lib/crt0%O%s}}} \
+   %{!shared:/emul/netbsd32/usr/lib/crtbegin%O%s} %{shared:/emul/netbsd32/usr/lib/crtbeginS%O%s}"
+
+#undef STARTFILE_SPEC
+#if DEFAULT_ARCH32_P
+#define STARTFILE_SPEC "\
+%{m32:" STARTFILE_SPEC32 "} \
+%{m64:" STARTFILE_SPEC64 "} \
+%{!m32:%{!m64:" STARTFILE_SPEC32 "}}"
+#else
+#define STARTFILE_SPEC "\
+%{m32:" STARTFILE_SPEC32 "} \
+%{m64:" STARTFILE_SPEC64 "} \
+%{!m32:%{!m64:" STARTFILE_SPEC64 "}}"
+#endif
+
+#undef ENDFILE_SPEC64
+#define	ENDFILE_SPEC64 \
+ "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
+
+#undef ENDFILE_SPEC32
+#define	ENDFILE_SPEC32 \
+ "%{!shared:/emul/netbsd32/usr/lib/crtend%O%s} %{shared:/emul/netbsd32/usr/lib/crtendS%O%s}"
+
+#undef ENDFILE_SPEC
+#if DEFAULT_ARCH32_P
+#define ENDFILE_SPEC "\
+%{m32:" ENDFILE_SPEC32 "} \
+%{m64:" ENDFILE_SPEC64 "} \
+%{!m32:%{!m64:" ENDFILE_SPEC32 "}}"
+#else
+#define ENDFILE_SPEC "\
+%{m32:" ENDFILE_SPEC32 "} \
+%{m64:" ENDFILE_SPEC64 "} \
+%{!m32:%{!m64:" ENDFILE_SPEC64 "}}"
+#endif
+
+#undef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS \
+  { "link_arch32",       LINK_ARCH32_SPEC },              \
+  { "link_arch64",       LINK_ARCH64_SPEC },              \
+  { "link_arch_default", LINK_ARCH_DEFAULT_SPEC },	  \
+  { "link_arch",	 LINK_ARCH_SPEC },
+
+#undef LINK_ARCH32_SPEC
+#define LINK_ARCH32_SPEC \
+ "-m elf32_sparc \
+  -Y P,/emul/netbsd32/usr/lib \
+  %{assert*} %{R*} \
+  %{shared:-shared} \
+  %{!shared: \
+    -dy -dc -dp \
+    %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
+    %{static:-static}}"
+
+#undef LINK_ARCH64_SPEC
+#define LINK_ARCH64_SPEC LINK_SPEC64
+
+#define LINK_ARCH_SPEC "\
+%{m32:%(link_arch32)} \
+%{m64:%(link_arch64)} \
+%{!m32:%{!m64:%(link_arch_default)}} \
+"
+
+#define LINK_ARCH_DEFAULT_SPEC \
+(DEFAULT_ARCH32_P ? LINK_ARCH32_SPEC : LINK_ARCH64_SPEC)
+
+#undef  LINK_SPEC
+#define LINK_SPEC "\
+%(link_arch) \
+%{mlittle-endian:-EL} \
+"
+
+#undef	CC1_SPEC
+#if DEFAULT_ARCH32_P
+#define CC1_SPEC "\
+%{sun4:} %{target:} \
+%{mcypress:-mcpu=cypress} \
+%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
+%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
+%{m64:-mptr64 -mcpu=ultrasparc -mstack-bias} \
+"
+#else
+#define CC1_SPEC "\
+%{sun4:} %{target:} \
+%{mcypress:-mcpu=cypress} \
+%{msparclite:-mcpu=sparclite} %{mf930:-mcpu=f930} %{mf934:-mcpu=f934} \
+%{mv8:-mcpu=v8} %{msupersparc:-mcpu=supersparc} \
+%{m32:-mptr32 -mcpu=cypress -mno-stack-bias} \
+"
+#endif
+
+#if DEFAULT_ARCH32_P
+#define MULTILIB_DEFAULTS { "m32" }
+#else
+#define MULTILIB_DEFAULTS { "m64" }
+#endif
+
+#undef CPP_SUBTARGET_SPEC
+#define CPP_SUBTARGET_SPEC \
+(DEFAULT_ARCH32_P ? "\
+%{m64:-D__sparc64__}%{!m64:-D__sparc} \
+" : "\
+%{!m32:-D__sparc64__}%{m32:-D__sparc} \
+")
+
+#endif	/* SPARC_BI_ARCH */
+
+/* Name the port. */
+#undef TARGET_NAME
+#define TARGET_NAME     "sparc64-netbsd"
diff -urN gcc-2.95.2/gcc/config/sparc/sparc.md gcc-patched/gcc/config/sparc/sparc.md
--- gcc/config/sparc/sparc.md	Thu Oct 21 14:35:40 1999
+++ gcc/config/sparc/sparc.md	Thu Dec 14 20:00:18 2000
@@ -3472,10 +3472,7 @@
 (define_split
   [(set (match_operand:TF 0 "register_operand" "")
         (match_operand:TF 1 "register_operand" ""))]
-  "reload_completed
-   && (! TARGET_ARCH64
-       || (TARGET_FPU
-           && ! TARGET_HARD_QUAD))"
+  "reload_completed"
   [(clobber (const_int 0))]
   "
 {
diff -urN gcc-2.95.2/gcc/config/sparc/sysv4.h gcc-patched/gcc/config/sparc/sysv4.h
--- gcc/config/sparc/sysv4.h	Tue Jun 22 02:48:53 1999
+++ gcc/config/sparc/sysv4.h	Thu Dec 14 20:00:19 2000
@@ -210,6 +210,29 @@
 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN) \
   asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
 
+/* A C statement (sans semicolon) to output an element in the table of
+   global constructors.  */
+#undef ASM_OUTPUT_CONSTRUCTOR
+#define ASM_OUTPUT_CONSTRUCTOR(FILE,NAME)				\
+  do {									\
+    ctors_section ();							\
+    fprintf (FILE, "\t%s\t ", TARGET_ARCH64 ? ASM_LONGLONG : INT_ASM_OP); \
+    assemble_name (FILE, NAME);						\
+    fprintf (FILE, "\n");						\
+  } while (0)
+
+/* A C statement (sans semicolon) to output an element in the table of
+   global destructors.  */
+#undef ASM_OUTPUT_DESTRUCTOR
+#define ASM_OUTPUT_DESTRUCTOR(FILE,NAME)       				\
+  do {									\
+    dtors_section ();                   				\
+    fprintf (FILE, "\t%s\t ", TARGET_ARCH64 ? ASM_LONGLONG : INT_ASM_OP); \
+    assemble_name (FILE, NAME);              				\
+    fprintf (FILE, "\n");						\
+  } while (0)
+
+
 /* Override the name of the mcount profiling function.  */
 
 #undef MCOUNT_FUNCTION
diff -urN gcc-2.95.2/gcc/config/sparc/xm-netbsd.h gcc-patched/gcc/config/sparc/xm-netbsd.h
--- gcc/config/sparc/xm-netbsd.h	Thu Jan  1 09:00:00 1970
+++ gcc/config/sparc/xm-netbsd.h	Thu Dec 14 20:00:19 2000
@@ -0,0 +1,4 @@
+/* Configuration for GCC for Sun SPARC running NetBSD as host.  */
+
+#include <sparc/xm-sparc.h>
+#include <xm-netbsd.h>
diff -urN gcc-2.95.2/gcc/config/sparc/xm-netbsd64.h gcc-patched/gcc/config/sparc/xm-netbsd64.h
--- gcc/config/sparc/xm-netbsd64.h	Thu Jan  1 09:00:00 1970
+++ gcc/config/sparc/xm-netbsd64.h	Thu Dec 14 20:00:19 2000
@@ -0,0 +1,4 @@
+/* Configuration for GCC for Sun SPARC V9 running NetBSD as host.  */
+
+#include <xm-netbsd.h>
+#include <sparc/xm-sp64.h>
diff -urN gcc-2.95.2/gcc/config/xm-netbsd.h gcc-patched/gcc/config/xm-netbsd.h
--- gcc/config/xm-netbsd.h	Thu Jan  1 09:00:00 1970
+++ gcc/config/xm-netbsd.h	Thu Dec 14 20:00:19 2000
@@ -0,0 +1,32 @@
+/* Configuration for GNU C-compiler for hosts running NetBSD.
+   Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC 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, or (at your option)
+any later version.
+
+GNU CC 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 GNU CC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* This file defines machine-independent things specific to a host
+   running NetBSD.  This file should not be specified as $xm_file itself;
+   instead $xm_file should be CPU/xm-netbsd.h, which should include both
+   CPU/xm-CPU.h and this file xm-netbsd.h.  */
+
+#undef POSIX
+#define POSIX
+
+/* Ensure we get gnu C's defaults.  */
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#endif
diff -urN gcc-2.95.2/gcc/config/xm-target64.h gcc-patched/gcc/config/xm-target64.h
--- gcc/config/xm-target64.h	Thu Jan  1 09:00:00 1970
+++ gcc/config/xm-target64.h	Thu Dec 14 20:00:19 2000
@@ -0,0 +1,6 @@
+/* Hack to extend HOST_WIDE_INT on 64-bit target cross compilers. */
+
+#ifdef __GNUC__
+#define HOST_WIDE_INT long long
+#define HOST_BITS_PER_WIDE_INT 64
+#endif
diff -urN gcc-2.95.2/gcc/emit-rtl.c gcc-patched/gcc/emit-rtl.c
--- gcc/emit-rtl.c	Wed Aug 11 16:28:52 1999
+++ gcc/emit-rtl.c	Thu Dec 14 20:00:20 2000
@@ -1378,6 +1378,15 @@
 	val = ((val & 0xffffffff) ^ 0x80000000) - 0x80000000;
 	return GEN_INT (val);
       }
+#if HOST_BITS_PER_WIDE_INT >= 64
+    else if (BITS_PER_WORD >= 64 && i <= 1)
+      {
+        val = k[i*2 + ! WORDS_BIG_ENDIAN];
+        val = (((val & 0xffffffff) ^ 0x80000000) - 0x80000000) << 32;
+        val |= (HOST_WIDE_INT) k[i*2 + WORDS_BIG_ENDIAN] & 0xffffffff;
+        return GEN_INT (val);
+      }
+#endif
     else
       abort ();
   }
diff -urN gcc-2.95.2/gcc/ginclude/stddef.h gcc-patched/gcc/ginclude/stddef.h
--- gcc/ginclude/stddef.h	Thu Dec 17 06:19:25 1998
+++ gcc/ginclude/stddef.h	Thu Dec 14 20:00:20 2000
@@ -45,6 +45,12 @@
 #define _WCHAR_T
 #endif
 #endif
+/* On NetBSD, machine/ansi.h defines _BSD_WINT_T_ instead of _WINT_T. */
+#if !defined(_WINT_T_) && !defined(_BSD_WINT_T_)
+#ifndef _BSD_WINT_T_
+#define _WINT_T
+#endif
+#endif
 /* Undef _FOO_T_ if we are supposed to define foo_t.  */
 #if defined (__need_ptrdiff_t) || defined (_STDDEF_H_)
 #undef _PTRDIFF_T_
@@ -58,6 +64,10 @@
 #undef _WCHAR_T_
 #undef _BSD_WCHAR_T_
 #endif
+#if defined (__need_wint_t) || defined (_STDDEF_H_)
+#undef _WINT_T_
+#undef _BSD_WINT_T_
+#endif
 #endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */
 
 /* Sequent's header files use _PTRDIFF_T_ in some conflicting way.
@@ -272,12 +282,14 @@
 
 #if defined (_STDDEF_H) || defined (__need_wint_t)
 #ifndef _WINT_T
+#ifndef _BSD_WINT_T_
 #define _WINT_T
 
 #ifndef __WINT_TYPE__
 #define __WINT_TYPE__ unsigned int
 #endif
 typedef __WINT_TYPE__ wint_t;
+#endif
 #endif
 #undef __need_wint_t
 #endif
diff -urN gcc-2.95.2/gcc/objc/objc-act.c gcc-patched/gcc/objc/objc-act.c
--- gcc/objc/objc-act.c	Thu Apr 15 05:28:54 1999
+++ gcc/objc/objc-act.c	Thu Dec 14 20:00:19 2000
@@ -8399,8 +8399,11 @@
       pushdecl (decl);
       rest_of_decl_compilation (decl, 0, 0, 0);
 
-      /* Make following constant read-only (why not)?  */
-      readonly_data_section ();
+      /* Make following constant read-only, if not compiling PIC. */
+      if (flag_pic)
+	data_section();
+      else
+	readonly_data_section ();
 
       exp = build1 (ADDR_EXPR, string_type_node, decl);
 
