190075Sobrien/* Common configuration file for NetBSD ELF targets.
290075Sobrien   Copyright (C) 2002 Free Software Foundation, Inc.
390075Sobrien   Contributed by Wasabi Systems, Inc.
490075Sobrien
5132718SkanThis file is part of GCC.
690075Sobrien
7132718SkanGCC is free software; you can redistribute it and/or modify
890075Sobrienit under the terms of the GNU General Public License as published by
990075Sobrienthe Free Software Foundation; either version 2, or (at your option)
1090075Sobrienany later version.
1190075Sobrien
12132718SkanGCC is distributed in the hope that it will be useful,
1390075Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of
1490075SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1590075SobrienGNU General Public License for more details.
1690075Sobrien
1790075SobrienYou should have received a copy of the GNU General Public License
18132718Skanalong with GCC; see the file COPYING.  If not, write to
19169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
20169689SkanBoston, MA 02110-1301, USA.  */
2190075Sobrien
22117395Skan/* TARGET_OS_CPP_BUILTINS() common to all NetBSD ELF targets.  */
23117395Skan#define NETBSD_OS_CPP_BUILTINS_ELF()		\
24117395Skan  do						\
25117395Skan    {						\
26117395Skan      NETBSD_OS_CPP_BUILTINS_COMMON();		\
27117395Skan    }						\
28117395Skan  while (0)
2990075Sobrien
3090075Sobrien/* This defines which switch letters take arguments.  On NetBSD, most
3190075Sobrien   of the normal cases (defined by gcc.c) apply, and we also have -h*
3290075Sobrien   and -z* options (for the linker) (coming from SVR4).  */
3390075Sobrien
3490075Sobrien#undef SWITCH_TAKES_ARG
3590075Sobrien#define SWITCH_TAKES_ARG(CHAR)			\
3690075Sobrien  (DEFAULT_SWITCH_TAKES_ARG (CHAR)		\
3790075Sobrien   || (CHAR) == 'h'				\
3890075Sobrien   || (CHAR) == 'z'				\
3990075Sobrien   || (CHAR) == 'R')
4090075Sobrien
4190075Sobrien
4290075Sobrien/* Provide a STARTFILE_SPEC appropriate for NetBSD ELF.  Here we
4390075Sobrien   provide support for the special GCC option -static.  On ELF
4490075Sobrien   targets, we also add the crtbegin.o file, which provides part
4590075Sobrien   of the support for getting C++ file-scope static objects
4690075Sobrien   constructed before entering "main".  */
4790075Sobrien
48117395Skan#define NETBSD_STARTFILE_SPEC	\
4990075Sobrien  "%{!shared:			\
5090075Sobrien     %{pg:gcrt0%O%s}		\
5190075Sobrien     %{!pg:			\
5290075Sobrien       %{p:gcrt0%O%s}		\
5390075Sobrien       %{!p:crt0%O%s}}}		\
54117395Skan   %:if-exists(crti%O%s)	\
55117395Skan   %{static:%:if-exists-else(crtbeginT%O%s crtbegin%O%s)} \
56117395Skan   %{!static: \
57117395Skan     %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}"
5890075Sobrien
59117395Skan#undef STARTFILE_SPEC
60117395Skan#define STARTFILE_SPEC NETBSD_STARTFILE_SPEC
6190075Sobrien
62117395Skan
6390075Sobrien/* Provide an ENDFILE_SPEC appropriate for NetBSD ELF.  Here we
6490075Sobrien   add crtend.o, which provides part of the support for getting
6590075Sobrien   C++ file-scope static objects deconstructed after exiting "main".  */
6690075Sobrien
67117395Skan#define NETBSD_ENDFILE_SPEC	\
68117395Skan  "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \
69117395Skan   %:if-exists(crtn%O%s)"
70117395Skan
7190075Sobrien#undef ENDFILE_SPEC
72117395Skan#define ENDFILE_SPEC NETBSD_ENDFILE_SPEC
7390075Sobrien
7490075Sobrien/* Provide a LINK_SPEC appropriate for NetBSD ELF.  Here we provide
7590075Sobrien   support for the special GCC options -assert, -R, -rpath, -shared,
76117395Skan   -nostdlib, -static, -rdynamic, and -dynamic-linker.
7790075Sobrien
78117395Skan   Target-specific code can use this in conjunction with any other
79117395Skan   target-specific LINK_SPEC options.
80117395Skan
81117395Skan   Target-specific code must provide the %(netbsd_entry_point) spec.  */
82117395Skan
83117395Skan#define NETBSD_LINK_SPEC_ELF \
84117395Skan  "%{assert*} %{R*} %{rpath*} \
85117395Skan   %{shared:-shared} \
86117395Skan   %{!shared: \
87117395Skan     -dc -dp \
88117395Skan     %{!nostdlib: \
89117395Skan       %{!r*: \
90117395Skan	 %{!e*:-e %(netbsd_entry_point)}}} \
91117395Skan     %{!static: \
92117395Skan       %{rdynamic:-export-dynamic} \
93117395Skan       %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
9490075Sobrien     %{static:-static}}"
95