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