150397Sobrien/* Definitions for Linux-based GNU systems with ELF format
2169689Skan   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006
3132718Skan   Free Software Foundation, Inc.
418334Speter   Contributed by Eric Youngdale.
550397Sobrien   Modified for stabs-in-ELF by H.J. Lu (hjl@lucon.org).
618334Speter
7132718SkanThis file is part of GCC.
818334Speter
9132718SkanGCC is free software; you can redistribute it and/or modify
1018334Speterit under the terms of the GNU General Public License as published by
1118334Speterthe Free Software Foundation; either version 2, or (at your option)
1218334Speterany later version.
1318334Speter
14132718SkanGCC is distributed in the hope that it will be useful,
1518334Speterbut WITHOUT ANY WARRANTY; without even the implied warranty of
1618334SpeterMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1718334SpeterGNU General Public License for more details.
1818334Speter
1918334SpeterYou should have received a copy of the GNU General Public License
20132718Skanalong with GCC; see the file COPYING.  If not, write to
21169689Skanthe Free Software Foundation, 51 Franklin Street, Fifth Floor,
22169689SkanBoston, MA 02110-1301, USA.  */
2318334Speter
24117395Skan/* Don't assume anything about the header files.  */
2518334Speter#define NO_IMPLICIT_EXTERN_C
2618334Speter
2718334Speter#undef ASM_APP_ON
2818334Speter#define ASM_APP_ON "#APP\n"
2918334Speter
3018334Speter#undef ASM_APP_OFF
3118334Speter#define ASM_APP_OFF "#NO_APP\n"
3218334Speter
3318334Speter#undef MD_EXEC_PREFIX
3418334Speter#undef MD_STARTFILE_PREFIX
3518334Speter
3650397Sobrien/* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
3750397Sobrien   the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
3818334Speter   provides part of the support for getting C++ file-scope static
39117395Skan   object constructed before entering `main'.  */
4018334Speter
4118334Speter#undef	STARTFILE_SPEC
42169689Skan#if defined HAVE_LD_PIE
4318334Speter#define STARTFILE_SPEC \
44132718Skan  "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
45132718Skan   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
4690075Sobrien#else
4790075Sobrien#define STARTFILE_SPEC \
48132718Skan  "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
49132718Skan   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
5090075Sobrien#endif
5118334Speter
5250397Sobrien/* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
5350397Sobrien   the GNU/Linux magical crtend.o file (see crtstuff.c) which
5418334Speter   provides part of the support for getting C++ file-scope static
5518334Speter   object constructed before entering `main', followed by a normal
5650397Sobrien   GNU/Linux "finalizer" file, `crtn.o'.  */
5718334Speter
5818334Speter#undef	ENDFILE_SPEC
5918334Speter#define ENDFILE_SPEC \
60132718Skan  "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
6150397Sobrien
62117395Skan/* This is for -profile to use -lc_p instead of -lc.  */
6350397Sobrien#ifndef CC1_SPEC
6450397Sobrien#define CC1_SPEC "%{profile:-p}"
6550397Sobrien#endif
6650397Sobrien
6790075Sobrien/* The GNU C++ standard library requires that these macros be defined.  */
6890075Sobrien#undef CPLUSPLUS_CPP_SPEC
6990075Sobrien#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
7050397Sobrien
7150397Sobrien#undef	LIB_SPEC
7250397Sobrien#define LIB_SPEC \
73117395Skan  "%{pthread:-lpthread} \
74117395Skan   %{shared:-lc} \
75117395Skan   %{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}"
7690075Sobrien
77132718Skan#define LINUX_TARGET_OS_CPP_BUILTINS()				\
78132718Skan    do {							\
79132718Skan	builtin_define ("__gnu_linux__");			\
80132718Skan	builtin_define_std ("linux");				\
81132718Skan	builtin_define_std ("unix");				\
82132718Skan	builtin_assert ("system=linux");			\
83132718Skan	builtin_assert ("system=unix");				\
84132718Skan	builtin_assert ("system=posix");			\
85132718Skan    } while (0)
86132718Skan
87169689Skan#if defined(HAVE_LD_EH_FRAME_HDR)
8890075Sobrien#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
8990075Sobrien#endif
9090075Sobrien
91132718Skan/* Define this so we can compile MS code for use with WINE.  */
92132718Skan#define HANDLE_PRAGMA_PACK_PUSH_POP
93132718Skan
94122180Skan#define LINK_GCC_C_SEQUENCE_SPEC \
95122180Skan  "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
96122180Skan
97169689Skan/* Use --as-needed -lgcc_s for eh support.  */
98169689Skan#ifdef HAVE_LD_AS_NEEDED
99169689Skan#define USE_LD_AS_NEEDED 1
100132718Skan#endif
101117395Skan
102169689Skan/* Determine which dynamic linker to use depending on whether GLIBC or
103169689Skan   uClibc is the default C library and whether -muclibc or -mglibc has
104169689Skan   been passed to change the default.  */
105169689Skan#if UCLIBC_DEFAULT
106169689Skan#define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:%{muclibc:%e-mglibc and -muclibc used together}" G ";:" U "}"
107169689Skan#else
108169689Skan#define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:%{mglibc:%e-mglibc and -muclibc used together}" U ";:" G "}"
109169689Skan#endif
110169689Skan
111169689Skan/* For most targets the following definitions suffice;
112169689Skan   GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
113169689Skan   GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
114169689Skan   supporting both 32-bit and 64-bit compilation.  */
115169689Skan#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
116169689Skan#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
117169689Skan#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
118169689Skan#define LINUX_DYNAMIC_LINKER \
119169689Skan  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
120169689Skan#define LINUX_DYNAMIC_LINKER32 \
121169689Skan  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32)
122169689Skan#define LINUX_DYNAMIC_LINKER64 \
123169689Skan  CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64)
124169689Skan
125169689Skan/* Determine whether the entire c99 runtime
126169689Skan   is present in the runtime library.  */
127169689Skan#define TARGET_C99_FUNCTIONS (OPTION_GLIBC)
128169689Skan
129169689Skan#define TARGET_POSIX_IO
130