]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/sh/elf.h
Contribute sh64-elf.
[thirdparty/gcc.git] / gcc / config / sh / elf.h
1 /* Definitions of target machine for gcc for Hitachi Super-H using ELF.
2 Copyright (C) 1996, 1997, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Ian Lance Taylor <ian@cygnus.com>.
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 GNU CC; 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 /* Undefine some macros defined in both sh.h and svr4.h. */
23 #undef IDENT_ASM_OP
24 #undef ASM_FILE_END
25 #undef ASM_OUTPUT_SOURCE_LINE
26 #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
27 #undef TARGET_ASM_NAMED_SECTION
28 #undef ASM_DECLARE_FUNCTION_NAME
29 #undef MAX_OFILE_ALIGNMENT
30 #undef SIZE_TYPE
31 #undef PTRDIFF_TYPE
32
33 /* Be ELF-like. */
34 /* TODO: convert includes to ${tm_file} list in config.gcc. */
35 #include "dbxelf.h"
36 #include "elfos.h"
37 #include "svr4.h"
38
39 /* No SDB debugging info. */
40 #undef SDB_DEBUGGING_INFO
41
42 /* Generate DWARF2 debugging information and make it the default */
43 #undef DWARF2_DEBUGGING_INFO
44 #define DWARF2_DEBUGGING_INFO 1
45
46 #undef PREFERRED_DEBUGGING_TYPE
47 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
48
49 /* use a more compact format for line information */
50 #define DWARF2_ASM_LINE_DEBUG_INFO 1
51
52 /* WCHAR_TYPE_SIZE is defined to BITS_PER_WORD in svr4.h, but
53 BITS_PER_WORD isn't constant any more. Fortunately, on no SH
54 platform is it wider than 32-bits. */
55 #define MAX_WCHAR_TYPE_SIZE 32
56
57 /* The prefix to add to user-visible assembler symbols.
58 Note that svr4.h redefined it from the original value (that we want)
59 in sh.h */
60
61 #undef USER_LABEL_PREFIX
62 #define USER_LABEL_PREFIX "_"
63
64 #undef LOCAL_LABEL_PREFIX
65 #define LOCAL_LABEL_PREFIX "."
66
67 #undef ASM_FILE_START
68 #define ASM_FILE_START(FILE) do { \
69 output_file_directive ((FILE), main_input_filename); \
70 /* We also need to show the text section with the proper \
71 attributes as in TEXT_SECTION_ASM_OP, before dwarf2out \
72 emits it without attributes in TEXT_SECTION, else GAS \
73 will complain. We can teach GAS specifically about the \
74 default attributes for our choice of text section, but \
75 then we would have to change GAS again if/when we change \
76 the text section name. */ \
77 fprintf ((FILE), "%s\n", TEXT_SECTION_ASM_OP); \
78 if (TARGET_LITTLE_ENDIAN) \
79 fprintf ((FILE), "\t.little\n"); \
80 } while (0)
81
82
83
84 /* Let code know that this is ELF. */
85 #define CPP_PREDEFINES "-D__sh__ -D__ELF__ -Acpu=sh -Amachine=sh"
86
87 #undef SIZE_TYPE
88 #define SIZE_TYPE (TARGET_SH5 ? "long unsigned int" : "unsigned int")
89
90 #undef PTRDIFF_TYPE
91 #define PTRDIFF_TYPE (TARGET_SH5 ? "long int" : "int")
92 /* Pass -ml and -mrelax to the assembler and linker. */
93 #undef ASM_SPEC
94 #define ASM_SPEC "%{ml:-little} %{mrelax:-relax} \
95 %{m5-compact:--isa=SHcompact} %{m5-compact-nofpu:--isa=SHcompact} \
96 %{m5-32media:--isa=SHmedia --abi=32} %{m5-32media-nofpu:--isa=SHmedia --abi=32} \
97 %{m5-64media:--isa=SHmedia --abi=64} %{m5-64media-nofpu:--isa=SHmedia --abi=64}"
98
99 #undef LINK_SPEC
100 #define LINK_SPEC " \
101 %{m5-compact:%{!ml:-m shelf32} %{ml:-m shlelf32}} \
102 %{m5-compact-nofpu:%{!ml:-m shelf32} %{ml:-m shlelf32}} \
103 %{m5-32media:%{!ml:-m shelf32} %{ml:-m shlelf32}} \
104 %{m5-32media-nofpu:%{!ml:-m shelf32} %{ml:-m shlelf32}} \
105 %{m5-64media:%{!ml:-m shelf64} %{ml:-m shlelf64}} \
106 %{m5-64media-nofpu:%{!ml:-m shelf64} %{ml:-m shlelf64}} \
107 %{!m5-64media:%{!m5-64media-nofpu:%{!m5-32media:%{!m5-32media-nofpu:%{!m5-compact:%{!m5-compact-nofpu:%{ml:-m shlelf}}}}}}} \
108 %{mrelax:-relax}"
109
110 /* svr4.h undefined DBX_REGISTER_NUMBER, so we need to define it
111 again. */
112 #define DBX_REGISTER_NUMBER(REGNO) \
113 (GENERAL_REGISTER_P (REGNO) \
114 ? ((REGNO) - FIRST_GENERAL_REG) \
115 : FP_REGISTER_P (REGNO) \
116 ? ((REGNO) - FIRST_FP_REG + (TARGET_SH5 ? (TARGET_SHCOMPACT ? 245 \
117 : 77) : 25)) \
118 : XD_REGISTER_P (REGNO) \
119 ? ((REGNO) - FIRST_XD_REG + (TARGET_SH5 ? 289 : 87)) \
120 : TARGET_REGISTER_P (REGNO) \
121 ? ((REGNO) - FIRST_TARGET_REG + 68) \
122 : (REGNO) == PR_REG \
123 ? (TARGET_SH5 ? 241 : 17) \
124 : (REGNO) == T_REG \
125 ? (TARGET_SH5 ? 242 : 18) \
126 : (REGNO) == GBR_REG \
127 ? (TARGET_SH5 ? 238 : 19) \
128 : (REGNO) == MACH_REG \
129 ? (TARGET_SH5 ? 239 : 20) \
130 : (REGNO) == MACL_REG \
131 ? (TARGET_SH5 ? 240 : 21) \
132 : (REGNO) == FPUL_REG \
133 ? (TARGET_SH5 ? 244 : 23) \
134 : (abort(), -1))
135
136 #undef ASM_GENERATE_INTERNAL_LABEL
137 #define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM) \
138 sprintf ((STRING), "*%s%s%ld", LOCAL_LABEL_PREFIX, (PREFIX), (long)(NUM))
139
140 #undef ASM_OUTPUT_INTERNAL_LABEL
141 #define ASM_OUTPUT_INTERNAL_LABEL(FILE,PREFIX,NUM) \
142 asm_fprintf ((FILE), "%L%s%d:\n", (PREFIX), (NUM))
143
144 #undef ASM_OUTPUT_SOURCE_LINE
145 #define ASM_OUTPUT_SOURCE_LINE(file, line) \
146 do \
147 { \
148 static int sym_lineno = 1; \
149 asm_fprintf ((file), ".stabn 68,0,%d,%LLM%d-", \
150 (line), sym_lineno); \
151 assemble_name ((file), \
152 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));\
153 asm_fprintf ((file), "\n%LLM%d:\n", sym_lineno); \
154 sym_lineno += 1; \
155 } \
156 while (0)
157
158 #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
159 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
160 do { \
161 text_section (); \
162 fprintf ((FILE), "\t.stabs \"\",%d,0,0,Letext\nLetext:\n", N_SO); \
163 } while (0)
164
165 #undef STARTFILE_SPEC
166 #define STARTFILE_SPEC \
167 "%{!shared: crt1.o%s} crti.o%s \
168 %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
169
170 #undef ENDFILE_SPEC
171 #define ENDFILE_SPEC \
172 "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"