1 /* Definitions for SOM assembler support.
2 Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005 Free Software Foundation,
5 This file is part of GCC.
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 2, or (at your option)
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.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
22 /* So we can conditionalize small amounts of code in pa.c or pa.md. */
26 /* We do not use BINCL stabs in SOM.
27 ??? If it does not hurt, we probably should to avoid useless divergence
28 from other embedded stabs implementations. */
31 #define DBX_LINES_FUNCTION_RELATIVE 1
33 /* gdb needs a null N_SO at the end of each file for scattered loading. */
35 #define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
37 /* Select a format to encode pointers in exception handling data. CODE
38 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
39 true if the symbol may be affected by dynamic relocations. Because
40 the HP assembler does auto alignment, it is necessary to use
41 DW_EH_PE_aligned instead of the default DW_EH_PE_absptr. */
43 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
44 (TARGET_GAS ? DW_EH_PE_absptr : DW_EH_PE_aligned)
46 /* HPUX has a program 'chatr' to list the dependencies of dynamically
47 linked executables and shared libraries. */
48 #define LDD_SUFFIX "chatr"
49 /* Look for lines like "dynamic /usr/lib/X11R5/libX11.sl"
50 or "static /usr/lib/X11R5/libX11.sl".
52 HPUX 10.20 also has lines like "static branch prediction ..."
53 so we filter that out explicitly.
55 We also try to bound our search for libraries with marker
56 lines. What a pain. */
57 #define PARSE_LDD_OUTPUT(PTR) \
59 static int in_shlib_list = 0; \
60 while (*PTR == ' ') PTR++; \
61 if (strncmp (PTR, "shared library list:", \
62 sizeof ("shared library list:") - 1) == 0) \
67 else if (strncmp (PTR, "shared library binding:", \
68 sizeof ("shared library binding:") - 1) == 0)\
73 else if (strncmp (PTR, "static branch prediction disabled", \
74 sizeof ("static branch prediction disabled") - 1) == 0)\
79 else if (in_shlib_list \
80 && strncmp (PTR, "dynamic", sizeof ("dynamic") - 1) == 0) \
82 PTR += sizeof ("dynamic") - 1; \
83 while (*p == ' ') PTR++; \
85 else if (in_shlib_list \
86 && strncmp (PTR, "static", sizeof ("static") - 1) == 0) \
88 PTR += sizeof ("static") - 1; \
89 while (*p == ' ') PTR++; \
95 /* Output the label for a function definition. */
96 #ifndef HP_FP_ARG_DESCRIPTOR_REVERSED
97 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
98 do { fprintf (FILE, ",ARGW%d=FR", (ARG0)); \
99 fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0)
100 #define DFMODE_RETURN_STRING ",RTNVAL=FU"
101 #define SFMODE_RETURN_STRING ",RTNVAL=FR"
103 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
104 do { fprintf (FILE, ",ARGW%d=FU", (ARG0)); \
105 fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0)
106 #define DFMODE_RETURN_STRING ",RTNVAL=FR"
107 #define SFMODE_RETURN_STRING ",RTNVAL=FU"
111 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
112 do { tree fntype = TREE_TYPE (TREE_TYPE (DECL)); \
113 tree tree_type = TREE_TYPE (DECL); \
116 if (TREE_PUBLIC (DECL) || TARGET_GAS) \
118 if (TREE_PUBLIC (DECL)) \
120 fputs ("\t.EXPORT ", FILE); \
121 assemble_name (FILE, NAME); \
122 fputs (",ENTRY,PRIV_LEV=3", FILE); \
126 fputs ("\t.PARAM ", FILE); \
127 assemble_name (FILE, NAME); \
128 fputs (",PRIV_LEV=3", FILE); \
130 for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4; \
131 parm = TREE_CHAIN (parm)) \
133 if (TYPE_MODE (DECL_ARG_TYPE (parm)) == SFmode \
134 && ! TARGET_SOFT_FLOAT) \
135 fprintf (FILE, ",ARGW%d=FR", i++); \
136 else if (TYPE_MODE (DECL_ARG_TYPE (parm)) == DFmode \
137 && ! TARGET_SOFT_FLOAT) \
142 ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++); \
150 FUNCTION_ARG_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm)),\
151 DECL_ARG_TYPE (parm)); \
152 /* Passing structs by invisible reference uses \
153 one general register. */ \
155 || TREE_ADDRESSABLE (DECL_ARG_TYPE (parm))) \
157 if (arg_size == 2 && i <= 2) \
160 fprintf (FILE, ",ARGW%d=GR", i++); \
161 fprintf (FILE, ",ARGW%d=GR", i++); \
163 else if (arg_size == 1) \
164 fprintf (FILE, ",ARGW%d=GR", i++); \
169 /* anonymous args */ \
170 if (TYPE_ARG_TYPES (tree_type) != 0 \
171 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (tree_type)))\
172 != void_type_node)) \
175 fprintf (FILE, ",ARGW%d=GR", i); \
177 if (TYPE_MODE (fntype) == DFmode && ! TARGET_SOFT_FLOAT) \
178 fputs (DFMODE_RETURN_STRING, FILE); \
179 else if (TYPE_MODE (fntype) == SFmode && ! TARGET_SOFT_FLOAT) \
180 fputs (SFMODE_RETURN_STRING, FILE); \
181 else if (fntype != void_type_node) \
182 fputs (",RTNVAL=GR", FILE); \
183 fputs ("\n", FILE); \
186 #define TARGET_ASM_FILE_START pa_som_file_start
188 /* String to output before text. */
189 #define TEXT_SECTION_ASM_OP som_text_section_asm_op ()
191 /* String to output before writable data. */
192 #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
194 /* String to output before uninitialized data. */
195 #define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
197 /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups
198 which reference data within the $TEXT$ space (for example constant
199 strings in the $LIT$ subspace).
201 The assemblers (GAS and HP as) both have problems with handling
202 the difference of two symbols which is the other correct way to
203 reference constant data during PIC code generation.
205 So, there's no way to reference constant data which is in the
206 $TEXT$ space during PIC generation. Instead place all constant
207 data into the $PRIVATE$ subspace (this reduces sharing, but it
209 #define READONLY_DATA_SECTION \
210 (flag_pic ? data_section : som_readonly_data_section)
212 /* We must not have a reference to an external symbol defined in a
213 shared library in a readonly section, else the SOM linker will
216 So, we force exception information into the data section. */
217 #define TARGET_ASM_EXCEPTION_SECTION data_section
219 /* This is how to output a command to make the user-level label
220 named NAME defined for reference from other files. We use
221 assemble_name_raw instead of assemble_name since a symbol in
222 a .IMPORT directive that isn't otherwise referenced is not
223 placed in the symbol table of the assembled object.
225 Failure to import a function reference can cause the HP linker
226 to segmentation fault!
228 Note that the SOM based tools need the symbol imported as a
229 CODE symbol, while the ELF based tools require the symbol to
230 be imported as an ENTRY symbol. */
232 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
233 do { fputs ("\t.IMPORT ", FILE); \
234 assemble_name_raw (FILE, NAME); \
235 if (FUNCTION_NAME_P (NAME)) \
236 fputs (",CODE\n", FILE); \
238 fputs (",DATA\n", FILE); \
241 /* The bogus HP assembler requires ALL external references to be
242 "imported", even library calls. They look a bit different, so
245 Also note not all libcall names are passed to pa_encode_section_info
246 (__main for example). To make sure all libcall names have section
247 info recorded in them, we do it here. We must also ensure that
248 we don't import a libcall that has been previously exported since
249 the HP assembler may change an ENTRY symbol to a CODE symbol. */
251 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
252 do { const char *name; \
255 if (!function_label_operand (RTL, VOIDmode)) \
256 hppa_encode_label (RTL); \
258 name = targetm.strip_name_encoding (XSTR ((RTL), 0)); \
259 id = maybe_get_identifier (name); \
260 if (!id || !TREE_SYMBOL_REFERENCED (id)) \
262 fputs ("\t.IMPORT ", FILE); \
263 assemble_name (FILE, XSTR ((RTL), 0)); \
264 fputs (",CODE\n", FILE); \
268 /* We want __gcc_plt_call to appear in every program built by
269 gcc, so we make a reference to it out of __main.
270 We use the asm statement to fool the optimizer into not
271 removing the dead (but important) initialization of
274 #define DO_GLOBAL_DTORS_BODY \
276 extern void __gcc_plt_call (void); \
277 void (*reference)(void) = &__gcc_plt_call; \
279 __asm__ ("" : : "r" (reference)); \
280 for (p = __DTOR_LIST__ + 1; *p; ) \
284 /* This macro specifies the biggest alignment supported by the object
285 file format of this machine.
287 The .align directive in the HP assembler allows alignments up to 4096
288 bytes. However, the maximum alignment of a global common symbol is 8
289 bytes for objects smaller than the page size (4096 bytes). For larger
290 objects, the linker provides an alignment of 32 bytes. Unfortunately,
291 this macro doesn't provide a mechanism to test for common symbols. */
292 #define MAX_OFILE_ALIGNMENT 32768
294 /* The SOM linker hardcodes paths into binaries. As a result, dotdots
295 must be removed from library prefixes to prevent binaries from depending
296 on the location of the GCC tool directory. The downside is GCC
297 cannot be moved after installation using a symlink. */
298 #define ALWAYS_STRIP_DOTDOT 1
300 /* Aggregates with a single float or double field should be passed and
301 returned in the general registers. */
302 #define MEMBER_TYPE_FORCES_BLK(FIELD, MODE) (MODE==SFmode || MODE==DFmode)
304 /* If GAS supports weak, we can support weak when we have working linker
305 support for secondary definitions and are generating code for GAS. */
307 #define SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
309 #define SUPPORTS_WEAK 0
312 /* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa
313 directive. This provides one-only linkage semantics even though we
314 don't have weak support. */
315 #ifdef HAVE_GAS_NSUBSPA_COMDAT
316 #define SUPPORTS_SOM_COMDAT (TARGET_GAS)
318 #define SUPPORTS_SOM_COMDAT 0
321 /* We can support one only if we support weak or comdat. */
322 #define SUPPORTS_ONE_ONLY (SUPPORTS_WEAK || SUPPORTS_SOM_COMDAT)
324 /* We use DECL_COMMON for uninitialized one-only variables as we don't
325 have linkonce .bss. We use SOM secondary definitions or comdat for
326 initialized variables and functions. */
327 #define MAKE_DECL_ONE_ONLY(DECL) \
329 if (TREE_CODE (DECL) == VAR_DECL \
330 && (DECL_INITIAL (DECL) == 0 \
331 || DECL_INITIAL (DECL) == error_mark_node)) \
332 DECL_COMMON (DECL) = 1; \
333 else if (SUPPORTS_WEAK) \
334 DECL_WEAK (DECL) = 1; \
337 /* This is how we tell the assembler that a symbol is weak. The SOM
338 weak implementation uses the secondary definition (sdef) flag.
340 The behavior of sdef symbols is similar to ELF weak symbols in that
341 multiple definitions can occur without incurring a link error.
342 However, they differ in the following ways:
343 1) Undefined sdef symbols are not allowed.
344 2) The linker searches for undefined sdef symbols and will load an
345 archive library member to resolve an undefined sdef symbol.
346 3) The exported symbol from a shared library is a primary symbol
347 rather than a sdef symbol. Thus, more care is needed in the
348 ordering of libraries.
350 It appears that the linker discards extra copies of "weak" functions
351 when linking shared libraries, independent of whether or not they
352 are in their own section. In linking final executables, -Wl,-O can
353 be used to remove dead procedures. Thus, support for named sections
354 is not needed and in previous testing caused problems with various
356 #define ASM_WEAKEN_LABEL(FILE,NAME) \
357 do { fputs ("\t.weak\t", FILE); \
358 assemble_name (FILE, NAME); \
359 fputc ('\n', FILE); \
360 if (! FUNCTION_NAME_P (NAME)) \
362 fputs ("\t.EXPORT ", FILE); \
363 assemble_name (FILE, NAME); \
364 fputs (",DATA\n", FILE); \
368 /* We can't handle weak aliases, and therefore can't support pragma weak.
369 Suppress the use of pragma weak in gthr-dce.h and gthr-posix.h. */
370 #define GTHREAD_USE_WEAK 0