summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog45
-rw-r--r--gcc/config.gcc37
-rw-r--r--gcc/config/alpha/netbsd-elf.h32
-rw-r--r--gcc/config/alpha/netbsd.h72
-rw-r--r--gcc/config/i386/netbsd-elf.h127
-rw-r--r--gcc/config/i386/netbsd.h1
-rw-r--r--gcc/config/m68k/netbsd.h1
-rw-r--r--gcc/config/mips/netbsd.h348
-rw-r--r--gcc/config/netbsd-aout.h215
-rw-r--r--gcc/config/netbsd-elf.h76
-rw-r--r--gcc/config/netbsd.h194
-rw-r--r--gcc/config/ns32k/netbsd.h1
12 files changed, 665 insertions, 484 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 513425dcf8c..37c60bd81ca 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,48 @@
+2002-01-21 Jason Thorpe <thorpej@wasabisystems.com>
+
+ * config/netbsd.h (TARGET_HAS_F_SETLKW): define.
+ Split a.out-specific bits into...
+ * config/netbsd-aout.h: ...this.
+ * config/netbsd-elf.h: New file.
+ * config/alpha/netbsd-elf.h: Remove.
+ * config/alpha/netbsd.h: Rewrite for a NetBSD/alpha ELF target.
+ * config/i386/netbsd-elf.h (LIB_SPEC): Remove.
+ (STARTFILE_SPEC): Remove redundant definition.
+ (ENDFILE_SPEC): Likewise.
+ (LINK_SPEC): Likewise.
+ (CPP_SPEC): Likewise.
+ (ASM_SPEC): Likewise.
+ (LIB_SPEC): Likewise.
+ (SWITCH_TAKES_ARG): Likewise.
+ (TARGET_MEM_FUNCTIONS): Likewise.
+ (CPP_PREDEFINES): Redefine.
+ (ASM_FINAL_SPEC): Remove redefinition.
+ (ASM_COMMENT_START): Redefine.
+ (FUNCTION_PROFILER): Define.
+ (TARGET_VERSION): Redefine.
+ Comment and formatting cleanup.
+ * config/i386/netbsd.h: Include <netbsd-aout.h>.
+ * config/m68k/netbsd.h: Include <netbsd-aout.h>.
+ * config/mips/netbsd.h: Rewrite for NetBSD/mips ELF target,
+ big- or little-endian.
+ * config/ns32k/netbsd.h: Include <netbsd-aout.h>.
+ * config.gcc (*-*-netbsd*): Add definitions common to all
+ NetBSD configs.
+ (alpha*-*-netbsd*): Remove redundant xm_defines, gas, and
+ gnu_ld definitions. Add netbsd-elf.h to and remove
+ alpha/netbsd-elf.h from tm_file. Remove alpha/t-crtfm from
+ tmake_file, and don't lose previous tmake_file contents.
+ (arm*-*-netbsd*): Add netbsd-aout.h to tm_file.
+ (i[34567]86-*-netbsdelf*): Remove redundant xm_defines, gas, and
+ gnu_ld definitions. Add netbsd-elf.h to tm_file.
+ (mips-dec-netbsd*): Remove as alias for mipsel-*-netbsd*.
+ (mipsel-*-netbsd*): Rename this to...
+ (mips*-*-netbsd*): ...this. Add elfos.h to tm_file. Add
+ mips/little.h to tm_file for mips*el-*.
+ (powerpc-*-netbsd*): Remove redundant xm_defines definition.
+ (sparc-*-netbsd*): Add netbsd-aout.h to tm_file.
+ (vax-*-netbsd*): Add netbsd-aout.h to tm_file.
+
2002-01-21 John David Anglin <dave@hiauly1.hia.nrc.ca>
* pa-protos.h (reg_before_reload_operand): New function prototype.
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 1996c2f8d36..7a86bee20a5 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -277,7 +277,7 @@ case $machine in
;;
esac
-# Common parts for GNU/Linux, GNU/Hurd, OpenBSD and FreeBSD systems.
+# Common parts for GNU/Linux, GNU/Hurd, OpenBSD, NetBSD, and FreeBSD systems.
case $machine in
*-*-linux*)
xm_defines=POSIX
@@ -312,6 +312,12 @@ case $machine in
tmake_file="${tmake_file} t-openbsd-thread"
fi
;;
+*-*-netbsd*)
+ tmake_file="t-libc-ok t-netbsd"
+ xm_defines=POSIX
+ gas=yes
+ gnu_ld=yes
+ ;;
*-*-freebsd[12] | *-*-freebsd[12].* | *-*-freebsd*aout*)
# This is the place-holder for the generic a.out configuration
# of FreeBSD. No actual configuration resides here since
@@ -469,11 +475,9 @@ alpha*-*-freebsd*)
tmake_file="${tmake_file} alpha/t-crtbe alpha/t-crtfm alpha/t-alpha alpha/t-ieee"
;;
alpha*-*-netbsd*)
- xm_defines=POSIX
- tm_file="${tm_file} alpha/elf.h alpha/netbsd.h alpha/netbsd-elf.h"
+ tm_file="${tm_file} netbsd.h alpha/elf.h netbsd-elf.h alpha/netbsd.h"
target_cpu_default="MASK_GAS"
- tmake_file="alpha/t-crtbe alpha/t-crtfm alpha/t-alpha alpha/t-ieee"
- gas=yes gnu_ld=yes
+ tmake_file="${tmake_file} alpha/t-alpha alpha/t-crtbe alpha/t-ieee"
;;
alpha*-*-openbsd*)
@@ -613,7 +617,7 @@ arm*-*-freebsd*|strongarm*-*-freebsd*)
tmake_file="${tmake_file} arm/t-strongarm-elf"
;;
arm*-*-netbsd*)
- tm_file="arm/aout.h arm/arm.h netbsd.h arm/netbsd.h"
+ tm_file="arm/aout.h arm/arm.h netbsd.h netbsd-aout.h arm/netbsd.h"
tmake_file="t-netbsd arm/t-netbsd"
use_collect2=yes
;;
@@ -1124,10 +1128,7 @@ i[34567]86-*-freebsd*)
tm_file="${tm_file} i386/att.h dbxelf.h elfos.h svr4.h ${fbsd_tm_file} i386/freebsd.h"
;;
i[34567]86-*-netbsdelf*)
- xm_defines=POSIX
- tm_file="${tm_file} i386/att.h dbxelf.h elfos.h svr4.h i386/netbsd-elf.h"
- tmake_file=t-netbsd
- gnu_ld=yes
+ tm_file="${tm_file} i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h"
float_format=i386
;;
i[34567]86-*-netbsd*)
@@ -2231,10 +2232,13 @@ mips-dec-bsd*) # Decstation running 4.4 BSD
use_collect2=yes
fi
;;
-mipsel-*-netbsd* | mips-dec-netbsd*) # Decstation running NetBSD
- tm_file=mips/netbsd.h
- # On NetBSD, the headers are already okay, except for math.h.
- tmake_file=t-netbsd
+mips*-*-netbsd*) # NetBSD/mips, either endian.
+ tm_file="elfos.h mips/netbsd.h"
+ case $machine in
+ mips*el-*)
+ tm_file="mips/little.h $tm_file"
+ ;;
+ esac
;;
mips*-*-linux*) # Linux MIPS, either endian.
tm_file="dbxelf.h elfos.h svr4.h linux.h mips/linux.h"
@@ -2650,7 +2654,6 @@ powerpc-*-sysv*)
tmake_file="rs6000/t-ppcos rs6000/t-ppccomm"
;;
powerpc-*-netbsd*)
- xm_defines=POSIX
tm_file="${tm_file} dbxelf.h elfos.h svr4.h freebsd-spec.h rs6000/sysv4.h rs6000/netbsd.h"
tmake_file="rs6000/t-ppcos rs6000/t-ppccomm"
;;
@@ -2892,7 +2895,7 @@ sparc-*-aout*)
tm_file="sparc/sparc.h aoutos.h sparc/aout.h libgloss.h"
;;
sparc-*-netbsd*)
- tm_file="${tm_file} sparc/aout.h netbsd.h sparc/netbsd.h"
+ tm_file="${tm_file} sparc/aout.h netbsd.h netbsd-aout.h sparc/netbsd.h"
tmake_file=t-netbsd
use_collect2=yes
;;
@@ -3206,7 +3209,7 @@ vax-*-sysv*) # VAXen running system V
float_format=vax
;;
vax-*-netbsd*)
- tm_file="${tm_file} netbsd.h vax/netbsd.h"
+ tm_file="${tm_file} netbsd.h netbsd-aout.h vax/netbsd.h"
tmake_file=t-netbsd
float_format=vax
use_collect2=yes
diff --git a/gcc/config/alpha/netbsd-elf.h b/gcc/config/alpha/netbsd-elf.h
deleted file mode 100644
index 6e4f4daf62b..00000000000
--- a/gcc/config/alpha/netbsd-elf.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Definitions of target machine for GNU compiler
- for Alpha NetBSD systems using ELF.
- 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, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (Alpha NetBSD/ELF)");
-
-#undef SUB_CPP_PREDEFINES
-#define SUB_CPP_PREDEFINES "-D__ELF__"
-
-#undef SUBTARGET_EXTRA_SPECS
-#define SUBTARGET_EXTRA_SPECS \
-{ "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
-
-#define ELF_DYNAMIC_LINKER "/usr/libexec/ld.elf_so"
diff --git a/gcc/config/alpha/netbsd.h b/gcc/config/alpha/netbsd.h
index 0a10f5ae0dc..7eacce23f8c 100644
--- a/gcc/config/alpha/netbsd.h
+++ b/gcc/config/alpha/netbsd.h
@@ -1,6 +1,6 @@
/* Definitions of target machine for GNU compiler,
for Alpha NetBSD systems.
- Copyright (C) 1998 Free Software Foundation, Inc.
+ Copyright (C) 1998, 2002 Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -23,11 +23,75 @@ Boston, MA 02111-1307, USA. */
#define TARGET_DEFAULT (MASK_FP | MASK_FPREGS | MASK_GAS)
#undef CPP_PREDEFINES
-#define CPP_PREDEFINES "-D_LONGLONG -Dnetbsd -Dunix " SUB_CPP_PREDEFINES
+#define CPP_PREDEFINES \
+ "-D__NetBSD__ -D__ELF__ -Asystem=unix -Asystem=NetBSD"
-#undef LIB_SPEC
-#define LIB_SPEC "%{pg:-lgmon} %{pg:-lc_p} %{!pg:-lc}"
/* Show that we need a GP when profiling. */
#undef TARGET_PROFILING_NEEDS_GP
#define TARGET_PROFILING_NEEDS_GP 1
+
+
+/* Provide a CPP_SPEC appropriate for NetBSD/alpha. In addition to
+ the standard NetBSD specs, we also handle Alpha FP mode indications. */
+
+#undef CPP_SPEC
+#define CPP_SPEC \
+ "%{mieee:-D_IEEE_FP} \
+ %{mieee-with-inexact:-D_IEEE_FP -D_IEEE_FP_INEXACT} \
+ %(cpp_cpu) %(cpp_subtarget)"
+
+#undef CPP_SUBTARGET_SPEC
+#define CPP_SUBTARGET_SPEC \
+ "%{posix:-D_POSIX_SOURCE}"
+
+
+/* Provide a LINK_SPEC appropriate for a NetBSD/alpha ELF target.
+ This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
+ the alpha target. */
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "%{G*} %{relax:-relax} \
+ %{O*:-O3} %{!O*:-O1} \
+ %{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}}"
+
+
+/* Provide an ENDFILE_SPEC appropriate for NetBSD/alpha ELF. Here we
+ add crtend.o, which provides part of the support for getting
+ C++ file-scope static objects deconstructed after exiting "main".
+
+ We also need to handle the GCC option `-ffast-math'. */
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC \
+ "%{ffast-math|funsafe-math-optimizations:crtfm%O%s} \
+ %{!shared:crtend%O%s} %{shared:crtendS%O%s}"
+
+
+/* Make gcc agree with <machine/ansi.h> */
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef WCHAR_UNSIGNED
+#define WCHAR_UNSIGNED 0
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+#undef WINT_TYPE
+#define WINT_TYPE "int"
+
+#undef TARGET_VERSION
+#define TARGET_VERSION fprintf (stderr, " (NetBSD/alpha ELF)");
diff --git a/gcc/config/i386/netbsd-elf.h b/gcc/config/i386/netbsd-elf.h
index cc6f3948539..7ff3c21fdea 100644
--- a/gcc/config/i386/netbsd-elf.h
+++ b/gcc/config/i386/netbsd-elf.h
@@ -1,6 +1,6 @@
/* Definitions of target machine for GNU compiler,
for i386/ELF NetBSD systems.
- Copyright (C) 2001 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
Contributed by matthew green <mrg@eterna.com.au>
This file is part of GNU CC.
@@ -20,87 +20,28 @@ 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. */
-/* Provide a LIB_SPEC appropriate for NetBSD. Just select the appropriate
- libc, depending on whether we're doing profiling; if `-posix' is specified,
- link against the appropriate libposix first. */
-
-#undef LIB_SPEC
-#define LIB_SPEC \
- "%{posix:%{!p:%{!pg:-lposix}}%{p:-lposix_p}%{pg:-lposix_p}} \
- %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
-
-/* 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'. We use the NetBSD crt0. */
-
-#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/i386 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. */
+/* Provide a LINK_SPEC appropriate for a NetBSD/i386 ELF target.
+ This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
+ the i386 target. */
#undef LINK_SPEC
-#define LINK_SPEC \
- "-m elf_i386 \
- %{assert*} %{R*} \
- %{shared:-shared} \
- %{!shared: \
- -dp \
- %{!nostdlib:%{!r*:%{!e*:-e __start}}} \
- %{!static: \
- -dy %{rdynamic:-export-dynamic} \
- %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
+#define LINK_SPEC \
+ "%{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}}"
-/* Provide a CPP_SPEC appropriate for NetBSD. Current we just deal with
- the GCC option `-posix'. */
-
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
-
-/* Provide an ASM_SPEC appropriate for NetBSD. Currently we only deal
- with the options for generating PIC code. */
-
-#undef ASM_SPEC
-#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. */
-
-#undef LIB_SPEC
-#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
-
-/* This defines which switch letters take arguments. */
-#undef SWITCH_TAKES_ARG
-#define SWITCH_TAKES_ARG(CHAR) \
- (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
- || (CHAR) == 'R')
-
-/* Implicit library calls should use memcpy, not bcopy, etc. */
-
-#define TARGET_MEM_FUNCTIONS
-
/* Names to predefine in the preprocessor for this target machine. */
-#define CPP_PREDEFINES "\
--Di386 -D__NetBSD__ -D__ELF__ -Asystem(unix) -Asystem(NetBSD)"
+#define CPP_PREDEFINES \
+ "-D__NetBSD__ -D__ELF__ -Asystem=unix -Asystem=NetBSD"
/* Make gcc agree with <machine/ansi.h> */
@@ -122,10 +63,6 @@ Boston, MA 02111-1307, USA. */
#undef WINT_TYPE
#define WINT_TYPE "int"
-/* 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"
@@ -133,14 +70,29 @@ Boston, MA 02111-1307, USA. */
#define ASM_APP_OFF "#NO_APP\n"
#undef ASM_FINAL_SPEC
-#define ASM_FINAL_SPEC "%{pipe:-}"
+
+#undef ASM_COMMENT_START
+#define ASM_COMMENT_START "#"
#undef DBX_REGISTER_NUMBER
#define DBX_REGISTER_NUMBER(n) svr4_dbx_register_map[n]
-#undef NO_PROFILE_COUNTERS
+
+/* Output assembler code to FILE to call the profiler. */
+
+#undef NO_PROFILE_COUNTERS
#define NO_PROFILE_COUNTERS
+#undef FUNCTION_PROFILER
+#define FUNCTION_PROFILER(FILE, LABELNO) \
+{ \
+ if (flag_pic) \
+ fprintf (FILE, "\tcall __mcount@PLT\n"); \
+ else \
+ fprintf (FILE, "\tcall __mcount\n"); \
+}
+
+
#undef HAS_INIT_SECTION
/* This is how we tell the assembler that two symbols have the same value. */
@@ -158,16 +110,15 @@ Boston, MA 02111-1307, USA. */
This is used to align code labels according to Intel recommendations. */
#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN
-#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \
- if ((LOG) != 0) { \
+#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \
+ if ((LOG) != 0) { \
if ((MAX_SKIP) == 0) fprintf ((FILE), "\t.p2align %d\n", (LOG)); \
else fprintf ((FILE), "\t.p2align %d,,%d\n", (LOG), (MAX_SKIP)); \
}
#endif
-/*
- * We always use gas here, so we don't worry about ECOFF assembler problems.
- */
+/* We always use gas here, so we don't worry about ECOFF assembler
+ problems. */
#undef TARGET_GAS
#define TARGET_GAS 1
@@ -176,4 +127,4 @@ Boston, MA 02111-1307, USA. */
#define DEFAULT_PCC_STRUCT_RETURN 1
#undef TARGET_VERSION
-#define TARGET_VERSION fprintf (stderr, " (NetBSD/i386 ELF target)");
+#define TARGET_VERSION fprintf (stderr, " (NetBSD/i386 ELF)");
diff --git a/gcc/config/i386/netbsd.h b/gcc/config/i386/netbsd.h
index 8f5ba201e9a..659a4f0fd3f 100644
--- a/gcc/config/i386/netbsd.h
+++ b/gcc/config/i386/netbsd.h
@@ -5,6 +5,7 @@
/* Get generic NetBSD definitions. */
#include <netbsd.h>
+#include <netbsd-aout.h>
/* This goes away when the math-emulator is fixed */
#undef TARGET_SUBTARGET_DEFAULT
diff --git a/gcc/config/m68k/netbsd.h b/gcc/config/m68k/netbsd.h
index a90ddbc9c4e..07dd4e8cc34 100644
--- a/gcc/config/m68k/netbsd.h
+++ b/gcc/config/m68k/netbsd.h
@@ -3,6 +3,7 @@
/* Get generic NetBSD definitions. */
#include <netbsd.h>
+#include <netbsd-aout.h>
#define TARGET_DEFAULT (MASK_BITFIELD|MASK_68881|MASK_68020)
diff --git a/gcc/config/mips/netbsd.h b/gcc/config/mips/netbsd.h
index 09229f149b3..95d3901df94 100644
--- a/gcc/config/mips/netbsd.h
+++ b/gcc/config/mips/netbsd.h
@@ -1,5 +1,6 @@
-/* Definitions for DECstation running BSD as target machine for GNU compiler.
- Copyright (C) 1993, 1995, 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Definitions of target machine for GNU compiler, for MIPS NetBSD systems.
+ Copyright (C) 1993, 1995, 1996, 1997, 1999, 2000, 2001, 2002
+ Free Software Foundation, Inc.
This file is part of GNU CC.
@@ -18,212 +19,177 @@ 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. */
-#define DECSTATION
-/* Look for the include files in the system-defined places. */
+/* Define default target values. */
-#ifndef CROSS_COMPILE
-#undef GPLUSPLUS_INCLUDE_DIR
-#define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++"
+#ifndef TARGET_ENDIAN_DEFAULT
+#define TARGET_ENDIAN_DEFAULT MASK_BIG_ENDIAN
+#endif
-#undef GCC_INCLUDE_DIR
-#define GCC_INCLUDE_DIR "/usr/include"
+#ifndef MACHINE_TYPE
+#if TARGET_ENDIAN_DEFAULT != 0
+#define MACHINE_TYPE "NetBSD/mipseb ELF"
+#else
+#define MACHINE_TYPE "NetBSD/mipsel ELF"
+#endif
+#endif
-#undef INCLUDE_DEFAULTS
-#define INCLUDE_DEFAULTS \
- { \
- { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \
- { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \
- { 0, 0, 0, 0 } \
- }
+#define TARGET_DEFAULT (MASK_GAS|MASK_ABICALLS)
-/* Under NetBSD, the normal location of the various *crt*.o files is the
- /usr/lib directory. */
-#undef STANDARD_STARTFILE_PREFIX
-#define STANDARD_STARTFILE_PREFIX "/usr/lib/"
-#endif
+/* XXX Don't use DWARF-2 debugging info, for now. */
+#undef DBX_DEBUGGING_INFO
+#define DBX_DEBUGGING_INFO
+#undef PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
-/* 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 \
- "%{G*} %{EB} %{EL} %{mips1} %{mips2} %{mips3} \
- %{!nostartfiles:%{!r*:%{!e*:-e __start}}} -dc -dp %{static:-Bstatic} %{assert*}"
+/* Include the generic MIPS ELF configuration. */
+#include <mips/elf.h>
+
+/* Now clean up after it. */
+#undef OBJECT_FORMAT_COFF
+#undef MD_EXEC_PREFIX
+#undef MD_STARTFILE_PREFIX
+#undef US_SOFTWARE_GOFAST
+#undef INIT_SUBTARGET_OPTABS
+#define INIT_SUBTARGET_OPTABS
+
-/* Implicit library calls should use memcpy, not bcopy, etc. */
+/* Get generic NetBSD definitions. */
+#include <netbsd.h>
-#define TARGET_MEM_FUNCTIONS
-/* Define mips-specific netbsd predefines... */
-#ifndef CPP_PREDEFINES
-#define CPP_PREDEFINES "-D__ANSI_COMPAT \
--DMIPSEL -DR3000 -DSYSTYPE_BSD -D_SYSTYPE_BSD -D__NetBSD__ -Dmips \
--D__NO_LEADING_UNDERSCORES__ -D__GP_SUPPORT__ \
--Dunix -D_R3000 \
--Asystem=unix -Asystem=NetBSD -Amachine=mips"
+/* Get generic NetBSD ELF definitions. */
+#include <netbsd-elf.h>
+
+
+/* Provide CPP predefines appropriate for NetBSD. We default to
+ MIPS-I. */
+
+#undef CPP_PREDEFINES
+#if TARGET_ENDIAN_DEFAULT != 0
+#define CPP_PREDEFINES \
+ "-D__NetBSD__ -D__ELF__ -D__mips__ -D__mips=1 -D__MIPSEB__ \
+ -D__NO_LEADING_UNDERSCORES__ -D__GP_SUPPORT__ \
+ -Asystem=unix -Asystem=NetBSD -Amachine=mips"
+#else
+#define CPP_PREDEFINES \
+ "-D__NetBSD__ -D__ELF__ -D__mips__ -D__mips=1 -D__MIPSEL__ \
+ -D__NO_LEADING_UNDERSCORES__ -D__GP_SUPPORT__ \
+ -Asystem=unix -Asystem=NetBSD -Amachine=mips"
#endif
-#ifndef SUBTARGET_CPP_SPEC
+
+/* Provide a CPP_SPEC appropriate for NetBSD. This is a simplified
+ CPP_SPEC from <mips/mips.h>. We use the SUBTARGET_CPP_SPEC to
+ deal with NetBSD-specific CPP options. */
+
+#undef CPP_SPEC
+#define CPP_SPEC \
+ "%(subtarget_cpp_size_spec) \
+ %{mips3:-U__mips -D__mips=3 -D__mips64} \
+ %{mips4:-U__mips -D__mips=4 -D__mips64} \
+ %{mips32:-U__mips -D__mips=32} \
+ %{mips64:-U__mips -D__mips=64 -D__mips64} \
+ %{mgp32:-U__mips64} %{mgp64:-D__mips64} \
+ %{mfp32:-D__mips_fpr=32} %{mfp64:-D__mips_fpr=64} \
+ %{!mfp32: \
+ %{!mfp64: \
+ %{mgp32:-D__mips_fpr=32} \
+ %{!mgp32: %(cpp_fpr_spec)}}} \
+ %{msingle-float: \
+ %{!msoft-float:-D__mips_single_float}} \
+ %{m4650: \
+ %{!msoft-float:-D__mips_single_float}} \
+ %{msoft-float:-D__mips_soft_float} \
+ %{mabi=eabi:-D__mips_eabi} \
+ %{mips16:%{!mno-mips16:-D__mips16}} \
+ %{EB:-U__MIPSEL__ -D__MIPSEB__} \
+ %{EL:-U__MIPSEB__ -D__MIPSEL__} \
+ %(subtarget_cpp_spec) "
+
+
+/* Provide a SUBTARGET_CPP_SIZE_SPEC appropriate for NetBSD. In
+ addition to the normal work done by this spec, we also define
+ __LONG64 or not (so that <machine/ansi.h> can tell). */
+
+#undef SUBTARGET_CPP_SIZE_SPEC
+#define SUBTARGET_CPP_SIZE_SPEC \
+ "%{mlong64: \
+ %{!mips1: \
+ %{!mips2: \
+ %{!mips32:-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int -D__LONG64}}}} \
+ %{!mlong64:-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int -U__LONG64}"
+
+
+/* Provide a SUBTARGET_CPP_SPEC appropriate for NetBSD. Currently,
+ we just deal with the GCC option '-posix'. */
+
+#undef SUBTARGET_CPP_SPEC
#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
-#endif
-#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
-#define STARTFILE_SPEC ""
-#ifndef MACHINE_TYPE
-#define MACHINE_TYPE "NetBSD/pmax"
-#endif
+/* Provide a LINK_SPEC appropriate for a NetBSD/mips target.
+ This is a copy of LINK_SPEC from <netbsd-elf.h> tweaked for
+ the MIPS target. */
-#define TARGET_DEFAULT MASK_GAS
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "%{assert*} %{R*} %{rpath*} \
+ %{EL:-m elf32lmip} \
+ %{EB:-m elf32bmip} \
+ %(endian_spec) \
+ %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips64} \
+ %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \
+ %{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 SUBTARGET_ASM_SPEC
+#define SUBTARGET_ASM_SPEC \
+ "%{fpic:-KPIC} %{fPIC:-KPIC}"
+
+
+/* -G is incompatible with -KPIC which is the default, so only allow objects
+ in the small data section if the user explicitly asks for it. */
+
+#undef MIPS_DEFAULT_GVALUE
+#define MIPS_DEFAULT_GVALUE 0
+
+
+/* This defines which switch letters take arguments. -G is a MIPS
+ special. */
+
+#undef SWITCH_TAKES_ARG
+#define SWITCH_TAKES_ARG(CHAR) \
+ (DEFAULT_SWITCH_TAKES_ARG (CHAR) \
+ || (CHAR) == 'R' \
+ || (CHAR) == 'G')
-#include "mips/mips.h"
-
-/*
- * Some imports from svr4.h in support of shared libraries.
- * Currently, we need the DECLARE_OBJECT_SIZE stuff.
- */
-
-/* Define the strings used for the special svr4 .type and .size directives.
- These strings generally do not vary from one system running svr4 to
- another, but if a given system (e.g. m88k running svr) needs to use
- different pseudo-op names for these, they may be overridden in the
- file which includes this one. */
-
-#undef TYPE_ASM_OP
-#undef SIZE_ASM_OP
-#undef WEAK_ASM_OP
-#define TYPE_ASM_OP "\t.type\t"
-#define SIZE_ASM_OP "\t.size\t"
-#define WEAK_ASM_OP "\t.weak\t"
-
-/* The following macro defines the format used to output the second
- operand of the .type assembler directive. Different svr4 assemblers
- expect various different forms for this operand. The one given here
- is just a default. You may need to override it in your machine-
- specific tm.h file (depending upon the particulars of your assembler). */
-
-#undef TYPE_OPERAND_FMT
-#define TYPE_OPERAND_FMT "@%s"
-
-/* Write the extra assembler code needed to declare a function's result.
- Most svr4 assemblers don't require any special declaration of the
- result value, but there are exceptions. */
-
-#ifndef ASM_DECLARE_RESULT
-#define ASM_DECLARE_RESULT(FILE, RESULT)
-#endif
-/* These macros generate the special .type and .size directives which
- are used to set the corresponding fields of the linker symbol table
- entries in an ELF object file under SVR4. These macros also output
- the starting labels for the relevant functions/objects. */
-
-/* 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. */
-
-#undef ASM_DECLARE_FUNCTION_NAME
-#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
- do { \
- fprintf (FILE, "%s", TYPE_ASM_OP); \
- assemble_name (FILE, NAME); \
- putc (',', FILE); \
- fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
- putc ('\n', FILE); \
- ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
- } while (0)
-
-/* Write the extra assembler code needed to declare an object properly. */
-
-#undef ASM_DECLARE_OBJECT_NAME
-#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
- do { \
- fprintf (FILE, "%s", TYPE_ASM_OP); \
- assemble_name (FILE, NAME); \
- putc (',', FILE); \
- fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
- putc ('\n', FILE); \
- size_directive_output = 0; \
- if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
- { \
- size_directive_output = 1; \
- fprintf (FILE, "%s", SIZE_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, ","); \
- fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
- int_size_in_bytes (TREE_TYPE (DECL))); \
- fprintf (FILE, "\n"); \
- } \
- ASM_OUTPUT_LABEL(FILE, NAME); \
- } while (0)
-
-/* Output the size directive for a decl in rest_of_decl_compilation
- in the case where we did not do so before the initializer.
- Once we find the error_mark_node, we know that the value of
- size_directive_output was set
- by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
-
-#undef ASM_FINISH_DECLARE_OBJECT
-#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
-do { \
- const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
- if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
- && ! AT_END && TOP_LEVEL \
- && DECL_INITIAL (DECL) == error_mark_node \
- && !size_directive_output) \
- { \
- size_directive_output = 1; \
- fprintf (FILE, "%s", SIZE_ASM_OP); \
- assemble_name (FILE, name); \
- fprintf (FILE, ","); \
- fprintf (FILE, HOST_WIDE_INT_PRINT_DEC, \
- int_size_in_bytes (TREE_TYPE (DECL))); \
- fprintf (FILE, "\n"); \
- } \
- } while (0)
-
-/* This is how to declare the size of a function. */
-
-#undef ASM_DECLARE_FUNCTION_SIZE
-#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
- do { \
- if (!flag_inhibit_size_directive) \
- { \
- char label[256]; \
- static int labelno; \
- labelno++; \
- ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
- ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
- fprintf (FILE, "%s", SIZE_ASM_OP); \
- assemble_name (FILE, (FNAME)); \
- fprintf (FILE, ","); \
- assemble_name (FILE, label); \
- fprintf (FILE, "-"); \
- assemble_name (FILE, (FNAME)); \
- putc ('\n', FILE); \
- } \
- } while (0)
-
-/* Switch into a generic section. */
-#undef TARGET_ASM_NAMED_SECTION
-#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
-
-/* Not having TARGET_GAS here seems a mistake. If we actually need to
- be prepared for file switching, then we need a custom
- TARGET_ASM_NAMED_SECTION too. */
-
-#undef TEXT_SECTION
-#define TEXT_SECTION() \
-do { \
- if (TARGET_FILE_SWITCHING) \
- abort (); \
- fputs (TEXT_SECTION_ASM_OP, asm_out_file); \
- fputc ('\n', asm_out_file); \
-} while (0)
-
-/* Since gas and gld are standard on NetBSD, we don't need these */
#undef ASM_FINAL_SPEC
-#undef STARTFILE_SPEC
+#undef SET_ASM_OP
+
+
+/* Make gcc agree with <machine/ansi.h> */
+
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+
+#undef WCHAR_UNSIGNED
+#define WCHAR_UNSIGNED 0
+
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE 32
+
+#undef WINT_TYPE
+#define WINT_TYPE "int"
diff --git a/gcc/config/netbsd-aout.h b/gcc/config/netbsd-aout.h
new file mode 100644
index 00000000000..867f99a14e0
--- /dev/null
+++ b/gcc/config/netbsd-aout.h
@@ -0,0 +1,215 @@
+/* Common configuration file for NetBSD a.out targets.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Wasabi Systems, 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 defines which switch letters take arguments. */
+
+#undef SWITCH_TAKES_ARG
+#define SWITCH_TAKES_ARG(CHAR) \
+ (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
+ || (CHAR) == 'R')
+
+
+/* Provide an ASM_SPEC appropriate for NetBSD. Currently we only deal
+ with the options for generating PIC code. */
+
+#undef ASM_SPEC
+#define ASM_SPEC " %| %{fpic:-k} %{fPIC:-k -K}"
+
+
+/* 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 a.out. Here we provide
+ support for the special GCC options -static, -assert, and -nostdlib. */
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "%{nostdlib:-nostdlib} \
+ %{!shared: \
+ %{!nostdlib: \
+ %{!r*: \
+ %{!e*:-e start}}} \
+ -dc -dp \
+ %{static:-Bstatic}} \
+ %{shared:-Bshareable} \
+ %{R*} \
+ %{assert*}"
+
+
+/* Some imports from svr4.h in support of shared libraries. */
+
+/* Define the strings used for the .type, .size, and .set directives.
+ These strings generally do not vary from one system running NetBSD
+ to another, but if a given system needs to use different pseudo-op
+ names for these, they may be overridden in the file included after
+ this one. */
+
+#undef TYPE_ASM_OP
+#undef SIZE_ASM_OP
+#undef SET_ASM_OP
+#define TYPE_ASM_OP "\t.type\t"
+#define SIZE_ASM_OP "\t.size\t"
+#define SET_ASM_OP "\t.set\t"
+
+
+/* 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.globl\t", FILE); assemble_name (FILE, NAME); \
+ fputc ('\n', FILE); \
+ fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
+ fputc ('\n', FILE); \
+ } \
+ while (0)
+
+
+/* The following macro defines the format used to output the second
+ operand of the .type assembler directive. Different svr4 assemblers
+ expect various different forms of this operand. The one given here
+ is just a default. You may need to override it in your machine-
+ specific tm.h file (depending on the particulars of your assembler). */
+
+#undef TYPE_OPERAND_FMT
+#define TYPE_OPERAND_FMT "@%s"
+
+
+/* Write the extra assembler code needed to declare a function's result.
+ Most svr4 assemblers don't require any special declaration of the
+ result value, but there are exceptions. */
+
+#ifndef ASM_DECLARE_RESULT
+#define ASM_DECLARE_RESULT(FILE, RESULT)
+#endif
+
+
+/* These macros generate the special .type and .size directives which
+ are used to set the corresponding fields of the linker symbol table
+ entries in an ELF object file under SVR4 (and a.out on NetBSD).
+ These macros also output the starting labels for the relevant
+ functions/objects. */
+
+/* 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. */
+
+#undef ASM_DECLARE_FUNCTION_NAME
+#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
+ do \
+ { \
+ fprintf (FILE, "%s", TYPE_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ putc (',', FILE); \
+ fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
+ putc ('\n', FILE); \
+ ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
+ ASM_OUTPUT_LABEL(FILE, NAME); \
+ } \
+ while (0)
+
+
+/* Write the extra assembler code needed to declare an object properly. */
+
+#undef ASM_DECLARE_OBJECT_NAME
+#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
+ do \
+ { \
+ fprintf (FILE, "%s", TYPE_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ putc (',', FILE); \
+ fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
+ putc ('\n', FILE); \
+ size_directive_output = 0; \
+ if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
+ { \
+ size_directive_output = 1; \
+ fprintf (FILE, "%s", SIZE_ASM_OP); \
+ assemble_name (FILE, NAME); \
+ fprintf (FILE, ",%d\n", \
+ int_size_in_bytes (TREE_TYPE (DECL))); \
+ } \
+ ASM_OUTPUT_LABEL(FILE, NAME); \
+ }
+ while (0)
+
+
+/* Output the size directive for a decl in rest_of_decl_compilation
+ in the case where we did not do so before the initializer.
+ Once we find the error_mark_node, we know that the value of
+ size_directive_output was set
+ by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
+
+#undef ASM_FINISH_DECLARE_OBJECT
+#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
+ do \
+ { \
+ const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
+ if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
+ && ! AT_END && TOP_LEVEL \
+ && DECL_INITIAL (DECL) == error_mark_node \
+ && !size_directive_output) \
+ { \
+ size_directive_output = 1; \
+ fprintf (FILE, "%s", SIZE_ASM_OP); \
+ assemble_name (FILE, name); \
+ fprintf (FILE, ",%d\n", \
+ int_size_in_bytes (TREE_TYPE (DECL))); \
+ } \
+ } \
+ while (0)
+
+
+/* This is how to declare the size of a function. */
+
+#undef ASM_DECLARE_FUNCTION_SIZE
+#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
+ do \
+ { \
+ if (!flag_inhibit_size_directive) \
+ { \
+ char label[256]; \
+ static int labelno; \
+ labelno++; \
+ ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
+ ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
+ fprintf (FILE, "%s", SIZE_ASM_OP); \
+ assemble_name (FILE, (FNAME)); \
+ fprintf (FILE, ","); \
+ assemble_name (FILE, label); \
+ fprintf (FILE, "-"); \
+ assemble_name (FILE, (FNAME)); \
+ putc ('\n', FILE); \
+ } \
+ } \
+ while (0)
diff --git a/gcc/config/netbsd-elf.h b/gcc/config/netbsd-elf.h
new file mode 100644
index 00000000000..7dd9ff3d66d
--- /dev/null
+++ b/gcc/config/netbsd-elf.h
@@ -0,0 +1,76 @@
+/* Common configuration file for NetBSD ELF targets.
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Wasabi Systems, 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 defines which switch letters take arguments. On NetBSD, most
+ of the normal cases (defined by gcc.c) apply, and we also have -h*
+ and -z* options (for the linker) (coming from SVR4). */
+
+#undef SWITCH_TAKES_ARG
+#define SWITCH_TAKES_ARG(CHAR) \
+ (DEFAULT_SWITCH_TAKES_ARG (CHAR) \
+ || (CHAR) == 'h' \
+ || (CHAR) == 'z' \
+ || (CHAR) == 'R')
+
+
+/* Provide a STARTFILE_SPEC appropriate for NetBSD ELF. 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. 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 NetBSD ELF. Here we provide
+ support for the special GCC options -assert, -R, -rpath, -shared,
+ -nostdlib, -static, -rdynamic, and -dynamic-linker. */
+
+#undef LINK_SPEC
+#define LINK_SPEC \
+ "%{assert*} %{R*} %{rpath*} \
+ %{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}}"
diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h
index a7b10b33f3e..5894174791e 100644
--- a/gcc/config/netbsd.h
+++ b/gcc/config/netbsd.h
@@ -32,33 +32,51 @@
#undef STANDARD_STARTFILE_PREFIX
#define STANDARD_STARTFILE_PREFIX "/usr/lib/"
-#endif
+#endif /* NETBSD_NATIVE */
-/* Provide a CPP_SPEC appropriate for NetBSD. Current we just deal with
+/* Provide a CPP_SPEC appropriate for NetBSD. Currently we just deal with
the GCC option `-posix'. */
#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
-
-/* Provide an ASM_SPEC appropriate for NetBSD. Currently we only deal
- with the options for generating PIC code. */
+#define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE}"
-#undef ASM_SPEC
-#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. Don't include libc when
+ linking a shared library. */
#undef LIB_SPEC
-#define LIB_SPEC "%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}"
-
-/* Provide a LINK_SPEC appropriate for NetBSD. Here we provide support
- for the special GCC options -shared, -static, -assert, and -nostdlib. */
-
-#undef LINK_SPEC
-#define LINK_SPEC \
- "%{!shared:%{!nostdlib:%{!r*:%{!e*:-e start}}} -dc -dp %{R*} %{static:-Bstatic}} %{shared} %{assert*}"
+#define LIB_SPEC \
+ "%{posix: \
+ %{!p: \
+ %{!pg:-lposix}} \
+ %{p:-lposix_p} \
+ %{pg:-lposix_p}} \
+ %{!shared: \
+ %{!symbolic: \
+ %{!p: \
+ %{!pg:-lc}} \
+ %{p:-lc_p} \
+ %{pg:-lc_p}}}"
+
+/* Provide a LIBGCC_SPEC appropriate for NetBSD. We also want to exclude
+ libgcc with -symbolic. */
+
+#undef LIBGCC_SPEC
+#ifdef NETBSD_NATIVE
+#define LIBGCC_SPEC \
+ "%{!symbolic: \
+ %{!shared: \
+ %{!p: \
+ %{!pg:-lgcc}}} \
+ %{shared:-lgcc_pic} \
+ %{p:-lgcc_p} \
+ %{pg:-lgcc_p}}"
+#else
+#define LIBGCC_SPEC "%{!shared:%{!symbolic:-lgcc}}"
+#endif
/* When building shared libraries, the initialization and finalization
functions for the library are .init and .fini respectively. */
@@ -75,11 +93,13 @@
fprintf ((STREAM), "void __fini() {\n\t%s();\n}\n", (FUNC)); \
} while (0)
-/* This defines which switch letters take arguments. */
-#undef SWITCH_TAKES_ARG
-#define SWITCH_TAKES_ARG(CHAR) \
- (DEFAULT_SWITCH_TAKES_ARG(CHAR) \
- || (CHAR) == 'R')
+/* Allow #sccs in preprocessor. */
+
+#undef SCCS_DIRECTIVE
+#define SCCS_DIRECTIVE
+
+#undef TARGET_HAS_F_SETLKW
+#define TARGET_HAS_F_SETLKW
/* Implicit library calls should use memcpy, not bcopy, etc. */
@@ -89,133 +109,3 @@
/* Handle #pragma weak and #pragma pack. */
#define HANDLE_SYSV_PRAGMA
-
-/*
- * Some imports from svr4.h in support of shared libraries.
- * Currently, we need the DECLARE_OBJECT_SIZE stuff.
- */
-
-/* Define the strings used for the .type, .size, and .set directives.
- These strings generally do not vary from one system running netbsd
- to another, but if a given system needs to use different pseudo-op
- names for these, they may be overridden in the file which includes
- this one. */
-
-#undef TYPE_ASM_OP
-#undef SIZE_ASM_OP
-#undef SET_ASM_OP
-#define TYPE_ASM_OP "\t.type\t"
-#define SIZE_ASM_OP "\t.size\t"
-#define SET_ASM_OP "\t.set\t"
-
-/* 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.globl\t", FILE); assemble_name (FILE, NAME); \
- fputc ('\n', FILE); \
- fputs ("\t.weak\t", FILE); assemble_name (FILE, NAME); \
- fputc ('\n', FILE); } while (0)
-
-/* The following macro defines the format used to output the second
- operand of the .type assembler directive. Different svr4 assemblers
- expect various different forms for this operand. The one given here
- is just a default. You may need to override it in your machine-
- specific tm.h file (depending upon the particulars of your assembler). */
-
-#undef TYPE_OPERAND_FMT
-#define TYPE_OPERAND_FMT "@%s"
-
-/* Write the extra assembler code needed to declare a function's result.
- Most svr4 assemblers don't require any special declaration of the
- result value, but there are exceptions. */
-
-#ifndef ASM_DECLARE_RESULT
-#define ASM_DECLARE_RESULT(FILE, RESULT)
-#endif
-
-/* These macros generate the special .type and .size directives which
- are used to set the corresponding fields of the linker symbol table
- entries in an ELF object file under SVR4. These macros also output
- the starting labels for the relevant functions/objects. */
-
-/* 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. */
-
-#undef ASM_DECLARE_FUNCTION_NAME
-#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
- do { \
- fprintf (FILE, "%s", TYPE_ASM_OP); \
- assemble_name (FILE, NAME); \
- putc (',', FILE); \
- fprintf (FILE, TYPE_OPERAND_FMT, "function"); \
- putc ('\n', FILE); \
- ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
- ASM_OUTPUT_LABEL(FILE, NAME); \
- } while (0)
-
-/* Write the extra assembler code needed to declare an object properly. */
-
-#undef ASM_DECLARE_OBJECT_NAME
-#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
- do { \
- fprintf (FILE, "%s", TYPE_ASM_OP); \
- assemble_name (FILE, NAME); \
- putc (',', FILE); \
- fprintf (FILE, TYPE_OPERAND_FMT, "object"); \
- putc ('\n', FILE); \
- size_directive_output = 0; \
- if (!flag_inhibit_size_directive && DECL_SIZE (DECL)) \
- { \
- size_directive_output = 1; \
- fprintf (FILE, "%s", SIZE_ASM_OP); \
- assemble_name (FILE, NAME); \
- fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
- } \
- ASM_OUTPUT_LABEL(FILE, NAME); \
- } while (0)
-
-/* Output the size directive for a decl in rest_of_decl_compilation
- in the case where we did not do so before the initializer.
- Once we find the error_mark_node, we know that the value of
- size_directive_output was set
- by ASM_DECLARE_OBJECT_NAME when it was run for the same decl. */
-
-#undef ASM_FINISH_DECLARE_OBJECT
-#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP_LEVEL, AT_END) \
-do { \
- const char *name = XSTR (XEXP (DECL_RTL (DECL), 0), 0); \
- if (!flag_inhibit_size_directive && DECL_SIZE (DECL) \
- && ! AT_END && TOP_LEVEL \
- && DECL_INITIAL (DECL) == error_mark_node \
- && !size_directive_output) \
- { \
- size_directive_output = 1; \
- fprintf (FILE, "%s", SIZE_ASM_OP); \
- assemble_name (FILE, name); \
- fprintf (FILE, ",%d\n", int_size_in_bytes (TREE_TYPE (DECL))); \
- } \
- } while (0)
-
-/* This is how to declare the size of a function. */
-
-#undef ASM_DECLARE_FUNCTION_SIZE
-#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \
- do { \
- if (!flag_inhibit_size_directive) \
- { \
- char label[256]; \
- static int labelno; \
- labelno++; \
- ASM_GENERATE_INTERNAL_LABEL (label, "Lfe", labelno); \
- ASM_OUTPUT_INTERNAL_LABEL (FILE, "Lfe", labelno); \
- fprintf (FILE, "%s", SIZE_ASM_OP); \
- assemble_name (FILE, (FNAME)); \
- fprintf (FILE, ","); \
- assemble_name (FILE, label); \
- fprintf (FILE, "-"); \
- assemble_name (FILE, (FNAME)); \
- putc ('\n', FILE); \
- } \
- } while (0)
diff --git a/gcc/config/ns32k/netbsd.h b/gcc/config/ns32k/netbsd.h
index cbbfb859c68..12ffdf77de5 100644
--- a/gcc/config/ns32k/netbsd.h
+++ b/gcc/config/ns32k/netbsd.h
@@ -66,6 +66,7 @@ Boston, MA 02111-1307, USA.
/* Get generic NetBSD definitions. */
#include <netbsd.h>
+#include <netbsd-aout.h>
/* Names to predefine in the preprocessor for this target machine. */
OpenPOWER on IntegriCloud