1 /* Target definitions for GCC for Intel 80386 running Solaris 2
2    Copyright (C) 1993-2018 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 can not 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 /* GNU as understands --32 and --64, but the native Solaris
58    assembler requires -xarch=generic or -xarch=generic64 instead.  */
59 #ifdef USE_GAS
60 #define ASM_CPU32_DEFAULT_SPEC "--32"
61 #define ASM_CPU64_DEFAULT_SPEC "--64"
62 #else
63 #define ASM_CPU32_DEFAULT_SPEC "-xarch=generic"
64 #define ASM_CPU64_DEFAULT_SPEC "-xarch=generic64"
65 #endif
66 
67 /* Since Studio 12.6, as needs -xbrace_comment=no so its AVX512 syntax is
68    fully compatible with gas.  */
69 #ifdef HAVE_AS_XBRACE_COMMENT_OPTION
70 #define ASM_XBRACE_COMMENT_SPEC "-xbrace_comment=no"
71 #else
72 #define ASM_XBRACE_COMMENT_SPEC ""
73 #endif
74 
75 #undef ASM_CPU_SPEC
76 #define ASM_CPU_SPEC "%(asm_cpu_default) " ASM_XBRACE_COMMENT_SPEC
77 
78 /* Don't include ASM_PIC_SPEC.  While the Solaris 10+ assembler accepts -K PIC,
79    it gives many warnings:
80 	Absolute relocation is used for symbol "<symbol>"
81    GNU as doesn't recognize -K at all.  */
82 #undef ASM_SPEC
83 #define ASM_SPEC ASM_SPEC_BASE
84 
85 #define DEFAULT_ARCH32_P !TARGET_64BIT_DEFAULT
86 
87 #define ARCH64_SUBDIR "amd64"
88 
89 #ifdef USE_GLD
90 /* Since binutils 2.21, GNU ld supports new *_sol2 emulations to strictly
91    follow the Solaris 2 ABI.  Prefer them if present.  */
92 #ifdef HAVE_LD_SOL2_EMULATION
93 #define ARCH32_EMULATION "elf_i386_sol2"
94 #define ARCH64_EMULATION "elf_x86_64_sol2"
95 #else
96 #define ARCH32_EMULATION "elf_i386"
97 #define ARCH64_EMULATION "elf_x86_64"
98 #endif
99 #endif
100 
101 #define ENDFILE_ARCH_SPEC \
102   "%{mpc32:crtprec32.o%s} \
103    %{mpc64:crtprec64.o%s} \
104    %{mpc80:crtprec80.o%s}"
105 
106 #define SUBTARGET_CPU_EXTRA_SPECS \
107   { "cpp_subtarget",	 CPP_SUBTARGET_SPEC },		\
108   { "asm_cpu",		 ASM_CPU_SPEC },		\
109   { "asm_cpu_default",	 ASM_CPU_DEFAULT_SPEC },	\
110 
111 /* Register the Solaris-specific #pragma directives.  */
112 #define REGISTER_SUBTARGET_PRAGMAS() solaris_register_pragmas ()
113 
114 #undef LOCAL_LABEL_PREFIX
115 #define LOCAL_LABEL_PREFIX "."
116 
117 /* The Solaris 10 FCS as doesn't accept "#" comments, while later versions
118    do.  */
119 #undef ASM_COMMENT_START
120 #define ASM_COMMENT_START "/"
121 
122 /* The 32-bit Solaris assembler does not support .quad.  Do not use it.  */
123 #ifndef HAVE_AS_IX86_QUAD
124 #undef ASM_QUAD
125 #endif
126 
127 /* The native Solaris assembler can't calculate the difference between
128    symbols in different sections, which causes problems for -fPIC jump
129    tables in .rodata.  */
130 #ifndef HAVE_AS_IX86_DIFF_SECT_DELTA
131 #undef JUMP_TABLES_IN_TEXT_SECTION
132 #define JUMP_TABLES_IN_TEXT_SECTION 1
133 
134 /* The native Solaris assembler cannot handle the SYMBOL-. syntax, but
135    requires SYMBOL@rel/@rel64 instead.  */
136 #define ASM_OUTPUT_DWARF_PCREL(FILE, SIZE, LABEL)	\
137   do {							\
138     fputs (integer_asm_op (SIZE, FALSE), FILE);		\
139     assemble_name (FILE, LABEL);			\
140     fputs (SIZE == 8 ? "@rel64" : "@rel", FILE);	\
141   } while (0)
142 #endif
143 
144 /* The Solaris assembler wants a .local for non-exported aliases.  */
145 #define ASM_OUTPUT_DEF_FROM_DECLS(FILE, DECL, TARGET)	\
146   do {							\
147     tree id = DECL_ASSEMBLER_NAME (DECL);		\
148     ultimate_transparent_alias_target (&id);		\
149     const char *declname = IDENTIFIER_POINTER (id);	\
150     ASM_OUTPUT_DEF ((FILE), declname,			\
151 		    IDENTIFIER_POINTER (TARGET));	\
152     if (! TREE_PUBLIC (DECL))				\
153       {							\
154 	fprintf ((FILE), "%s", LOCAL_ASM_OP);		\
155 	assemble_name ((FILE), declname);		\
156 	fprintf ((FILE), "\n");				\
157       }							\
158   } while (0)
159 
160 #ifndef USE_GAS
161 /* The Sun assembler uses .tcomm for TLS common sections.  */
162 #define TLS_COMMON_ASM_OP ".tcomm"
163 
164 /* Similar to the Sun assembler on SPARC, the native assembler requires
165    TLS objects to be declared as @tls_obj (not @tls_object).  Unlike SPARC,
166    gas doesn't understand this variant.  */
167 #undef  ASM_DECLARE_OBJECT_NAME
168 #define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL)		\
169   do								\
170     {								\
171       HOST_WIDE_INT size;					\
172 								\
173       if (targetm.have_tls && DECL_THREAD_LOCAL_P (DECL))	\
174 	ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "tls_obj");	\
175       else							\
176 	ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object");	\
177 								\
178       size_directive_output = 0;				\
179       if (!flag_inhibit_size_directive				\
180 	  && (DECL) && DECL_SIZE (DECL))			\
181 	{							\
182 	  size_directive_output = 1;				\
183 	  size = int_size_in_bytes (TREE_TYPE (DECL));		\
184 	  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size);		\
185 	}							\
186 								\
187       ASM_OUTPUT_LABEL (FILE, NAME);				\
188     }								\
189   while (0)
190 #endif /* !USE_GAS */
191 
192 /* As in sparc/sol2.h, override the default from i386/x86-64.h to work
193    around Sun as TLS bug.  */
194 #undef  ASM_OUTPUT_ALIGNED_DECL_COMMON
195 #define ASM_OUTPUT_ALIGNED_DECL_COMMON(FILE, DECL, NAME, SIZE, ALIGN)	\
196   do									\
197     {									\
198       if (TARGET_SUN_TLS						\
199 	  && in_section							\
200 	  && ((in_section->common.flags & SECTION_TLS) == SECTION_TLS))	\
201 	switch_to_section (bss_section);				\
202       x86_elf_aligned_decl_common (FILE, DECL, NAME, SIZE, ALIGN);	\
203     }									\
204   while  (0)
205 
206 /* Output a simple call for .init/.fini.  */
207 #define ASM_OUTPUT_CALL(FILE, FN)				\
208   do								\
209     {								\
210       fprintf (FILE, "\tcall\t");				\
211       ix86_print_operand (FILE, XEXP (DECL_RTL (FN), 0), 'P');	\
212       fprintf (FILE, "\n");					\
213     }								\
214   while (0)
215 
216 #undef TARGET_ASM_NAMED_SECTION
217 #define TARGET_ASM_NAMED_SECTION i386_solaris_elf_named_section
218 
219 /* Sun as requires "h" flag for large sections, GNU as can do without, but
220    accepts "l".  */
221 #ifdef USE_GAS
222 #define MACH_DEP_SECTION_ASM_FLAG 'l'
223 #else
224 #define MACH_DEP_SECTION_ASM_FLAG 'h'
225 #endif
226 
227 #ifndef USE_GAS
228 /* Emit COMDAT group signature symbols for Sun as.  */
229 #undef TARGET_ASM_FILE_END
230 #define TARGET_ASM_FILE_END solaris_file_end
231 #endif
232 
233 /* Unlike GNU ld, Sun ld doesn't coalesce .ctors.N/.dtors.N sections, so
234    inhibit their creation.  Also cf. sparc/sysv4.h.  */
235 #ifndef USE_GLD
236 #define CTORS_SECTION_ASM_OP	"\t.section\t.ctors, \"aw\""
237 #define DTORS_SECTION_ASM_OP	"\t.section\t.dtors, \"aw\""
238 #endif
239 
240 #ifndef USE_GAS
241 #define LARGECOMM_SECTION_ASM_OP "\t.lbcomm\t"
242 #endif
243 
244 #define USE_IX86_FRAME_POINTER 1
245 #define USE_X86_64_FRAME_POINTER 1
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
255