1/* Definitions for systems using, at least optionally, a GNU
2 (glibc-based) userspace or other userspace with libc derived from
3 glibc (e.g. uClibc) or for which similar specs are appropriate.
4 Copyright (C) 1995-2017 Free Software Foundation, Inc.
5 Contributed by Eric Youngdale.
6 Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
7
8This file is part of GCC.
9
10GCC is free software; you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by
12the Free Software Foundation; either version 3, or (at your option)
13any later version.
14
15GCC is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20Under Section 7 of GPL version 3, you are granted additional
21permissions described in the GCC Runtime Library Exception, version
223.1, as published by the Free Software Foundation.
23
24You should have received a copy of the GNU General Public License and
25a copy of the GCC Runtime Library Exception along with this program;
26see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
27<http://www.gnu.org/licenses/>. */
28
29/* Don't assume anything about the header files. */
30#define NO_IMPLICIT_EXTERN_C
31
32#undef ASM_APP_ON
33#define ASM_APP_ON "#APP\n"
34
35#undef ASM_APP_OFF
36#define ASM_APP_OFF "#NO_APP\n"
37
38#if ENABLE_OFFLOADING == 1
39#define CRTOFFLOADBEGIN "%{fopenacc|fopenmp:crtoffloadbegin%O%s}"
40#define CRTOFFLOADEND "%{fopenacc|fopenmp:crtoffloadend%O%s}"
41#else
42#define CRTOFFLOADBEGIN ""
43#define CRTOFFLOADEND ""
44#endif
45
46/* Provide a STARTFILE_SPEC appropriate for GNU userspace. Here we add
47 the GNU userspace magical crtbegin.o file (see crtstuff.c) which
48 provides part of the support for getting C++ file-scope static
49 object constructed before entering `main'. */
50
51#if defined HAVE_LD_PIE
52#define GNU_USER_TARGET_STARTFILE_SPEC \
53 "%{shared:; \
54 pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
55 static:crt1.o%s; \
56 static-pie:rcrt1.o%s; \
57 " PIE_SPEC ":Scrt1.o%s; \
58 :crt1.o%s} \
59 crti.o%s \
60 %{static:crtbeginT.o%s; \
61 shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
62 :crtbegin.o%s} \
63 %{fvtable-verify=none:%s; \
64 fvtable-verify=preinit:vtv_start_preinit.o%s; \
65 fvtable-verify=std:vtv_start.o%s} \
66 " CRTOFFLOADBEGIN
67#else
68#define GNU_USER_TARGET_STARTFILE_SPEC \
69 "%{shared:; \
70 pg|p|profile:gcrt1.o%s; \
71 :crt1.o%s} \
72 crti.o%s \
73 %{static:crtbeginT.o%s; \
74 shared|pie|static-pie:crtbeginS.o%s; \
75 :crtbegin.o%s} \
76 %{fvtable-verify=none:%s; \
77 fvtable-verify=preinit:vtv_start_preinit.o%s; \
78 fvtable-verify=std:vtv_start.o%s} \
79 " CRTOFFLOADBEGIN
80#endif
81#undef STARTFILE_SPEC
82#define STARTFILE_SPEC GNU_USER_TARGET_STARTFILE_SPEC
83
84/* Provide a ENDFILE_SPEC appropriate for GNU userspace. Here we tack on
85 the GNU userspace magical crtend.o file (see crtstuff.c) which
86 provides part of the support for getting C++ file-scope static
87 object constructed before entering `main', followed by a normal
88 GNU userspace "finalizer" file, `crtn.o'. */
89
90#if defined HAVE_LD_PIE
91#define GNU_USER_TARGET_ENDFILE_SPEC \
92 "%{fvtable-verify=none:%s; \
93 fvtable-verify=preinit:vtv_end_preinit.o%s; \
94 fvtable-verify=std:vtv_end.o%s} \
95 %{static:crtend.o%s; \
96 shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
97 :crtend.o%s} \
98 crtn.o%s \
99 " CRTOFFLOADEND
100#else
101#define GNU_USER_TARGET_ENDFILE_SPEC \
102 "%{fvtable-verify=none:%s; \
103 fvtable-verify=preinit:vtv_end_preinit.o%s; \
104 fvtable-verify=std:vtv_end.o%s} \
105 %{static:crtend.o%s; \
106 shared|pie|static-pie:crtendS.o%s; \
107 :crtend.o%s} \
108 crtn.o%s \
109 " CRTOFFLOADEND
110#endif
111#undef ENDFILE_SPEC
112#define ENDFILE_SPEC GNU_USER_TARGET_ENDFILE_SPEC
113
114/* This is for -profile to use -lc_p instead of -lc. */
115#define GNU_USER_TARGET_CC1_SPEC "%{profile:-p}"
116#ifndef CC1_SPEC
117#define CC1_SPEC GNU_USER_TARGET_CC1_SPEC
118#endif
119
120/* The GNU C++ standard library requires that these macros be defined. */
121#undef CPLUSPLUS_CPP_SPEC
122#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
123
124#define GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC \
125 "%{shared:-lc} \
126 %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
127
128#define GNU_USER_TARGET_LIB_SPEC \
129 "%{pthread:-lpthread} " \
130 GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC
131
132#undef LIB_SPEC
133#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
134
135#if defined(HAVE_LD_EH_FRAME_HDR)
136#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
137#endif
138
139#undef LINK_GCC_C_SEQUENCE_SPEC
140#define LINK_GCC_C_SEQUENCE_SPEC \
141 "%{static|static-pie:--start-group} %G %L \
142 %{static|static-pie:--end-group}%{!static:%{!static-pie:%G}}"
143
144/* Use --as-needed -lgcc_s for eh support. */
145#ifdef HAVE_LD_AS_NEEDED
146#define USE_LD_AS_NEEDED 1
147#endif
148
149#define TARGET_POSIX_IO
150
151#undef TARGET_LIBC_HAS_FUNCTION
152#define TARGET_LIBC_HAS_FUNCTION gnu_libc_has_function
153
154/* Link -lasan early on the command line. For -static-libasan, don't link
155 it for -shared link, the executable should be compiled with -static-libasan
156 in that case, and for executable link with --{,no-}whole-archive around
157 it to force everything into the executable. And similarly for -ltsan
158 and -llsan. */
159#if defined(HAVE_LD_STATIC_DYNAMIC)
160#undef LIBASAN_EARLY_SPEC
161#define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
162 "%{static-libasan:%{!shared:" \
163 LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
164 LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
165#undef LIBTSAN_EARLY_SPEC
166#define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
167 "%{static-libtsan:%{!shared:" \
168 LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
169 LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
170#undef LIBLSAN_EARLY_SPEC
171#define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
172 "%{static-liblsan:%{!shared:" \
173 LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
174 LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
175#endif
176