]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/pa/som.h
Update copyright years.
[thirdparty/gcc.git] / gcc / config / pa / som.h
CommitLineData
0d381b47 1/* Definitions for SOM assembler support.
7adcbafe 2 Copyright (C) 1999-2022 Free Software Foundation, Inc.
0d381b47 3
b7849684 4This file is part of GCC.
0d381b47 5
b7849684 6GCC is free software; you can redistribute it and/or modify
0d381b47 7it under the terms of the GNU General Public License as published by
2f83c7d6 8the Free Software Foundation; either version 3, or (at your option)
0d381b47
JL
9any later version.
10
b7849684 11GCC is distributed in the hope that it will be useful,
0d381b47
JL
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
2f83c7d6
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
0d381b47
JL
19
20/* So we can conditionalize small amounts of code in pa.c or pa.md. */
3d9268b6
JDA
21#undef TARGET_SOM
22#define TARGET_SOM 1
0d381b47 23
7bfe7d63
RB
24/* With SOM we can only do STABS. */
25#undef PREFERRED_DEBUGGING_TYPE
26#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
27
0d381b47
JL
28/* We do not use BINCL stabs in SOM.
29 ??? If it does not hurt, we probably should to avoid useless divergence
30 from other embedded stabs implementations. */
31#undef DBX_USE_BINCL
32
3e487b21 33#define DBX_LINES_FUNCTION_RELATIVE 1
0d381b47 34
fe19a83d 35/* gdb needs a null N_SO at the end of each file for scattered loading. */
0d381b47 36
3e487b21 37#define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
0d381b47 38
0d381b47
JL
39/* HPUX has a program 'chatr' to list the dependencies of dynamically
40 linked executables and shared libraries. */
41#define LDD_SUFFIX "chatr"
42/* Look for lines like "dynamic /usr/lib/X11R5/libX11.sl"
43 or "static /usr/lib/X11R5/libX11.sl".
44
45 HPUX 10.20 also has lines like "static branch prediction ..."
46 so we filter that out explicitly.
47
48 We also try to bound our search for libraries with marker
49 lines. What a pain. */
50#define PARSE_LDD_OUTPUT(PTR) \
51do { \
52 static int in_shlib_list = 0; \
53 while (*PTR == ' ') PTR++; \
c0129e2d 54 if (startswith (PTR, "shared library list:")) \
0d381b47
JL
55 { \
56 PTR = 0; \
57 in_shlib_list = 1; \
58 } \
c0129e2d 59 else if (startswith (PTR, "shared library binding:")) \
0d381b47
JL
60 { \
61 PTR = 0; \
62 in_shlib_list = 0; \
63 } \
c0129e2d 64 else if (startswith (PTR, "static branch prediction disabled")) \
0d381b47
JL
65 { \
66 PTR = 0; \
67 in_shlib_list = 0; \
68 } \
69 else if (in_shlib_list \
c0129e2d 70 && startswith (PTR, "dynamic")) \
0d381b47
JL
71 { \
72 PTR += sizeof ("dynamic") - 1; \
73 while (*p == ' ') PTR++; \
74 } \
75 else if (in_shlib_list \
c0129e2d 76 && startswith (PTR, "static")) \
0d381b47
JL
77 { \
78 PTR += sizeof ("static") - 1; \
79 while (*p == ' ') PTR++; \
80 } \
81 else \
82 PTR = 0; \
83} while (0)
84
85/* Output the label for a function definition. */
86#ifndef HP_FP_ARG_DESCRIPTOR_REVERSED
87#define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
88 do { fprintf (FILE, ",ARGW%d=FR", (ARG0)); \
89 fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0)
90#define DFMODE_RETURN_STRING ",RTNVAL=FU"
91#define SFMODE_RETURN_STRING ",RTNVAL=FR"
92#else
93#define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
94 do { fprintf (FILE, ",ARGW%d=FU", (ARG0)); \
95 fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0)
96#define DFMODE_RETURN_STRING ",RTNVAL=FR"
97#define SFMODE_RETURN_STRING ",RTNVAL=FU"
98#endif
99
100\f
0d381b47 101#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
01af7e0a
JDA
102 do { tree tree_type = TREE_TYPE (DECL); \
103 tree fntype = TREE_TYPE (tree_type); \
0d381b47
JL
104 tree parm; \
105 int i; \
106 if (TREE_PUBLIC (DECL) || TARGET_GAS) \
49ad7cfa 107 { \
0d381b47
JL
108 if (TREE_PUBLIC (DECL)) \
109 { \
110 fputs ("\t.EXPORT ", FILE); \
111 assemble_name (FILE, NAME); \
112 fputs (",ENTRY,PRIV_LEV=3", FILE); \
113 } \
114 else \
115 { \
116 fputs ("\t.PARAM ", FILE); \
117 assemble_name (FILE, NAME); \
92bcb380 118 fputs (",PRIV_LEV=3", FILE); \
0d381b47
JL
119 } \
120 for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4; \
910ad8de 121 parm = DECL_CHAIN (parm)) \
0d381b47 122 { \
73da6b3a
JDA
123 tree type = DECL_ARG_TYPE (parm); \
124 machine_mode mode = TYPE_MODE (type); \
01af7e0a
JDA
125 if (!AGGREGATE_TYPE_P (type) \
126 && mode == SFmode && ! TARGET_SOFT_FLOAT) \
0d381b47 127 fprintf (FILE, ",ARGW%d=FR", i++); \
01af7e0a
JDA
128 else if (!AGGREGATE_TYPE_P (type) \
129 && mode == DFmode && ! TARGET_SOFT_FLOAT) \
0d381b47
JL
130 { \
131 if (i <= 2) \
132 { \
133 if (i == 1) i++; \
134 ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++); \
135 } \
136 else \
137 break; \
138 } \
139 else \
140 { \
73da6b3a 141 int arg_size = pa_function_arg_size (mode, type); \
0d381b47
JL
142 /* Passing structs by invisible reference uses \
143 one general register. */ \
73da6b3a 144 if (arg_size > 2 || TREE_ADDRESSABLE (type)) \
0d381b47
JL
145 arg_size = 1; \
146 if (arg_size == 2 && i <= 2) \
147 { \
148 if (i == 1) i++; \
149 fprintf (FILE, ",ARGW%d=GR", i++); \
150 fprintf (FILE, ",ARGW%d=GR", i++); \
151 } \
152 else if (arg_size == 1) \
153 fprintf (FILE, ",ARGW%d=GR", i++); \
154 else \
155 i += arg_size; \
156 } \
157 } \
158 /* anonymous args */ \
f38958e8 159 if (stdarg_p (tree_type)) \
0d381b47
JL
160 { \
161 for (; i < 4; i++) \
162 fprintf (FILE, ",ARGW%d=GR", i); \
163 } \
01af7e0a
JDA
164 if (!AGGREGATE_TYPE_P (fntype) \
165 && TYPE_MODE (fntype) == DFmode \
166 && ! TARGET_SOFT_FLOAT) \
0d381b47 167 fputs (DFMODE_RETURN_STRING, FILE); \
01af7e0a
JDA
168 else if (!AGGREGATE_TYPE_P (fntype) \
169 && TYPE_MODE (fntype) == SFmode \
170 && ! TARGET_SOFT_FLOAT) \
0d381b47
JL
171 fputs (SFMODE_RETURN_STRING, FILE); \
172 else if (fntype != void_type_node) \
173 fputs (",RTNVAL=GR", FILE); \
174 fputs ("\n", FILE); \
175 }} while (0)
176
1bc7c5b6 177#define TARGET_ASM_FILE_START pa_som_file_start
d6b5193b 178#define TARGET_ASM_INIT_SECTIONS pa_som_asm_init_sections
0d381b47 179
774acadf 180/* String to output before writable data. */
9a55eab3
JDA
181#define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
182
774acadf 183/* String to output before uninitialized data. */
9a55eab3
JDA
184#define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
185
478a1f5e
JDA
186/* This is how to output a command to make the user-level label
187 named NAME defined for reference from other files. We use
188 assemble_name_raw instead of assemble_name since a symbol in
189 a .IMPORT directive that isn't otherwise referenced is not
190 placed in the symbol table of the assembled object.
191
192 Failure to import a function reference can cause the HP linker
193 to segmentation fault!
194
195 Note that the SOM based tools need the symbol imported as a
196 CODE symbol, while the ELF based tools require the symbol to
197 be imported as an ENTRY symbol. */
198
199#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
744b2d61
JDA
200 pa_hpux_asm_output_external ((FILE), (DECL), (NAME))
201#define ASM_OUTPUT_EXTERNAL_REAL(FILE, DECL, NAME) \
478a1f5e
JDA
202 do { fputs ("\t.IMPORT ", FILE); \
203 assemble_name_raw (FILE, NAME); \
204 if (FUNCTION_NAME_P (NAME)) \
205 fputs (",CODE\n", FILE); \
206 else \
207 fputs (",DATA\n", FILE); \
0d381b47
JL
208 } while (0)
209
210/* The bogus HP assembler requires ALL external references to be
744b2d61 211 "imported", even library calls. They look a bit different, so
0d381b47
JL
212 here's this macro.
213
fb49053f 214 Also note not all libcall names are passed to pa_encode_section_info
0d381b47 215 (__main for example). To make sure all libcall names have section
744b2d61
JDA
216 info recorded in them, we do it here.
217
218 We must also ensure that a libcall that has been previously
219 exported is not subsequently imported since the HP assembler may
220 change the type from an ENTRY to a CODE symbol. This would make
221 the symbol local. We are forced to use the identifier node
222 associated with the real assembler name for this check as the
223 symbol_ref available in ASM_DECLARE_FUNCTION_NAME is not the
224 same as the one used here. As a result, we can't use flags
225 in the symbol_ref for this check. The identifier check assumes
226 assemble_external_libcall is called before the symbol is used. */
0d381b47
JL
227
228#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
f3403757
JDA
229 do { const char *name; \
230 tree id; \
231 \
0d381b47 232 if (!function_label_operand (RTL, VOIDmode)) \
ae9d61ab 233 pa_encode_label (RTL); \
f3403757 234 \
cdcb88d7 235 name = targetm.strip_name_encoding (XSTR ((RTL), 0)); \
f3403757 236 id = maybe_get_identifier (name); \
cdcb88d7 237 if (!id || !TREE_SYMBOL_REFERENCED (id)) \
f3403757
JDA
238 { \
239 fputs ("\t.IMPORT ", FILE); \
744b2d61 240 assemble_name_raw (FILE, XSTR ((RTL), 0)); \
f3403757
JDA
241 fputs (",CODE\n", FILE); \
242 } \
0d381b47
JL
243 } while (0)
244
2e1ed1e3
JDA
245/* We want __gcc_plt_call to appear in every program built by
246 gcc, so we make a reference to it out of __main.
247 We use the asm statement to fool the optimizer into not
248 removing the dead (but important) initialization of
249 REFERENCE. */
250
251#define DO_GLOBAL_DTORS_BODY \
252do { \
f25b1930
JDA
253 extern void __gcc_plt_call (void); \
254 void (*reference)(void) = &__gcc_plt_call; \
2e1ed1e3
JDA
255 func_ptr *p; \
256 __asm__ ("" : : "r" (reference)); \
257 for (p = __DTOR_LIST__ + 1; *p; ) \
258 (*p++) (); \
259} while (0)
260
d4482715
JDA
261/* This macro specifies the biggest alignment supported by the object
262 file format of this machine.
263
264 The .align directive in the HP assembler allows alignments up to 4096
265 bytes. However, the maximum alignment of a global common symbol is 8
266 bytes for objects smaller than the page size (4096 bytes). For larger
22f549fd
JDA
267 objects, the linker provides an alignment of 32 bytes. Unfortunately,
268 this macro doesn't provide a mechanism to test for common symbols. */
269#define MAX_OFILE_ALIGNMENT 32768
90b37266 270
43852342
JDA
271/* The SOM linker hardcodes paths into binaries. As a result, dotdots
272 must be removed from library prefixes to prevent binaries from depending
273 on the location of the GCC tool directory. The downside is GCC
274 cannot be moved after installation using a symlink. */
c49a6962
JM
275#undef TARGET_ALWAYS_STRIP_DOTDOT
276#define TARGET_ALWAYS_STRIP_DOTDOT true
a02aa5b0 277
4af6a063 278/* If GAS supports weak, we can support weak when we have working linker
74b90fe2
JDA
279 support for secondary definitions and are generating code for GAS.
280 This is primarily for one-only support as SOM doesn't allow undefined
1d4a3bfa 281 weak symbols or weak aliases. */
4af6a063 282#ifdef HAVE_GAS_WEAK
74b90fe2 283#define TARGET_SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
4af6a063 284#else
74b90fe2 285#define TARGET_SUPPORTS_WEAK 0
4af6a063
JDA
286#endif
287
e41f3691
JDA
288/* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa
289 directive. This provides one-only linkage semantics even though we
290 don't have weak support. */
291#ifdef HAVE_GAS_NSUBSPA_COMDAT
292#define SUPPORTS_SOM_COMDAT (TARGET_GAS)
293#else
294#define SUPPORTS_SOM_COMDAT 0
295#endif
4af6a063 296
e41f3691 297/* We can support one only if we support weak or comdat. */
74b90fe2 298#define SUPPORTS_ONE_ONLY (TARGET_SUPPORTS_WEAK || SUPPORTS_SOM_COMDAT)
e41f3691
JDA
299
300/* We use DECL_COMMON for uninitialized one-only variables as we don't
301 have linkonce .bss. We use SOM secondary definitions or comdat for
302 initialized variables and functions. */
303#define MAKE_DECL_ONE_ONLY(DECL) \
304 do { \
305 if (TREE_CODE (DECL) == VAR_DECL \
306 && (DECL_INITIAL (DECL) == 0 \
307 || DECL_INITIAL (DECL) == error_mark_node)) \
308 DECL_COMMON (DECL) = 1; \
74b90fe2 309 else if (TARGET_SUPPORTS_WEAK) \
e41f3691
JDA
310 DECL_WEAK (DECL) = 1; \
311 } while (0)
4af6a063
JDA
312
313/* This is how we tell the assembler that a symbol is weak. The SOM
314 weak implementation uses the secondary definition (sdef) flag.
315
316 The behavior of sdef symbols is similar to ELF weak symbols in that
317 multiple definitions can occur without incurring a link error.
318 However, they differ in the following ways:
319 1) Undefined sdef symbols are not allowed.
320 2) The linker searches for undefined sdef symbols and will load an
321 archive library member to resolve an undefined sdef symbol.
322 3) The exported symbol from a shared library is a primary symbol
323 rather than a sdef symbol. Thus, more care is needed in the
324 ordering of libraries.
325
326 It appears that the linker discards extra copies of "weak" functions
327 when linking shared libraries, independent of whether or not they
328 are in their own section. In linking final executables, -Wl,-O can
329 be used to remove dead procedures. Thus, support for named sections
330 is not needed and in previous testing caused problems with various
331 HP tools. */
1d4a3bfa
JDA
332#if defined HAVE_GAS_WEAK
333#define ASM_WEAKEN_DECL(FILE,DECL,NAME,VALUE) \
334 do \
335 { \
336 if ((VALUE) != NULL) \
337 error_at (DECL_SOURCE_LOCATION (DECL), \
338 "weak aliases are not supported"); \
339 fputs ("\t.weak\t", FILE); \
340 assemble_name (FILE, NAME); \
341 fputc ('\n', FILE); \
342 \
343 /* Import external objects. */ \
344 if (DECL_EXTERNAL (DECL)) \
345 { \
346 fputs ("\t.IMPORT ", FILE); \
347 assemble_name (FILE, NAME); \
348 if (TREE_CODE (DECL) == FUNCTION_DECL) \
349 fputs (",CODE\n", FILE); \
350 else \
351 fputs (",DATA\n", FILE); \
352 } \
353 /* Functions are globalized by ASM_DECLARE_FUNCTION_NAME. */ \
354 else if (TREE_CODE (DECL) != FUNCTION_DECL) \
355 { \
356 fputs ("\t.EXPORT ", FILE); \
357 assemble_name (FILE, NAME); \
358 fputs (",DATA\n", FILE); \
359 } \
360 } \
361 while (0)
362#endif
363
364/* Although gas accepts .weakref, it doesn't provide the correct symbol
365 type for function references. For now, we use ASM_WEAKEN_DECL instead.
366 We have to undefine HAVE_GAS_WEAKREF to prevent default.h from defining
367 ASM_OUTPUT_WEAKREF. */
368#undef HAVE_GAS_WEAKREF
4af6a063
JDA
369
370/* We can't handle weak aliases, and therefore can't support pragma weak.
371 Suppress the use of pragma weak in gthr-dce.h and gthr-posix.h. */
372#define GTHREAD_USE_WEAK 0
881466d8
JDA
373
374/* Shared library suffix. Collect2 strips the version string after
375 this suffix when generating constructor/destructor names. */
376#define SHLIB_SUFFIX ".sl"
41dfca87 377
9621d524 378/* We don't have named sections. */
41dfca87 379#define TARGET_HAVE_NAMED_SECTIONS false
57d138a9
JDA
380
381#define TARGET_ASM_TM_CLONE_TABLE_SECTION pa_som_tm_clone_table_section
9621d524
JDA
382
383/* Generate specially named labels to identify DWARF 2 frame unwind
384 information. */
385#define EH_FRAME_THROUGH_COLLECT2