1 /* Definitions for SOM assembler support.
2 Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GCC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* So we can conditionalize small amounts of code in pa.c or pa.md. */
25 /* We do not use BINCL stabs in SOM.
26 ??? If it does not hurt, we probably should to avoid useless divergence
27 from other embedded stabs implementations. */
30 #define DBX_LINES_FUNCTION_RELATIVE 1
32 /* gdb needs a null N_SO at the end of each file for scattered loading. */
34 #define DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
36 /* Select a format to encode pointers in exception handling data. CODE
37 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
38 true if the symbol may be affected by dynamic relocations. Because
39 the HP assembler does auto alignment, it is necessary to use
40 DW_EH_PE_aligned instead of the default DW_EH_PE_absptr. */
42 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
43 (TARGET_GAS ? DW_EH_PE_absptr : DW_EH_PE_aligned)
45 /* HPUX has a program 'chatr' to list the dependencies of dynamically
46 linked executables and shared libraries. */
47 #define LDD_SUFFIX "chatr"
48 /* Look for lines like "dynamic /usr/lib/X11R5/libX11.sl"
49 or "static /usr/lib/X11R5/libX11.sl".
51 HPUX 10.20 also has lines like "static branch prediction ..."
52 so we filter that out explicitly.
54 We also try to bound our search for libraries with marker
55 lines. What a pain. */
56 #define PARSE_LDD_OUTPUT(PTR) \
58 static int in_shlib_list = 0; \
59 while (*PTR == ' ') PTR++; \
60 if (strncmp (PTR, "shared library list:", \
61 sizeof ("shared library list:") - 1) == 0) \
66 else if (strncmp (PTR, "shared library binding:", \
67 sizeof ("shared library binding:") - 1) == 0)\
72 else if (strncmp (PTR, "static branch prediction disabled", \
73 sizeof ("static branch prediction disabled") - 1) == 0)\
78 else if (in_shlib_list \
79 && strncmp (PTR, "dynamic", sizeof ("dynamic") - 1) == 0) \
81 PTR += sizeof ("dynamic") - 1; \
82 while (*p == ' ') PTR++; \
84 else if (in_shlib_list \
85 && strncmp (PTR, "static", sizeof ("static") - 1) == 0) \
87 PTR += sizeof ("static") - 1; \
88 while (*p == ' ') PTR++; \
94 /* Output the label for a function definition. */
95 #ifndef HP_FP_ARG_DESCRIPTOR_REVERSED
96 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
97 do { fprintf (FILE, ",ARGW%d=FR", (ARG0)); \
98 fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0)
99 #define DFMODE_RETURN_STRING ",RTNVAL=FU"
100 #define SFMODE_RETURN_STRING ",RTNVAL=FR"
102 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
103 do { fprintf (FILE, ",ARGW%d=FU", (ARG0)); \
104 fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0)
105 #define DFMODE_RETURN_STRING ",RTNVAL=FR"
106 #define SFMODE_RETURN_STRING ",RTNVAL=FU"
110 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
111 do { tree fntype = TREE_TYPE (TREE_TYPE (DECL)); \
112 tree tree_type = TREE_TYPE (DECL); \
115 if (TREE_PUBLIC (DECL) || TARGET_GAS) \
117 if (TREE_PUBLIC (DECL)) \
119 fputs ("\t.EXPORT ", FILE); \
120 assemble_name (FILE, NAME); \
121 fputs (",ENTRY,PRIV_LEV=3", FILE); \
125 fputs ("\t.PARAM ", FILE); \
126 assemble_name (FILE, NAME); \
127 fputs (",PRIV_LEV=3", FILE); \
129 for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4; \
130 parm = TREE_CHAIN (parm)) \
132 if (TYPE_MODE (DECL_ARG_TYPE (parm)) == SFmode \
133 && ! TARGET_SOFT_FLOAT) \
134 fprintf (FILE, ",ARGW%d=FR", i++); \
135 else if (TYPE_MODE (DECL_ARG_TYPE (parm)) == DFmode \
136 && ! TARGET_SOFT_FLOAT) \
141 ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++); \
149 FUNCTION_ARG_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm)),\
150 DECL_ARG_TYPE (parm)); \
151 /* Passing structs by invisible reference uses \
152 one general register. */ \
154 || TREE_ADDRESSABLE (DECL_ARG_TYPE (parm))) \
156 if (arg_size == 2 && i <= 2) \
159 fprintf (FILE, ",ARGW%d=GR", i++); \
160 fprintf (FILE, ",ARGW%d=GR", i++); \
162 else if (arg_size == 1) \
163 fprintf (FILE, ",ARGW%d=GR", i++); \
168 /* anonymous args */ \
169 if (TYPE_ARG_TYPES (tree_type) != 0 \
170 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (tree_type)))\
171 != void_type_node)) \
174 fprintf (FILE, ",ARGW%d=GR", i); \
176 if (TYPE_MODE (fntype) == DFmode && ! TARGET_SOFT_FLOAT) \
177 fputs (DFMODE_RETURN_STRING, FILE); \
178 else if (TYPE_MODE (fntype) == SFmode && ! TARGET_SOFT_FLOAT) \
179 fputs (SFMODE_RETURN_STRING, FILE); \
180 else if (fntype != void_type_node) \
181 fputs (",RTNVAL=GR", FILE); \
182 fputs ("\n", FILE); \
185 #define TARGET_ASM_FILE_START pa_som_file_start
187 /* String to output before text. */
188 #define TEXT_SECTION_ASM_OP som_text_section_asm_op ()
190 /* String to output before writable data. */
191 #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
193 /* String to output before uninitialized data. */
194 #define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
196 /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups
197 which reference data within the $TEXT$ space (for example constant
198 strings in the $LIT$ subspace).
200 The assemblers (GAS and HP as) both have problems with handling
201 the difference of two symbols which is the other correct way to
202 reference constant data during PIC code generation.
204 So, there's no way to reference constant data which is in the
205 $TEXT$ space during PIC generation. Instead place all constant
206 data into the $PRIVATE$ subspace (this reduces sharing, but it
208 #define READONLY_DATA_SECTION \
209 (flag_pic ? data_section : som_readonly_data_section)
211 /* We must not have a reference to an external symbol defined in a
212 shared library in a readonly section, else the SOM linker will
215 So, we force exception information into the data section. */
216 #define TARGET_ASM_EXCEPTION_SECTION data_section
218 /* This is how to output a command to make the user-level label named NAME
219 defined for reference from other files.
221 We call assemble_name, which in turn sets TREE_SYMBOL_REFERENCED. This
222 macro will restore the original value of TREE_SYMBOL_REFERENCED to avoid
223 placing useless function definitions in the output file.
225 Also note that the SOM based tools need the symbol imported as a CODE
226 symbol, while the ELF based tools require the symbol to be imported as
227 an ENTRY symbol. What a crock. */
229 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
230 do { int save_referenced; \
231 save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)); \
232 fputs ("\t.IMPORT ", FILE); \
233 assemble_name (FILE, NAME); \
234 if (FUNCTION_NAME_P (NAME)) \
235 fputs (",CODE\n", FILE); \
237 fputs (",DATA\n", FILE); \
238 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced; \
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. */
291 #define MAX_OFILE_ALIGNMENT \
292 (TREE_PUBLIC (decl) && DECL_COMMON (decl) \
293 ? (host_integerp (DECL_SIZE_UNIT (decl), 1) >= 4096 ? 256 : 64) \
296 /* The SOM linker hardcodes paths into binaries. As a result, dotdots
297 must be removed from library prefixes to prevent binaries from depending
298 on the location of the GCC tool directory. The downside is GCC
299 cannot be moved after installation using a symlink. */
300 #define ALWAYS_STRIP_DOTDOT 1
302 /* Aggregates with a single float or double field should be passed and
303 returned in the general registers. */
304 #define MEMBER_TYPE_FORCES_BLK(FIELD, MODE) (MODE==SFmode || MODE==DFmode)
306 /* If GAS supports weak, we can support weak when we have working linker
307 support for secondary definitions and are generating code for GAS. */
309 #define SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
311 #define SUPPORTS_WEAK 0
314 /* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa
315 directive. This provides one-only linkage semantics even though we
316 don't have weak support. */
317 #ifdef HAVE_GAS_NSUBSPA_COMDAT
318 #define SUPPORTS_SOM_COMDAT (TARGET_GAS)
320 #define SUPPORTS_SOM_COMDAT 0
323 /* We can support one only if we support weak or comdat. */
324 #define SUPPORTS_ONE_ONLY (SUPPORTS_WEAK || SUPPORTS_SOM_COMDAT)
326 /* We use DECL_COMMON for uninitialized one-only variables as we don't
327 have linkonce .bss. We use SOM secondary definitions or comdat for
328 initialized variables and functions. */
329 #define MAKE_DECL_ONE_ONLY(DECL) \
331 if (TREE_CODE (DECL) == VAR_DECL \
332 && (DECL_INITIAL (DECL) == 0 \
333 || DECL_INITIAL (DECL) == error_mark_node)) \
334 DECL_COMMON (DECL) = 1; \
335 else if (SUPPORTS_WEAK) \
336 DECL_WEAK (DECL) = 1; \
339 /* This is how we tell the assembler that a symbol is weak. The SOM
340 weak implementation uses the secondary definition (sdef) flag.
342 The behavior of sdef symbols is similar to ELF weak symbols in that
343 multiple definitions can occur without incurring a link error.
344 However, they differ in the following ways:
345 1) Undefined sdef symbols are not allowed.
346 2) The linker searches for undefined sdef symbols and will load an
347 archive library member to resolve an undefined sdef symbol.
348 3) The exported symbol from a shared library is a primary symbol
349 rather than a sdef symbol. Thus, more care is needed in the
350 ordering of libraries.
352 It appears that the linker discards extra copies of "weak" functions
353 when linking shared libraries, independent of whether or not they
354 are in their own section. In linking final executables, -Wl,-O can
355 be used to remove dead procedures. Thus, support for named sections
356 is not needed and in previous testing caused problems with various
358 #define ASM_WEAKEN_LABEL(FILE,NAME) \
359 do { fputs ("\t.weak\t", FILE); \
360 assemble_name (FILE, NAME); \
361 fputc ('\n', FILE); \
362 if (! FUNCTION_NAME_P (NAME)) \
364 fputs ("\t.EXPORT ", FILE); \
365 assemble_name (FILE, NAME); \
366 fputs (",DATA\n", FILE); \
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