]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/sh/linux.h
linux.h (SUBTARGET_LINK_SPEC): Don't set rpath.
[thirdparty/gcc.git] / gcc / config / sh / linux.h
1 /* Definitions for SH running Linux-based GNU systems using ELF
2 Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc.
3 Contributed by Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
4
5 This file is part of GNU CC.
6
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 /* Run-time Target Specification. */
23 #undef TARGET_VERSION
24 #define TARGET_VERSION fputs (" (SH GNU/Linux with ELF)", stderr);
25
26 /* We're not SYSVR4, not having /usr/ccs */
27 #undef MD_EXEC_PREFIX
28 #undef MD_STARTFILE_PREFIX
29
30 /* This was defined in linux.h. Define it here also. */
31 #define HANDLE_PRAGMA_PACK_PUSH_POP
32
33 /* Don't assume anything about the header files. */
34 #define NO_IMPLICIT_EXTERN_C
35
36 /* The GNU C++ standard library requires that these macros be defined. */
37 #undef CPLUSPLUS_CPP_SPEC
38 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
39
40 /* Enable DWARF 2 exceptions. */
41 #undef DWARF2_UNWIND_INFO
42 #define DWARF2_UNWIND_INFO 1
43
44 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
45 (flag_pic \
46 ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \
47 : DW_EH_PE_absptr)
48
49 #undef SUBTARGET_CPP_SPEC
50 #define SUBTARGET_CPP_SPEC "\
51 %{posix:-D_POSIX_SOURCE} \
52 %{pthread:-D_REENTRANT -D_PTHREADS} \
53 "
54
55 #define TARGET_OS_CPP_BUILTINS() \
56 do { \
57 builtin_define_std ("unix"); \
58 builtin_define ("__gnu_linux__"); \
59 builtin_define_std ("linux"); \
60 builtin_assert ("system=posix"); \
61 } while (0)
62
63 #undef TARGET_DEFAULT
64 #define TARGET_DEFAULT \
65 (TARGET_CPU_DEFAULT | USERMODE_BIT | TARGET_ENDIAN_DEFAULT)
66
67 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
68
69 #undef SUBTARGET_LINK_EMUL_SUFFIX
70 #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
71 #undef SUBTARGET_LINK_SPEC
72 #define SUBTARGET_LINK_SPEC \
73 "%{shared:-shared} \
74 %{!static: \
75 %{rdynamic:-export-dynamic} \
76 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
77 %{static:-static}"
78
79 #undef LIB_SPEC
80 #define LIB_SPEC \
81 "%{pthread:-lpthread} \
82 %{shared: -lc} \
83 %{!static:-rpath-link %R/lib:%R/usr/lib} \
84 %{!shared: \
85 %{mieee-fp:-lieee} \
86 %{profile:-lc_p} %{!profile: -lc}}"
87
88 #if defined(HAVE_LD_EH_FRAME_HDR)
89 #undef LINK_EH_SPEC
90 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
91 #endif
92
93 #undef STARTFILE_SPEC
94 #if defined HAVE_LD_PIE
95 #define STARTFILE_SPEC \
96 "%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
97 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
98 #else
99 #define STARTFILE_SPEC \
100 "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
101 crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
102 #endif
103
104 #undef ENDFILE_SPEC
105 #define ENDFILE_SPEC \
106 "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
107
108 /* Output assembler code to STREAM to call the profiler. */
109
110 #undef FUNCTION_PROFILER
111 #define FUNCTION_PROFILER(STREAM,LABELNO) \
112 do { \
113 if (flag_pic) \
114 { \
115 fprintf (STREAM, "\tmov.l\t3f,r1\n"); \
116 fprintf (STREAM, "\tmova\t3f,r0\n"); \
117 fprintf (STREAM, "\tadd\tr1,r0\n"); \
118 fprintf (STREAM, "\tmov.l\t1f,r1\n"); \
119 fprintf (STREAM, "\tmov.l\t@(r0,r1),r1\n"); \
120 } \
121 else \
122 fprintf (STREAM, "\tmov.l\t1f,r1\n"); \
123 fprintf (STREAM, "\tsts.l\tpr,@-r15\n"); \
124 fprintf (STREAM, "\tmova\t2f,r0\n"); \
125 fprintf (STREAM, "\tjmp\t@r1\n"); \
126 fprintf (STREAM, "\tlds\tr0,pr\n"); \
127 fprintf (STREAM, "\t.align\t2\n"); \
128 if (flag_pic) \
129 { \
130 fprintf (STREAM, "1:\t.long\tmcount@GOT\n"); \
131 fprintf (STREAM, "3:\t.long\t_GLOBAL_OFFSET_TABLE_\n"); \
132 } \
133 else \
134 fprintf (STREAM, "1:\t.long\tmcount\n"); \
135 fprintf (STREAM, "2:\tlds.l\t@r15+,pr\n"); \
136 } while (0)
137
138 /* Do code reading to identify a signal frame, and set the frame
139 state data appropriately. See unwind-dw2.c for the structs. */
140
141 #ifdef IN_LIBGCC2
142 #include <signal.h>
143 #include <sys/ucontext.h>
144 #include "insn-constants.h"
145
146 # if defined (__SH5__)
147 #define SH_DWARF_FRAME_GP0 0
148 #define SH_DWARF_FRAME_FP0 (__SH5__ == 32 ? 245 : 77)
149 #define SH_DWARF_FRAME_XD0 289
150 #define SH_DWARF_FRAME_BT0 68
151 #define SH_DWARF_FRAME_PR 241
152 #define SH_DWARF_FRAME_PR_MEDIA 18
153 #define SH_DWARF_FRAME_GBR 238
154 #define SH_DWARF_FRAME_MACH 239
155 #define SH_DWARF_FRAME_MACL 240
156 #define SH_DWARF_FRAME_PC 64
157 #define SH_DWARF_FRAME_SR 65
158 #define SH_DWARF_FRAME_FPUL 244
159 #define SH_DWARF_FRAME_FPSCR 243
160 #else
161 #define SH_DWARF_FRAME_GP0 0
162 #define SH_DWARF_FRAME_FP0 25
163 #define SH_DWARF_FRAME_XD0 87
164 #define SH_DWARF_FRAME_PR 17
165 #define SH_DWARF_FRAME_GBR 19
166 #define SH_DWARF_FRAME_MACH 20
167 #define SH_DWARF_FRAME_MACL 21
168 #define SH_DWARF_FRAME_PC 16
169 #define SH_DWARF_FRAME_SR 22
170 #define SH_DWARF_FRAME_FPUL 23
171 #define SH_DWARF_FRAME_FPSCR 24
172 #endif /* defined (__SH5__) */
173
174 #if defined (__SH5__)
175 /* MD_FALLBACK_FRAME_STATE_FOR is not yet defined for SHMEDIA. */
176 #else /* defined (__SH5__) */
177
178 #if defined (__SH3E__) || defined (__SH4__)
179 #define SH_FALLBACK_FRAME_FLOAT_STATE(SC, FS, CFA) \
180 do { \
181 int i_, r_; \
182 \
183 r_ = SH_DWARF_FRAME_FP0; \
184 for (i_ = 0; i_ < 16; i_++) \
185 { \
186 (FS)->regs.reg[r_+i_].how = REG_SAVED_OFFSET; \
187 (FS)->regs.reg[r_+i_].loc.offset \
188 = (long)&((SC)->sc_fpregs[i_]) - (CFA); \
189 } \
190 \
191 r_ = SH_DWARF_FRAME_XD0 ; \
192 for (i_ = 0; i_ < 8; i_++) \
193 { \
194 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
195 (FS)->regs.reg[i_].loc.offset \
196 = (long)&((SC)->sc_xfpregs[2*i_]) - (CFA); \
197 } \
198 \
199 (FS)->regs.reg[SH_DWARF_FRAME_FPUL].how = REG_SAVED_OFFSET; \
200 (FS)->regs.reg[SH_DWARF_FRAME_FPUL].loc.offset \
201 = (long)&((SC)->sc_fpul) - (CFA); \
202 (FS)->regs.reg[SH_DWARF_FRAME_FPSCR].how = REG_SAVED_OFFSET; \
203 (FS)->regs.reg[SH_DWARF_FRAME_FPSCR].loc.offset \
204 = (long)&((SC)->sc_fpscr) - (CFA); \
205 } while (0)
206
207 #else
208 #define SH_FALLBACK_FRAME_FLOAT_STATE(SC, FS, CFA)
209 #endif
210
211 #define MD_FALLBACK_FRAME_STATE_FOR(CONTEXT, FS, SUCCESS) \
212 do { \
213 unsigned char *pc_ = (CONTEXT)->ra; \
214 struct sigcontext *sc_; \
215 long new_cfa_; \
216 int i_; \
217 \
218 /* mov.w 1f,r3; trapa #0x10; 1: .short 0x77 (sigreturn) */ \
219 /* mov.w 1f,r3; trapa #0x10; 1: .short 0xad (rt_sigreturn) */ \
220 if ((*(unsigned short *) (pc_+0) == 0x9300) \
221 && (*(unsigned short *) (pc_+2) == 0xc310) \
222 && (*(unsigned short *) (pc_+4) == 0x0077)) \
223 sc_ = (CONTEXT)->cfa; \
224 else if ((*(unsigned short *) (pc_+0) == 0x9300) \
225 && (*(unsigned short *) (pc_+2) == 0xc310) \
226 && (*(unsigned short *) (pc_+4) == 0x00ad)) \
227 { \
228 struct rt_sigframe { \
229 struct siginfo info; \
230 struct ucontext uc; \
231 } *rt_ = (CONTEXT)->cfa; \
232 sc_ = (struct sigcontext *) &rt_->uc.uc_mcontext; \
233 } \
234 else \
235 break; \
236 \
237 new_cfa_ = sc_->sc_regs[15]; \
238 (FS)->cfa_how = CFA_REG_OFFSET; \
239 (FS)->cfa_reg = 15; \
240 (FS)->cfa_offset = new_cfa_ - (long) (CONTEXT)->cfa; \
241 \
242 for (i_ = 0; i_ < 15; i_++) \
243 { \
244 (FS)->regs.reg[i_].how = REG_SAVED_OFFSET; \
245 (FS)->regs.reg[i_].loc.offset \
246 = (long)&(sc_->sc_regs[i_]) - new_cfa_; \
247 } \
248 \
249 (FS)->regs.reg[SH_DWARF_FRAME_PR].how = REG_SAVED_OFFSET; \
250 (FS)->regs.reg[SH_DWARF_FRAME_PR].loc.offset \
251 = (long)&(sc_->sc_pr) - new_cfa_; \
252 (FS)->regs.reg[SH_DWARF_FRAME_SR].how = REG_SAVED_OFFSET; \
253 (FS)->regs.reg[SH_DWARF_FRAME_SR].loc.offset \
254 = (long)&(sc_->sc_sr) - new_cfa_; \
255 (FS)->regs.reg[SH_DWARF_FRAME_GBR].how = REG_SAVED_OFFSET; \
256 (FS)->regs.reg[SH_DWARF_FRAME_GBR].loc.offset \
257 = (long)&(sc_->sc_gbr) - new_cfa_; \
258 (FS)->regs.reg[SH_DWARF_FRAME_MACH].how = REG_SAVED_OFFSET; \
259 (FS)->regs.reg[SH_DWARF_FRAME_MACH].loc.offset \
260 = (long)&(sc_->sc_mach) - new_cfa_; \
261 (FS)->regs.reg[SH_DWARF_FRAME_MACL].how = REG_SAVED_OFFSET; \
262 (FS)->regs.reg[SH_DWARF_FRAME_MACL].loc.offset \
263 = (long)&(sc_->sc_macl) - new_cfa_; \
264 \
265 SH_FALLBACK_FRAME_FLOAT_STATE(sc_, (FS), new_cfa_); \
266 \
267 /* The unwinder expects the PC to point to the following insn, \
268 whereas the kernel returns the address of the actual \
269 faulting insn. */ \
270 sc_->sc_pc += 2; \
271 (FS)->regs.reg[SH_DWARF_FRAME_PC].how = REG_SAVED_OFFSET; \
272 (FS)->regs.reg[SH_DWARF_FRAME_PC].loc.offset \
273 = (long)&(sc_->sc_pc) - new_cfa_; \
274 (FS)->retaddr_column = SH_DWARF_FRAME_PC; \
275 goto SUCCESS; \
276 } while (0)
277
278 #endif /* defined (__SH5__) */
279 #endif /* IN_LIBGCC2 */