gcc:
[official-gcc.git] / gcc / config / sh / linux.h
blobc38055208c80f142927f8ec1ade5a59d212fe770
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, 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* Run-time Target Specification. */
24 #undef TARGET_VERSION
25 #define TARGET_VERSION fputs (" (SH GNU/Linux with ELF)", stderr);
27 /* Enable DWARF 2 exceptions. */
28 #undef DWARF2_UNWIND_INFO
29 #define DWARF2_UNWIND_INFO 1
31 #undef SUBTARGET_CPP_SPEC
32 #define SUBTARGET_CPP_SPEC "\
33 %{posix:-D_POSIX_SOURCE} \
34 %{pthread:-D_REENTRANT -D_PTHREADS} \
37 #define TARGET_OS_CPP_BUILTINS() \
38 do \
39 { \
40 LINUX_TARGET_OS_CPP_BUILTINS(); \
41 if (flag_pic) \
42 { \
43 builtin_define ("__PIC__"); \
44 builtin_define ("__pic__"); \
45 } \
46 } \
47 while (0)
49 #undef TARGET_DEFAULT
50 #define TARGET_DEFAULT \
51 (TARGET_CPU_DEFAULT | MASK_USERMODE | TARGET_ENDIAN_DEFAULT \
52 | TARGET_OPT_DEFAULT)
54 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
56 #undef SUBTARGET_LINK_EMUL_SUFFIX
57 #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
58 #undef SUBTARGET_LINK_SPEC
59 #define SUBTARGET_LINK_SPEC \
60 "%{shared:-shared} \
61 %{!static: \
62 %{rdynamic:-export-dynamic} \
63 %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
64 %{static:-static}"
66 /* Output assembler code to STREAM to call the profiler. */
68 #undef FUNCTION_PROFILER
69 #define FUNCTION_PROFILER(STREAM,LABELNO) \
70 do { \
71 if (TARGET_SHMEDIA) \
72 { \
73 fprintf (STREAM, "\tpt\t1f,tr1\n"); \
74 fprintf (STREAM, "\taddi.l\tr15,-8,r15\n"); \
75 fprintf (STREAM, "\tst.l\tr15,0,r18\n"); \
76 if (flag_pic) \
77 { \
78 const char *gofs = "(datalabel _GLOBAL_OFFSET_TABLE_-(0f-.))"; \
79 fprintf (STREAM, "\tmovi\t((%s>>16)&0xffff),r21\n", gofs); \
80 fprintf (STREAM, "\tshori\t(%s & 0xffff),r21\n", gofs); \
81 fprintf (STREAM, "0:\tptrel/u\tr21,tr0\n"); \
82 fprintf (STREAM, "\tmovi\t((mcount@GOTPLT)&0xffff),r22\n"); \
83 fprintf (STREAM, "\tgettr\ttr0,r21\n"); \
84 fprintf (STREAM, "\tadd.l\tr21,r22,r21\n"); \
85 fprintf (STREAM, "\tld.l\tr21,0,r21\n"); \
86 fprintf (STREAM, "\tptabs\tr21,tr0\n"); \
87 } \
88 else \
89 fprintf (STREAM, "\tpt\tmcount,tr0\n"); \
90 fprintf (STREAM, "\tgettr\ttr1,r18\n"); \
91 fprintf (STREAM, "\tblink\ttr0,r63\n"); \
92 fprintf (STREAM, "1:\tld.l\tr15,0,r18\n"); \
93 fprintf (STREAM, "\taddi.l\tr15,8,r15\n"); \
94 } \
95 else \
96 { \
97 if (flag_pic) \
98 { \
99 fprintf (STREAM, "\tmov.l\t3f,r1\n"); \
100 fprintf (STREAM, "\tmova\t3f,r0\n"); \
101 fprintf (STREAM, "\tadd\tr1,r0\n"); \
102 fprintf (STREAM, "\tmov.l\t1f,r1\n"); \
103 fprintf (STREAM, "\tmov.l\t@(r0,r1),r1\n"); \
105 else \
106 fprintf (STREAM, "\tmov.l\t1f,r1\n"); \
107 fprintf (STREAM, "\tsts.l\tpr,@-r15\n"); \
108 fprintf (STREAM, "\tmova\t2f,r0\n"); \
109 fprintf (STREAM, "\tjmp\t@r1\n"); \
110 fprintf (STREAM, "\tlds\tr0,pr\n"); \
111 fprintf (STREAM, "\t.align\t2\n"); \
112 if (flag_pic) \
114 fprintf (STREAM, "1:\t.long\tmcount@GOT\n"); \
115 fprintf (STREAM, "3:\t.long\t_GLOBAL_OFFSET_TABLE_\n"); \
117 else \
118 fprintf (STREAM, "1:\t.long\tmcount\n"); \
119 fprintf (STREAM, "2:\tlds.l\t@r15+,pr\n"); \
121 } while (0)
123 #define MD_UNWIND_SUPPORT "config/sh/linux-unwind.h"
125 /* For SH3 and SH4, we use a slot of the unwind frame which correspond
126 to a fake register number 16 as a placeholder for the return address
127 in MD_FALLBACK_FRAME_STATE_FOR and its content will be read with
128 _Unwind_GetGR which uses dwarf_reg_size_table to get the size of
129 the register. So the entry of dwarf_reg_size_table corresponding to
130 this slot must be set. To do this, we redefine DBX_REGISTER_NUMBER
131 so as to return itself for 16. */
132 #undef DBX_REGISTER_NUMBER
133 #define DBX_REGISTER_NUMBER(REGNO) \
134 ((! TARGET_SH5 && (REGNO) == 16) ? 16 : SH_DBX_REGISTER_NUMBER (REGNO))
136 /* Since libgcc is compiled with -fpic for this target, we can't use
137 __sdivsi3_1 as the division strategy for -O0 and -Os. */
138 #undef SH_DIV_STRATEGY_DEFAULT
139 #define SH_DIV_STRATEGY_DEFAULT SH_DIV_CALL2
140 #undef SH_DIV_STR_FOR_SIZE
141 #define SH_DIV_STR_FOR_SIZE "call2"