1 /* Common configuration file for NetBSD ELF targets.
2    Copyright (C) 2002-2018 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 /* Provide a STARTFILE_SPEC appropriate for NetBSD ELF.  Here we
30    provide support for the special GCC option -static.  On ELF
31    targets, we also add the crtbegin.o file, which provides part
32    of the support for getting C++ file-scope static objects
33    constructed before entering "main".  */
34 
35 #define NETBSD_STARTFILE_SPEC	\
36   "%{!shared:			\
37      %{pg:gcrt0%O%s}		\
38      %{!pg:			\
39        %{p:gcrt0%O%s}		\
40        %{!p:crt0%O%s}}}		\
41    %:if-exists(crti%O%s)	\
42    %{static:%:if-exists-else(crtbeginT%O%s crtbegin%O%s)} \
43    %{!static: \
44      %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}"
45 
46 #undef STARTFILE_SPEC
47 #define STARTFILE_SPEC NETBSD_STARTFILE_SPEC
48 
49 
50 /* Provide an ENDFILE_SPEC appropriate for NetBSD ELF.  Here we
51    add crtend.o, which provides part of the support for getting
52    C++ file-scope static objects deconstructed after exiting "main".  */
53 
54 #define NETBSD_ENDFILE_SPEC	\
55   "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \
56    %:if-exists(crtn%O%s)"
57 
58 #undef ENDFILE_SPEC
59 #define ENDFILE_SPEC NETBSD_ENDFILE_SPEC
60 
61 /* Provide a LINK_SPEC appropriate for NetBSD ELF.  Here we provide
62    support for the special GCC options -assert, -R, -rpath, -shared,
63    -nostdlib, -static, -rdynamic, and -dynamic-linker.
64 
65    Target-specific code can use this in conjunction with any other
66    target-specific LINK_SPEC options.
67 
68    Target-specific code must provide the %(netbsd_entry_point) spec.  */
69 
70 #define NETBSD_LINK_SPEC_ELF \
71   "%{assert*} %{R*} %{rpath*} \
72    %{shared:-shared} \
73    %{symbolic:-Bsymbolic} \
74    %{!shared: \
75      -dc -dp \
76      %{!nostdlib: \
77        %{!r: \
78 	 %{!e*:-e %(netbsd_entry_point)}}} \
79      %{!static: \
80        %{rdynamic:-export-dynamic} \
81        -dynamic-linker /usr/libexec/ld.elf_so} \
82      %{static:-static}}"
83 
84 /* Use --as-needed -lgcc_s for eh support.  */
85 #ifdef HAVE_LD_AS_NEEDED
86 #define USE_LD_AS_NEEDED 1
87 #endif
88