]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/i386/sol2.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / i386 / sol2.h
1 /* Target definitions for GCC for Intel 80386 running Solaris 2
2 Copyright (C) 1993-2022 Free Software Foundation, Inc.
3 Contributed by Fred Fish (fnf@cygnus.com).
4
5 This file is part of GCC.
6
7 GCC 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 3, or (at your option)
10 any later version.
11
12 GCC 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 GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21 #define SUBTARGET_OPTIMIZATION_OPTIONS \
22 { OPT_LEVELS_1_PLUS, OPT_momit_leaf_frame_pointer, NULL, 1 }
23
24 /* 32-bit Solaris/x86 only guarantees 4-byte stack alignment as required by
25 the i386 psABI, so realign it as necessary for SSE instructions. */
26 #undef STACK_REALIGN_DEFAULT
27 #define STACK_REALIGN_DEFAULT (TARGET_64BIT ? 0 : 1)
28
29 /* Old versions of the Solaris assembler cannot handle the difference of
30 labels in different sections, so force DW_EH_PE_datarel if so. */
31 #ifndef HAVE_AS_IX86_DIFF_SECT_DELTA
32 #undef ASM_PREFERRED_EH_DATA_FORMAT
33 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \
34 (flag_pic ? ((GLOBAL ? DW_EH_PE_indirect : 0) \
35 | (TARGET_64BIT ? DW_EH_PE_pcrel | DW_EH_PE_sdata4 \
36 : DW_EH_PE_datarel)) \
37 : DW_EH_PE_absptr)
38 #endif
39
40 /* The Solaris linker will not merge a read-only .eh_frame section
41 with a read-write .eh_frame section. None of the encodings used
42 with non-PIC code require runtime relocations. In 64-bit mode,
43 since there is no backwards compatibility issue, we use a read-only
44 section for .eh_frame. In 32-bit mode, we use a writable .eh_frame
45 section in order to be compatible with G++ for Solaris x86. */
46 #undef EH_TABLES_CAN_BE_READ_ONLY
47 #define EH_TABLES_CAN_BE_READ_ONLY (TARGET_64BIT)
48
49 /* Follow Sun requirements for TLS code sequences and use Sun assembler TLS
50 syntax. */
51 #undef TARGET_SUN_TLS
52 #define TARGET_SUN_TLS 1
53
54 #undef CPP_SPEC
55 #define CPP_SPEC "%(cpp_subtarget)"
56
57 #undef CC1_SPEC
58 #define CC1_SPEC "%(cc1_cpu) " ASAN_CC1_SPEC \
59 " %{mx32:%e-mx32 is not supported on Solaris}"
60
61 /* GNU as understands --32 and --64, but the native Solaris
62 assembler requires -xarch=generic or -xarch=generic64 instead. */
63 #ifdef USE_GAS
64 #define ASM_CPU32_DEFAULT_SPEC "--32"
65 #define ASM_CPU64_DEFAULT_SPEC "--64"
66 #else
67 #define ASM_CPU32_DEFAULT_SPEC "-xarch=generic"
68 #define ASM_CPU64_DEFAULT_SPEC "-xarch=generic64"
69 #endif
70
71 /* Since Studio 12.6, as needs -xbrace_comment=no so its AVX512 syntax is
72 fully compatible with gas. */
73 #ifdef HAVE_AS_XBRACE_COMMENT_OPTION
74 #define ASM_XBRACE_COMMENT_SPEC "-xbrace_comment=no"
75 #else
76 #define ASM_XBRACE_COMMENT_SPEC ""
77 #endif
78
79 #undef ASM_CPU_SPEC
80 #define ASM_CPU_SPEC "%(asm_cpu_default) " ASM_XBRACE_COMMENT_SPEC
81
82 /* Don't include ASM_PIC_SPEC. While the Solaris 10+ assembler accepts -K PIC,
83 it gives many warnings:
84 Absolute relocation is used for symbol "<symbol>"
85 GNU as doesn't recognize -K at all. */
86 #undef ASM_SPEC
87 #define ASM_SPEC ASM_SPEC_BASE
88
89 #define DEFAULT_ARCH32_P !TARGET_64BIT_DEFAULT
90
91 #define ARCH64_SUBDIR "amd64"
92
93 #ifdef USE_GLD
94 /* Since binutils 2.21, GNU ld supports new *_sol2 emulations to strictly
95 follow the Solaris 2 ABI. Prefer them if present. */
96 #ifdef HAVE_LD_SOL2_EMULATION
97 #define ARCH32_EMULATION "elf_i386_sol2"
98 #define ARCH64_EMULATION "elf_x86_64_sol2"
99 #else
100 #define ARCH32_EMULATION "elf_i386"
101 #define ARCH64_EMULATION "elf_x86_64"
102 #endif
103 #endif
104
105 #define ENDFILE_ARCH_SPEC \
106 "%{mpc32:crtprec32.o%s} \
107 %{mpc64:crtprec64.o%s} \
108 %{mpc80:crtprec80.o%s}"
109
110 #define SUBTARGET_CPU_EXTRA_SPECS \
111 { "cpp_subtarget", CPP_SUBTARGET_SPEC }, \
112 { "asm_cpu", ASM_CPU_SPEC }, \
113 { "asm_cpu_default", ASM_CPU_DEFAULT_SPEC }, \
114
115 /* Register the Solaris-specific #pragma directives. */
116 #define REGISTER_SUBTARGET_PRAGMAS() solaris_register_pragmas ()
117
118 #undef LOCAL_LABEL_PREFIX
119 #define LOCAL_LABEL_PREFIX "."
120
121 /* The 32-bit Solaris assembler does not support .quad. Do not use it. */
122 #ifndef HAVE_AS_IX86_QUAD
123 #undef ASM_QUAD
124 #endif
125
126 /* The native Solaris assembler can't calculate the difference between
127 symbols in different sections, which causes problems for -fPIC jump
128 tables in .rodata. */
129 #ifndef HAVE_AS_IX86_DIFF_SECT_DELTA
130 #undef JUMP_TABLES_IN_TEXT_SECTION
131 #define JUMP_TABLES_IN_TEXT_SECTION 1
132
133 /* The native Solaris assembler cannot handle the SYMBOL-. syntax, but
134 requires SYMBOL@rel/@rel64 instead. */
135 #define ASM_OUTPUT_DWARF_PCREL(FILE, SIZE, LABEL) \
136 do { \
137 fputs (integer_asm_op (SIZE, FALSE), FILE); \
138 assemble_name (FILE, LABEL); \
139 fputs (SIZE == 8 ? "@rel64" : "@rel", FILE); \
140 } while (0)
141 #endif
142
143 /* The Solaris assembler wants a .local for non-exported aliases. */
144 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET) \
145 do { \
146 tree id = DECL_ASSEMBLER_NAME (DECL); \
147 ultimate_transparent_alias_target (&id); \
148 const char *declname = IDENTIFIER_POINTER (id); \
149 ASM_OUTPUT_DEF ((FILE), declname, \
150 IDENTIFIER_POINTER (TARGET)); \
151 if (! TREE_PUBLIC (DECL)) \
152 { \
153 fprintf ((FILE), "%s", LOCAL_ASM_OP); \
154 assemble_name ((FILE), declname); \
155 fprintf ((FILE), "\n"); \
156 } \
157 } while (0)
158
159 #ifndef USE_GAS
160 /* The Sun assembler uses .tcomm for TLS common sections. */
161 #define TLS_COMMON_ASM_OP ".tcomm"
162
163 /* Similar to the Sun assembler on SPARC, the native assembler requires
164 TLS objects to be declared as @tls_obj (not @tls_object). Unlike SPARC,
165 gas doesn't understand this variant. */
166 #undef ASM_DECLARE_OBJECT_NAME
167 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
168 do \
169 { \
170 HOST_WIDE_INT size; \
171 \
172 if (targetm.have_tls && DECL_THREAD_LOCAL_P (DECL)) \
173 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "tls_obj"); \
174 else \
175 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
176 \
177 size_directive_output = 0; \
178 if (!flag_inhibit_size_directive \
179 && (DECL) && DECL_SIZE (DECL)) \
180 { \
181 size_directive_output = 1; \
182 size = int_size_in_bytes (TREE_TYPE (DECL)); \
183 ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
184 } \
185 \
186 ASM_OUTPUT_LABEL (FILE, NAME); \
187 } \
188 while (0)
189 #endif /* !USE_GAS */
190
191 /* As in sparc/sol2.h, override the default from i386/x86-64.h to work
192 around Sun as TLS bug. */
193 #undef ASM_OUTPUT_ALIGNED_DECL_COMMON
194 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN) \
195 do \
196 { \
197 if (TARGET_SUN_TLS \
198 && in_section \
199 && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS)) \
200 switch_to_section (bss_section); \
201 x86_elf_aligned_decl_common (FILE, DECL, NAME, SIZE, ALIGN); \
202 } \
203 while (0)
204
205 /* Output a simple call for .init/.fini. */
206 #define ASM_OUTPUT_CALL(FILE, FN) \
207 do \
208 { \
209 fprintf (FILE, "\tcall\t"); \
210 ix86_print_operand (FILE, XEXP (DECL_RTL (FN), 0), 'P'); \
211 fprintf (FILE, "\n"); \
212 } \
213 while (0)
214
215 #undef TARGET_ASM_NAMED_SECTION
216 #define TARGET_ASM_NAMED_SECTION i386_solaris_elf_named_section
217
218 /* Sun as requires "h" flag for large sections, GNU as can do without, but
219 accepts "l". */
220 #ifdef USE_GAS
221 #define MACH_DEP_SECTION_ASM_FLAG 'l'
222 #else
223 #define MACH_DEP_SECTION_ASM_FLAG 'h'
224 #endif
225
226 #ifndef USE_GAS
227 /* Emit COMDAT group signature symbols for Sun as. */
228 #undef TARGET_ASM_FILE_END
229 #define TARGET_ASM_FILE_END solaris_file_end
230 #endif
231
232 /* Unlike GNU ld, Sun ld doesn't coalesce .ctors.N/.dtors.N sections, so
233 inhibit their creation. Also cf. sparc/sysv4.h. */
234 #ifndef USE_GLD
235 #define CTORS_SECTION_ASM_OP "\t.section\t.ctors, \"aw\""
236 #define DTORS_SECTION_ASM_OP "\t.section\t.dtors, \"aw\""
237 #endif
238
239 #ifndef USE_GAS
240 #define LARGECOMM_SECTION_ASM_OP "\t.lbcomm\t"
241 #endif
242
243 /* -fsanitize=address is currently only supported for 32-bit. */
244 #define ASAN_REJECT_SPEC \
245 DEF_ARCH64_SPEC("%e-fsanitize=address is not supported in this configuration")
246
247 #undef NO_PROFILE_COUNTERS
248
249 #undef MCOUNT_NAME
250 #define MCOUNT_NAME "_mcount"
251
252 /* We do not need NT_VERSION notes. */
253 #undef X86_FILE_START_VERSION_DIRECTIVE
254 #define X86_FILE_START_VERSION_DIRECTIVE false