netbsd-elf.h revision 117395
190075Sobrien/* Common configuration file for NetBSD ELF targets.
290075Sobrien   Copyright (C) 2002 Free Software Foundation, Inc.
390075Sobrien   Contributed by Wasabi Systems, Inc.
490075Sobrien
590075SobrienThis file is part of GNU CC.
690075Sobrien
790075SobrienGNU CC 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
1290075SobrienGNU CC 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
1890075Sobrienalong with GNU CC; see the file COPYING.  If not, write to
1990075Sobrienthe Free Software Foundation, 59 Temple Place - Suite 330,
2090075SobrienBoston, MA 02111-1307, 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      builtin_define ("__ELF__");		\
28117395Skan    }						\
29117395Skan  while (0)
3090075Sobrien
3190075Sobrien/* This defines which switch letters take arguments.  On NetBSD, most
3290075Sobrien   of the normal cases (defined by gcc.c) apply, and we also have -h*
3390075Sobrien   and -z* options (for the linker) (coming from SVR4).  */
3490075Sobrien
3590075Sobrien#undef SWITCH_TAKES_ARG
3690075Sobrien#define SWITCH_TAKES_ARG(CHAR)			\
3790075Sobrien  (DEFAULT_SWITCH_TAKES_ARG (CHAR)		\
3890075Sobrien   || (CHAR) == 'h'				\
3990075Sobrien   || (CHAR) == 'z'				\
4090075Sobrien   || (CHAR) == 'R')
4190075Sobrien
4290075Sobrien
4390075Sobrien/* Provide a STARTFILE_SPEC appropriate for NetBSD ELF.  Here we
4490075Sobrien   provide support for the special GCC option -static.  On ELF
4590075Sobrien   targets, we also add the crtbegin.o file, which provides part
4690075Sobrien   of the support for getting C++ file-scope static objects
4790075Sobrien   constructed before entering "main".  */
4890075Sobrien
49117395Skan#define NETBSD_STARTFILE_SPEC	\
5090075Sobrien  "%{!shared:			\
5190075Sobrien     %{pg:gcrt0%O%s}		\
5290075Sobrien     %{!pg:			\
5390075Sobrien       %{p:gcrt0%O%s}		\
5490075Sobrien       %{!p:crt0%O%s}}}		\
55117395Skan   %:if-exists(crti%O%s)	\
56117395Skan   %{static:%:if-exists-else(crtbeginT%O%s crtbegin%O%s)} \
57117395Skan   %{!static: \
58117395Skan     %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}"
5990075Sobrien
60117395Skan#undef STARTFILE_SPEC
61117395Skan#define STARTFILE_SPEC NETBSD_STARTFILE_SPEC
6290075Sobrien
63117395Skan
6490075Sobrien/* Provide an ENDFILE_SPEC appropriate for NetBSD ELF.  Here we
6590075Sobrien   add crtend.o, which provides part of the support for getting
6690075Sobrien   C++ file-scope static objects deconstructed after exiting "main".  */
6790075Sobrien
68117395Skan#define NETBSD_ENDFILE_SPEC	\
69117395Skan  "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \
70117395Skan   %:if-exists(crtn%O%s)"
71117395Skan
7290075Sobrien#undef ENDFILE_SPEC
73117395Skan#define ENDFILE_SPEC NETBSD_ENDFILE_SPEC
7490075Sobrien
7590075Sobrien/* Provide a LINK_SPEC appropriate for NetBSD ELF.  Here we provide
7690075Sobrien   support for the special GCC options -assert, -R, -rpath, -shared,
77117395Skan   -nostdlib, -static, -rdynamic, and -dynamic-linker.
7890075Sobrien
79117395Skan   Target-specific code can use this in conjunction with any other
80117395Skan   target-specific LINK_SPEC options.
81117395Skan
82117395Skan   Target-specific code must provide the %(netbsd_entry_point) spec.  */
83117395Skan
84117395Skan#define NETBSD_LINK_SPEC_ELF \
85117395Skan  "%{assert*} %{R*} %{rpath*} \
86117395Skan   %{shared:-shared} \
87117395Skan   %{!shared: \
88117395Skan     -dc -dp \
89117395Skan     %{!nostdlib: \
90117395Skan       %{!r*: \
91117395Skan	 %{!e*:-e %(netbsd_entry_point)}}} \
92117395Skan     %{!static: \
93117395Skan       %{rdynamic:-export-dynamic} \
94117395Skan       %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
9590075Sobrien     %{static:-static}}"
96