xref: /openbsd/gnu/gcc/gcc/config/linux.h (revision 404b540a)
1*404b540aSrobert /* Definitions for Linux-based GNU systems with ELF format
2*404b540aSrobert    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006
3*404b540aSrobert    Free Software Foundation, Inc.
4*404b540aSrobert    Contributed by Eric Youngdale.
5*404b540aSrobert    Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
6*404b540aSrobert 
7*404b540aSrobert This file is part of GCC.
8*404b540aSrobert 
9*404b540aSrobert GCC is free software; you can redistribute it and/or modify
10*404b540aSrobert it under the terms of the GNU General Public License as published by
11*404b540aSrobert the Free Software Foundation; either version 2, or (at your option)
12*404b540aSrobert any later version.
13*404b540aSrobert 
14*404b540aSrobert GCC is distributed in the hope that it will be useful,
15*404b540aSrobert but WITHOUT ANY WARRANTY; without even the implied warranty of
16*404b540aSrobert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17*404b540aSrobert GNU General Public License for more details.
18*404b540aSrobert 
19*404b540aSrobert You should have received a copy of the GNU General Public License
20*404b540aSrobert along with GCC; see the file COPYING.  If not, write to
21*404b540aSrobert the Free Software Foundation, 51 Franklin Street, Fifth Floor,
22*404b540aSrobert Boston, MA 02110-1301, USA.  */
23*404b540aSrobert 
24*404b540aSrobert /* Don't assume anything about the header files.  */
25*404b540aSrobert #define NO_IMPLICIT_EXTERN_C
26*404b540aSrobert 
27*404b540aSrobert #undef ASM_APP_ON
28*404b540aSrobert #define ASM_APP_ON "#APP\n"
29*404b540aSrobert 
30*404b540aSrobert #undef ASM_APP_OFF
31*404b540aSrobert #define ASM_APP_OFF "#NO_APP\n"
32*404b540aSrobert 
33*404b540aSrobert #undef MD_EXEC_PREFIX
34*404b540aSrobert #undef MD_STARTFILE_PREFIX
35*404b540aSrobert 
36*404b540aSrobert /* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
37*404b540aSrobert    the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
38*404b540aSrobert    provides part of the support for getting C++ file-scope static
39*404b540aSrobert    object constructed before entering `main'.  */
40*404b540aSrobert 
41*404b540aSrobert #undef	STARTFILE_SPEC
42*404b540aSrobert #if defined HAVE_LD_PIE
43*404b540aSrobert #define STARTFILE_SPEC \
44*404b540aSrobert   "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
45*404b540aSrobert    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
46*404b540aSrobert #else
47*404b540aSrobert #define STARTFILE_SPEC \
48*404b540aSrobert   "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
49*404b540aSrobert    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
50*404b540aSrobert #endif
51*404b540aSrobert 
52*404b540aSrobert /* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
53*404b540aSrobert    the GNU/Linux magical crtend.o file (see crtstuff.c) which
54*404b540aSrobert    provides part of the support for getting C++ file-scope static
55*404b540aSrobert    object constructed before entering `main', followed by a normal
56*404b540aSrobert    GNU/Linux "finalizer" file, `crtn.o'.  */
57*404b540aSrobert 
58*404b540aSrobert #undef	ENDFILE_SPEC
59*404b540aSrobert #define ENDFILE_SPEC \
60*404b540aSrobert   "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
61*404b540aSrobert 
62*404b540aSrobert /* This is for -profile to use -lc_p instead of -lc.  */
63*404b540aSrobert #ifndef CC1_SPEC
64*404b540aSrobert #define CC1_SPEC "%{profile:-p}"
65*404b540aSrobert #endif
66*404b540aSrobert 
67*404b540aSrobert /* The GNU C++ standard library requires that these macros be defined.  */
68*404b540aSrobert #undef CPLUSPLUS_CPP_SPEC
69*404b540aSrobert #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
70*404b540aSrobert 
71*404b540aSrobert #undef	LIB_SPEC
72*404b540aSrobert #define LIB_SPEC \
73*404b540aSrobert   "%{pthread:-lpthread} \
74*404b540aSrobert    %{shared:-lc} \
75*404b540aSrobert    %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
76*404b540aSrobert 
77*404b540aSrobert #define LINUX_TARGET_OS_CPP_BUILTINS()				\
78*404b540aSrobert     do {							\
79*404b540aSrobert 	builtin_define ("__gnu_linux__");			\
80*404b540aSrobert 	builtin_define_std ("linux");				\
81*404b540aSrobert 	builtin_define_std ("unix");				\
82*404b540aSrobert 	builtin_assert ("system=linux");			\
83*404b540aSrobert 	builtin_assert ("system=unix");				\
84*404b540aSrobert 	builtin_assert ("system=posix");			\
85*404b540aSrobert     } while (0)
86*404b540aSrobert 
87*404b540aSrobert #if defined(HAVE_LD_EH_FRAME_HDR)
88*404b540aSrobert #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
89*404b540aSrobert #endif
90*404b540aSrobert 
91*404b540aSrobert /* Define this so we can compile MS code for use with WINE.  */
92*404b540aSrobert #define HANDLE_PRAGMA_PACK_PUSH_POP
93*404b540aSrobert 
94*404b540aSrobert #define LINK_GCC_C_SEQUENCE_SPEC \
95*404b540aSrobert   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
96*404b540aSrobert 
97*404b540aSrobert /* Use --as-needed -lgcc_s for eh support.  */
98*404b540aSrobert #ifdef HAVE_LD_AS_NEEDED
99*404b540aSrobert #define USE_LD_AS_NEEDED 1
100*404b540aSrobert #endif
101*404b540aSrobert 
102*404b540aSrobert /* Determine which dynamic linker to use depending on whether GLIBC or
103*404b540aSrobert    uClibc is the default C library and whether -muclibc or -mglibc has
104*404b540aSrobert    been passed to change the default.  */
105*404b540aSrobert #if UCLIBC_DEFAULT
106*404b540aSrobert #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
107*404b540aSrobert #else
108*404b540aSrobert #define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
109*404b540aSrobert #endif
110*404b540aSrobert 
111*404b540aSrobert /* For most targets the following definitions suffice;
112*404b540aSrobert    GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
113*404b540aSrobert    GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
114*404b540aSrobert    supporting both 32-bit and 64-bit compilation.  */
115*404b540aSrobert #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
116*404b540aSrobert #define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
117*404b540aSrobert #define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
118*404b540aSrobert #define LINUX_DYNAMIC_LINKER \
119*404b540aSrobert   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
120*404b540aSrobert #define LINUX_DYNAMIC_LINKER32 \
121*404b540aSrobert   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
122*404b540aSrobert #define LINUX_DYNAMIC_LINKER64 \
123*404b540aSrobert   CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
124*404b540aSrobert 
125*404b540aSrobert /* Determine whether the entire c99 runtime
126*404b540aSrobert    is present in the runtime library.  */
127*404b540aSrobert #define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
128*404b540aSrobert 
129*404b540aSrobert #define TARGET_POSIX_IO
130