1 /* Definitions of target machine for GNU compiler,
2    for PowerPC machines running Linux.
3    Copyright (C) 1996-2014 Free Software Foundation, Inc.
4    Contributed by Michael Meissner (meissner@cygnus.com).
5 
6    This file is part of GCC.
7 
8    GCC is free software; you can redistribute it and/or modify it
9    under the terms of the GNU General Public License as published
10    by the Free Software Foundation; either version 3, or (at your
11    option) any later version.
12 
13    GCC is distributed in the hope that it will be useful, but WITHOUT
14    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16    License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with GCC; see the file COPYING3.  If not see
20    <http://www.gnu.org/licenses/>.  */
21 
22 /* Linux doesn't support saving and restoring 64-bit regs in a 32-bit
23    process.  */
24 #define OS_MISSING_POWERPC64 1
25 
26 /* We use glibc _mcount for profiling.  */
27 #define NO_PROFILE_COUNTERS 1
28 
29 #ifdef SINGLE_LIBC
30 #define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
31 #define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
32 #define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
33 #else
34 #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
35 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
36 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
37 #endif
38 
39 /* Determine what functions are present at the runtime;
40    this includes full c99 runtime and sincos.  */
41 #undef TARGET_LIBC_HAS_FUNCTION
42 #define TARGET_LIBC_HAS_FUNCTION linux_libc_has_function
43 
44 #undef  TARGET_OS_CPP_BUILTINS
45 #define TARGET_OS_CPP_BUILTINS()		\
46   do						\
47     {						\
48       builtin_define_std ("PPC");		\
49       builtin_define_std ("powerpc");		\
50       builtin_assert ("cpu=powerpc");		\
51       builtin_assert ("machine=powerpc");	\
52       TARGET_OS_SYSV_CPP_BUILTINS ();		\
53     }						\
54   while (0)
55 
56 #undef	CPP_OS_DEFAULT_SPEC
57 #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
58 
59 /* The GNU C++ standard library currently requires _GNU_SOURCE being
60    defined on glibc-based systems. This temporary hack accomplishes this,
61    it should go away as soon as libstdc++-v3 has a real fix.  */
62 #undef  CPLUSPLUS_CPP_SPEC
63 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
64 
65 #undef  LINK_SHLIB_SPEC
66 #define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}"
67 
68 #undef	LIB_DEFAULT_SPEC
69 #define LIB_DEFAULT_SPEC "%(lib_linux)"
70 
71 #undef	STARTFILE_DEFAULT_SPEC
72 #define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"
73 
74 #undef	ENDFILE_DEFAULT_SPEC
75 #define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"
76 
77 #undef	LINK_START_DEFAULT_SPEC
78 #define LINK_START_DEFAULT_SPEC "%(link_start_linux)"
79 
80 #undef	LINK_OS_DEFAULT_SPEC
81 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
82 
83 #undef  DEFAULT_ASM_ENDIAN
84 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
85 #define DEFAULT_ASM_ENDIAN " -mlittle"
86 #define LINK_OS_LINUX_EMUL ENDIAN_SELECT(" -m elf32ppclinux",	\
87 					 " -m elf32lppclinux",	\
88 					 " -m elf32lppclinux")
89 #else
90 #define DEFAULT_ASM_ENDIAN " -mbig"
91 #define LINK_OS_LINUX_EMUL ENDIAN_SELECT(" -m elf32ppclinux",	\
92 					 " -m elf32lppclinux",	\
93 					 " -m elf32ppclinux")
94 #endif
95 
96 #undef LINK_OS_LINUX_SPEC
97 #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \
98   %{rdynamic:-export-dynamic} \
99   -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
100 
101 #define LINK_GCC_C_SEQUENCE_SPEC \
102   "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
103 
104 /* Use --as-needed -lgcc_s for eh support.  */
105 #ifdef HAVE_LD_AS_NEEDED
106 #define USE_LD_AS_NEEDED 1
107 #endif
108 
109 /* Override rs6000.h definition.  */
110 #undef  ASM_APP_ON
111 #define ASM_APP_ON "#APP\n"
112 
113 /* Override rs6000.h definition.  */
114 #undef  ASM_APP_OFF
115 #define ASM_APP_OFF "#NO_APP\n"
116 
117 /* For backward compatibility, we must continue to use the AIX
118    structure return convention.  */
119 #undef  DRAFT_V4_STRUCT_RET
120 #define DRAFT_V4_STRUCT_RET 1
121 
122 /* We are 32-bit all the time, so optimize a little.  */
123 #undef TARGET_64BIT
124 #define TARGET_64BIT 0
125 
126 /* We don't need to generate entries in .fixup, except when
127    -mrelocatable or -mrelocatable-lib is given.  */
128 #undef RELOCATABLE_NEEDS_FIXUP
129 #define RELOCATABLE_NEEDS_FIXUP \
130   (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE)
131 
132 #define TARGET_POSIX_IO
133 
134 #ifdef TARGET_LIBC_PROVIDES_SSP
135 /* ppc32 glibc provides __stack_chk_guard in -0x7008(2).  */
136 #define TARGET_THREAD_SSP_OFFSET	-0x7008
137 #endif
138 
139 #define POWERPC_LINUX
140 
141 /* ppc linux has 128-bit long double support in glibc 2.4 and later.  */
142 #ifdef TARGET_DEFAULT_LONG_DOUBLE_128
143 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128
144 #endif
145 
146 /* Static stack checking is supported by means of probes.  */
147 #define STACK_CHECK_STATIC_BUILTIN 1
148 
149 /* Software floating point support for exceptions and rounding modes
150    depends on the C library in use.  */
151 #undef TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P
152 #define TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P \
153   rs6000_linux_float_exceptions_rounding_supported_p
154