* alias.c, c-common.h, c-incpath.c, c-incpath.h, expr.c,
[official-gcc.git] / gcc / config / sh / linux.h
blob56c85d632b083bfde5f57b540daf3c56eb21a495
1 /* Definitions for SH running Linux-based GNU systems using ELF
2 Copyright (C) 1999, 2000, 2002, 2003, 2004, 2005
3 Free Software Foundation, Inc.
4 Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 /* Run-time Target Specification. */
24 #undef TARGET_VERSION
25 #define TARGET_VERSION fputs (" (SH GNU/Linux with ELF)", stderr);
27 /* We're not SYSVR4, not having /usr/ccs */
28 #undef MD_EXEC_PREFIX
29 #undef MD_STARTFILE_PREFIX
31 /* This was defined in linux.h. Define it here also. */
32 #define HANDLE_PRAGMA_PACK_PUSH_POP
34 /* Don't assume anything about the header files. */
35 #define NO_IMPLICIT_EXTERN_C
37 /* The GNU C++ standard library requires that these macros be defined. */
38 #undef CPLUSPLUS_CPP_SPEC
39 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
41 /* Enable DWARF 2 exceptions. */
42 #undef DWARF2_UNWIND_INFO
43 #define DWARF2_UNWIND_INFO 1
45 #undef SUBTARGET_CPP_SPEC
46 #define SUBTARGET_CPP_SPEC "\
47 %{posix:-D_POSIX_SOURCE} \
48 %{pthread:-D_REENTRANT -D_PTHREADS} \
51 #define TARGET_OS_CPP_BUILTINS() \
52 do { \
53 builtin_define_std ("unix"); \
54 builtin_define ("__gnu_linux__"); \
55 builtin_define_std ("linux"); \
56 builtin_assert ("system=linux"); \
57 builtin_assert ("system=unix"); \
58 builtin_assert ("system=posix"); \
59 } while (0)
61 #undef TARGET_DEFAULT
62 #define TARGET_DEFAULT \
63 (TARGET_CPU_DEFAULT | USERMODE_BIT | TARGET_ENDIAN_DEFAULT)
65 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
67 #undef SUBTARGET_LINK_EMUL_SUFFIX
68 #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
69 #undef SUBTARGET_LINK_SPEC
70 #define SUBTARGET_LINK_SPEC \
71 "%{shared:-shared} \
72 %{!static: \
73 %{rdynamic:-export-dynamic} \
74 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
75 %{static:-static}"
77 #undef LIB_SPEC
78 #define LIB_SPEC \
79 "%{pthread:-lpthread} \
80 %{shared: -lc} \
81 %{!static:-rpath-link %R/lib:%R/usr/lib} \
82 %{!shared: \
83 %{mieee-fp:-lieee} \
84 %{profile:-lc_p} %{!profile: -lc}}"
86 #if defined(HAVE_LD_EH_FRAME_HDR)
87 #undef LINK_EH_SPEC
88 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
89 #endif
91 #undef STARTFILE_SPEC
92 #if defined HAVE_LD_PIE
93 #define STARTFILE_SPEC \
94 "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
95 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
96 #else
97 #define STARTFILE_SPEC \
98 "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
99 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
100 #endif
102 #undef ENDFILE_SPEC
103 #define ENDFILE_SPEC \
104 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
106 #define LINK_GCC_C_SEQUENCE_SPEC \
107 "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"
109 /* Use --as-needed -lgcc_s for eh support. */
110 #ifdef HAVE_LD_AS_NEEDED
111 #define USE_LD_AS_NEEDED 1
112 #endif
114 /* Determine whether the the entire c99 runtime
115 is present in the runtime library. */
116 #define TARGET_C99_FUNCTIONS 1
118 /* Output assembler code to STREAM to call the profiler. */
120 #undef FUNCTION_PROFILER
121 #define FUNCTION_PROFILER(STREAM,LABELNO) \
122 do { \
123 if (flag_pic) \
125 fprintf (STREAM, "\tmov.l\t3f,r1\n"); \
126 fprintf (STREAM, "\tmova\t3f,r0\n"); \
127 fprintf (STREAM, "\tadd\tr1,r0\n"); \
128 fprintf (STREAM, "\tmov.l\t1f,r1\n"); \
129 fprintf (STREAM, "\tmov.l\t@(r0,r1),r1\n"); \
131 else \
132 fprintf (STREAM, "\tmov.l\t1f,r1\n"); \
133 fprintf (STREAM, "\tsts.l\tpr,@-r15\n"); \
134 fprintf (STREAM, "\tmova\t2f,r0\n"); \
135 fprintf (STREAM, "\tjmp\t@r1\n"); \
136 fprintf (STREAM, "\tlds\tr0,pr\n"); \
137 fprintf (STREAM, "\t.align\t2\n"); \
138 if (flag_pic) \
140 fprintf (STREAM, "1:\t.long\tmcount@GOT\n"); \
141 fprintf (STREAM, "3:\t.long\t_GLOBAL_OFFSET_TABLE_\n"); \
143 else \
144 fprintf (STREAM, "1:\t.long\tmcount\n"); \
145 fprintf (STREAM, "2:\tlds.l\t@r15+,pr\n"); \
146 } while (0)
148 #define MD_UNWIND_SUPPORT "config/sh/linux-unwind.h"
150 /* For SH3 and SH4, we use a slot of the unwind frame which correspond
151 to a fake register number 16 as a placeholder for the return address
152 in MD_FALLBACK_FRAME_STATE_FOR and its content will be read with
153 _Unwind_GetGR which uses dwarf_reg_size_table to get the size of
154 the register. So the entry of dwarf_reg_size_table corresponding to
155 this slot must be set. To do this, we redefine DBX_REGISTER_NUMBER
156 so as to return itself for 16. */
157 #undef DBX_REGISTER_NUMBER
158 #define DBX_REGISTER_NUMBER(REGNO) \
159 ((! TARGET_SH5 && (REGNO) == 16) ? 16 : SH_DBX_REGISTER_NUMBER (REGNO))