netbsd-elf.h revision 117395
1/* Common configuration file for NetBSD ELF targets.
2   Copyright (C) 2002 Free Software Foundation, Inc.
3   Contributed by Wasabi Systems, Inc.
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING.  If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA.  */
21
22/* TARGET_OS_CPP_BUILTINS() common to all NetBSD ELF targets.  */
23#define NETBSD_OS_CPP_BUILTINS_ELF()		\
24  do						\
25    {						\
26      NETBSD_OS_CPP_BUILTINS_COMMON();		\
27      builtin_define ("__ELF__");		\
28    }						\
29  while (0)
30
31/* This defines which switch letters take arguments.  On NetBSD, most
32   of the normal cases (defined by gcc.c) apply, and we also have -h*
33   and -z* options (for the linker) (coming from SVR4).  */
34
35#undef SWITCH_TAKES_ARG
36#define SWITCH_TAKES_ARG(CHAR)			\
37  (DEFAULT_SWITCH_TAKES_ARG (CHAR)		\
38   || (CHAR) == 'h'				\
39   || (CHAR) == 'z'				\
40   || (CHAR) == 'R')
41
42
43/* Provide a STARTFILE_SPEC appropriate for NetBSD ELF.  Here we
44   provide support for the special GCC option -static.  On ELF
45   targets, we also add the crtbegin.o file, which provides part
46   of the support for getting C++ file-scope static objects
47   constructed before entering "main".  */
48
49#define NETBSD_STARTFILE_SPEC	\
50  "%{!shared:			\
51     %{pg:gcrt0%O%s}		\
52     %{!pg:			\
53       %{p:gcrt0%O%s}		\
54       %{!p:crt0%O%s}}}		\
55   %:if-exists(crti%O%s)	\
56   %{static:%:if-exists-else(crtbeginT%O%s crtbegin%O%s)} \
57   %{!static: \
58     %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}"
59
60#undef STARTFILE_SPEC
61#define STARTFILE_SPEC NETBSD_STARTFILE_SPEC
62
63
64/* Provide an ENDFILE_SPEC appropriate for NetBSD ELF.  Here we
65   add crtend.o, which provides part of the support for getting
66   C++ file-scope static objects deconstructed after exiting "main".  */
67
68#define NETBSD_ENDFILE_SPEC	\
69  "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \
70   %:if-exists(crtn%O%s)"
71
72#undef ENDFILE_SPEC
73#define ENDFILE_SPEC NETBSD_ENDFILE_SPEC
74
75/* Provide a LINK_SPEC appropriate for NetBSD ELF.  Here we provide
76   support for the special GCC options -assert, -R, -rpath, -shared,
77   -nostdlib, -static, -rdynamic, and -dynamic-linker.
78
79   Target-specific code can use this in conjunction with any other
80   target-specific LINK_SPEC options.
81
82   Target-specific code must provide the %(netbsd_entry_point) spec.  */
83
84#define NETBSD_LINK_SPEC_ELF \
85  "%{assert*} %{R*} %{rpath*} \
86   %{shared:-shared} \
87   %{!shared: \
88     -dc -dp \
89     %{!nostdlib: \
90       %{!r*: \
91	 %{!e*:-e %(netbsd_entry_point)}}} \
92     %{!static: \
93       %{rdynamic:-export-dynamic} \
94       %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}} \
95     %{static:-static}}"
96