]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/config/pa/som.h
dbxout.c (dbxout_source_line_counter): New global variable.
[thirdparty/gcc.git] / gcc / config / pa / som.h
1 /* Definitions for SOM assembler support.
2 Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
3
4 This file is part of GNU CC.
5
6 GNU CC 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)
9 any later version.
10
11 GNU CC 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.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 /* So we can conditionalize small amounts of code in pa.c or pa.md. */
22 #undef TARGET_SOM
23 #define TARGET_SOM 1
24
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. */
28 #undef DBX_USE_BINCL
29
30 /* We make the first line stab special to avoid adding several
31 gross hacks to GAS. */
32 #undef ASM_OUTPUT_SOURCE_LINE
33 #define ASM_OUTPUT_SOURCE_LINE(file, line, counter) \
34 { static tree last_function_decl = NULL; \
35 if (current_function_decl == last_function_decl) \
36 fprintf (file, "\t.stabn 68,0,%d,L$M%d-%s\nL$M%d:\n", \
37 line, counter, \
38 XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0) + 1, \
39 counter); \
40 else \
41 fprintf (file, "\t.stabn 68,0,%d,0\n", line); \
42 last_function_decl = current_function_decl; \
43 }
44
45 /* gdb needs a null N_SO at the end of each file for scattered loading. */
46
47 #undef DBX_OUTPUT_MAIN_SOURCE_FILE_END
48 #define DBX_OUTPUT_MAIN_SOURCE_FILE_END(FILE, FILENAME) \
49 text_section (); \
50 fputs ("\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \
51 fprintf (FILE, \
52 "\t.stabs \"\",%d,0,0,L$text_end0000\nL$text_end0000:\n", N_SO)
53
54 /* Select a format to encode pointers in exception handling data. CODE
55 is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is
56 true if the symbol may be affected by dynamic relocations. Because
57 the HP assembler does auto alignment, it is necessary to use
58 DW_EH_PE_aligned instead of the default DW_EH_PE_absptr. */
59
60 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \
61 (TARGET_GAS ? DW_EH_PE_absptr : DW_EH_PE_aligned)
62
63 /* HPUX has a program 'chatr' to list the dependencies of dynamically
64 linked executables and shared libraries. */
65 #define LDD_SUFFIX "chatr"
66 /* Look for lines like "dynamic /usr/lib/X11R5/libX11.sl"
67 or "static /usr/lib/X11R5/libX11.sl".
68
69 HPUX 10.20 also has lines like "static branch prediction ..."
70 so we filter that out explicitly.
71
72 We also try to bound our search for libraries with marker
73 lines. What a pain. */
74 #define PARSE_LDD_OUTPUT(PTR) \
75 do { \
76 static int in_shlib_list = 0; \
77 while (*PTR == ' ') PTR++; \
78 if (strncmp (PTR, "shared library list:", \
79 sizeof ("shared library list:") - 1) == 0) \
80 { \
81 PTR = 0; \
82 in_shlib_list = 1; \
83 } \
84 else if (strncmp (PTR, "shared library binding:", \
85 sizeof ("shared library binding:") - 1) == 0)\
86 { \
87 PTR = 0; \
88 in_shlib_list = 0; \
89 } \
90 else if (strncmp (PTR, "static branch prediction disabled", \
91 sizeof ("static branch prediction disabled") - 1) == 0)\
92 { \
93 PTR = 0; \
94 in_shlib_list = 0; \
95 } \
96 else if (in_shlib_list \
97 && strncmp (PTR, "dynamic", sizeof ("dynamic") - 1) == 0) \
98 { \
99 PTR += sizeof ("dynamic") - 1; \
100 while (*p == ' ') PTR++; \
101 } \
102 else if (in_shlib_list \
103 && strncmp (PTR, "static", sizeof ("static") - 1) == 0) \
104 { \
105 PTR += sizeof ("static") - 1; \
106 while (*p == ' ') PTR++; \
107 } \
108 else \
109 PTR = 0; \
110 } while (0)
111
112 /* Output the label for a function definition. */
113 #ifndef HP_FP_ARG_DESCRIPTOR_REVERSED
114 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
115 do { fprintf (FILE, ",ARGW%d=FR", (ARG0)); \
116 fprintf (FILE, ",ARGW%d=FU", (ARG1));} while (0)
117 #define DFMODE_RETURN_STRING ",RTNVAL=FU"
118 #define SFMODE_RETURN_STRING ",RTNVAL=FR"
119 #else
120 #define ASM_DOUBLE_ARG_DESCRIPTORS(FILE, ARG0, ARG1) \
121 do { fprintf (FILE, ",ARGW%d=FU", (ARG0)); \
122 fprintf (FILE, ",ARGW%d=FR", (ARG1));} while (0)
123 #define DFMODE_RETURN_STRING ",RTNVAL=FR"
124 #define SFMODE_RETURN_STRING ",RTNVAL=FU"
125 #endif
126
127 \f
128 /* NAME refers to the function's name. If we are placing each function into
129 its own section, we need to switch to the section for this function. Note
130 that the section name will have a "." prefix. */
131 #define ASM_OUTPUT_FUNCTION_PREFIX(FILE, NAME) \
132 { \
133 const char *name = (*targetm.strip_name_encoding) (NAME); \
134 if (TARGET_GAS && in_section == in_text) \
135 fputs ("\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \
136 else if (TARGET_GAS) \
137 fprintf (FILE, \
138 "\t.SUBSPA .%s\n", name); \
139 }
140
141 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
142 do { tree fntype = TREE_TYPE (TREE_TYPE (DECL)); \
143 tree tree_type = TREE_TYPE (DECL); \
144 tree parm; \
145 int i; \
146 if (TREE_PUBLIC (DECL) || TARGET_GAS) \
147 { \
148 if (TREE_PUBLIC (DECL)) \
149 { \
150 fputs ("\t.EXPORT ", FILE); \
151 assemble_name (FILE, NAME); \
152 fputs (",ENTRY,PRIV_LEV=3", FILE); \
153 } \
154 else \
155 { \
156 fputs ("\t.PARAM ", FILE); \
157 assemble_name (FILE, NAME); \
158 fputs (",PRIV_LEV=3", FILE); \
159 } \
160 for (parm = DECL_ARGUMENTS (DECL), i = 0; parm && i < 4; \
161 parm = TREE_CHAIN (parm)) \
162 { \
163 if (TYPE_MODE (DECL_ARG_TYPE (parm)) == SFmode \
164 && ! TARGET_SOFT_FLOAT) \
165 fprintf (FILE, ",ARGW%d=FR", i++); \
166 else if (TYPE_MODE (DECL_ARG_TYPE (parm)) == DFmode \
167 && ! TARGET_SOFT_FLOAT) \
168 { \
169 if (i <= 2) \
170 { \
171 if (i == 1) i++; \
172 ASM_DOUBLE_ARG_DESCRIPTORS (FILE, i++, i++); \
173 } \
174 else \
175 break; \
176 } \
177 else \
178 { \
179 int arg_size = \
180 FUNCTION_ARG_SIZE (TYPE_MODE (DECL_ARG_TYPE (parm)),\
181 DECL_ARG_TYPE (parm)); \
182 /* Passing structs by invisible reference uses \
183 one general register. */ \
184 if (arg_size > 2 \
185 || TREE_ADDRESSABLE (DECL_ARG_TYPE (parm))) \
186 arg_size = 1; \
187 if (arg_size == 2 && i <= 2) \
188 { \
189 if (i == 1) i++; \
190 fprintf (FILE, ",ARGW%d=GR", i++); \
191 fprintf (FILE, ",ARGW%d=GR", i++); \
192 } \
193 else if (arg_size == 1) \
194 fprintf (FILE, ",ARGW%d=GR", i++); \
195 else \
196 i += arg_size; \
197 } \
198 } \
199 /* anonymous args */ \
200 if (TYPE_ARG_TYPES (tree_type) != 0 \
201 && (TREE_VALUE (tree_last (TYPE_ARG_TYPES (tree_type)))\
202 != void_type_node)) \
203 { \
204 for (; i < 4; i++) \
205 fprintf (FILE, ",ARGW%d=GR", i); \
206 } \
207 if (TYPE_MODE (fntype) == DFmode && ! TARGET_SOFT_FLOAT) \
208 fputs (DFMODE_RETURN_STRING, FILE); \
209 else if (TYPE_MODE (fntype) == SFmode && ! TARGET_SOFT_FLOAT) \
210 fputs (SFMODE_RETURN_STRING, FILE); \
211 else if (fntype != void_type_node) \
212 fputs (",RTNVAL=GR", FILE); \
213 fputs ("\n", FILE); \
214 }} while (0)
215
216 /* Output at beginning of assembler file. */
217
218 #define ASM_FILE_START(FILE) \
219 do { \
220 if (TARGET_PA_20) \
221 fputs("\t.LEVEL 2.0\n", FILE); \
222 else if (TARGET_PA_11) \
223 fputs("\t.LEVEL 1.1\n", FILE); \
224 else \
225 fputs("\t.LEVEL 1.0\n", FILE); \
226 fputs ("\t.SPACE $PRIVATE$\n\
227 \t.SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31\n\
228 \t.SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82\n\
229 \t.SPACE $TEXT$\n\
230 \t.SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44\n\
231 \t.SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n\
232 \t.IMPORT $global$,DATA\n\
233 \t.IMPORT $$dyncall,MILLICODE\n", FILE);\
234 if (profile_flag)\
235 fprintf (FILE, "\t.IMPORT _mcount, CODE\n");\
236 if (write_symbols != NO_DEBUG) \
237 output_file_directive ((FILE), main_input_filename); \
238 } while (0)
239
240 /* Output before code. */
241
242 /* Supposedly the assembler rejects the command if there is no tab! */
243 #define TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $CODE$\n"
244
245 /* Output before read-only data. */
246
247 /* Supposedly the assembler rejects the command if there is no tab! */
248 #define READONLY_DATA_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $LIT$\n"
249
250 #define EXTRA_SECTIONS in_readonly_data
251
252 #define EXTRA_SECTION_FUNCTIONS \
253 extern void readonly_data PARAMS ((void)); \
254 void \
255 readonly_data () \
256 { \
257 if (in_section != in_readonly_data) \
258 { \
259 in_section = in_readonly_data; \
260 fprintf (asm_out_file, "%s\n", READONLY_DATA_ASM_OP); \
261 } \
262 }
263
264 /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups
265 which reference data within the $TEXT$ space (for example constant
266 strings in the $LIT$ subspace).
267
268 The assemblers (GAS and HP as) both have problems with handling
269 the difference of two symbols which is the other correct way to
270 reference constant data during PIC code generation.
271
272 So, there's no way to reference constant data which is in the
273 $TEXT$ space during PIC generation. Instead place all constant
274 data into the $PRIVATE$ subspace (this reduces sharing, but it
275 works correctly). */
276
277 #define READONLY_DATA_SECTION (flag_pic ? data_section : readonly_data)
278
279 /* Output before writable data. */
280
281 /* Supposedly the assembler rejects the command if there is no tab! */
282 #define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
283
284 /* Output before uninitialized data. */
285
286 #define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
287
288 /* We must not have a reference to an external symbol defined in a
289 shared library in a readonly section, else the SOM linker will
290 complain.
291
292 So, we force exception information into the data section. */
293 #define TARGET_ASM_EXCEPTION_SECTION data_section
294
295 /* This is how to output a command to make the user-level label named NAME
296 defined for reference from other files.
297
298 We call assemble_name, which in turn sets TREE_SYMBOL_REFERENCED. This
299 macro will restore the original value of TREE_SYMBOL_REFERENCED to avoid
300 placing useless function definitions in the output file.
301
302 Also note that the SOM based tools need the symbol imported as a CODE
303 symbol, while the ELF based tools require the symbol to be imported as
304 an ENTRY symbol. What a crock. */
305
306 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
307 do { int save_referenced; \
308 save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)); \
309 fputs ("\t.IMPORT ", FILE); \
310 assemble_name (FILE, NAME); \
311 if (FUNCTION_NAME_P (NAME)) \
312 fputs (",CODE\n", FILE); \
313 else \
314 fputs (",DATA\n", FILE); \
315 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced; \
316 } while (0)
317
318 /* The bogus HP assembler requires ALL external references to be
319 "imported", even library calls. They look a bit different, so
320 here's this macro.
321
322 Also note not all libcall names are passed to pa_encode_section_info
323 (__main for example). To make sure all libcall names have section
324 info recorded in them, we do it here. We must also ensure that
325 we don't import a libcall that has been previously exported since
326 the HP assembler may change an ENTRY symbol to a CODE symbol. */
327
328 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, RTL) \
329 do { const char *name; \
330 tree id; \
331 \
332 if (!function_label_operand (RTL, VOIDmode)) \
333 hppa_encode_label (RTL); \
334 \
335 name = (*targetm.strip_name_encoding) (XSTR ((RTL), 0)); \
336 id = maybe_get_identifier (name); \
337 if (! id || ! TREE_SYMBOL_REFERENCED (id)) \
338 { \
339 fputs ("\t.IMPORT ", FILE); \
340 assemble_name (FILE, XSTR ((RTL), 0)); \
341 fputs (",CODE\n", FILE); \
342 } \
343 } while (0)
344
345 /* We want __gcc_plt_call to appear in every program built by
346 gcc, so we make a reference to it out of __main.
347 We use the asm statement to fool the optimizer into not
348 removing the dead (but important) initialization of
349 REFERENCE. */
350
351 #define DO_GLOBAL_DTORS_BODY \
352 do { \
353 extern void __gcc_plt_call (); \
354 void (*reference)() = &__gcc_plt_call; \
355 func_ptr *p; \
356 __asm__ ("" : : "r" (reference)); \
357 for (p = __DTOR_LIST__ + 1; *p; ) \
358 (*p++) (); \
359 } while (0)
360
361 /* The .align directive in the HP assembler allows up to a 32 alignment. */
362 #define MAX_OFILE_ALIGNMENT 32768
363
364 /* The SOM linker hardcodes paths into binaries. As a result, dotdots
365 must be removed from library prefixes to prevent binaries from depending
366 on the location of the GCC tool directory. The downside is GCC
367 cannot be moved after installation using a symlink. */
368 #define ALWAYS_STRIP_DOTDOT 1
369
370 /* Aggregates with a single float or double field should be passed and
371 returned in the general registers. */
372 #define MEMBER_TYPE_FORCES_BLK(FIELD, MODE) (MODE==SFmode || MODE==DFmode)
373
374 /* If GAS supports weak, we can support weak when we have working linker
375 support for secondary definitions and are generating code for GAS. */
376 #ifdef HAVE_GAS_WEAK
377 #define SUPPORTS_WEAK (TARGET_SOM_SDEF && TARGET_GAS)
378 #else
379 #define SUPPORTS_WEAK 0
380 #endif
381
382 /* We can support one only if we support weak. */
383 #define SUPPORTS_ONE_ONLY SUPPORTS_WEAK
384
385 /* Use weak (secondary definitions) to make one only declarations. */
386 #define MAKE_DECL_ONE_ONLY(DECL) (DECL_WEAK (DECL) = 1)
387
388 /* This is how we tell the assembler that a symbol is weak. The SOM
389 weak implementation uses the secondary definition (sdef) flag.
390
391 The behavior of sdef symbols is similar to ELF weak symbols in that
392 multiple definitions can occur without incurring a link error.
393 However, they differ in the following ways:
394 1) Undefined sdef symbols are not allowed.
395 2) The linker searches for undefined sdef symbols and will load an
396 archive library member to resolve an undefined sdef symbol.
397 3) The exported symbol from a shared library is a primary symbol
398 rather than a sdef symbol. Thus, more care is needed in the
399 ordering of libraries.
400
401 It appears that the linker discards extra copies of "weak" functions
402 when linking shared libraries, independent of whether or not they
403 are in their own section. In linking final executables, -Wl,-O can
404 be used to remove dead procedures. Thus, support for named sections
405 is not needed and in previous testing caused problems with various
406 HP tools. */
407 #define ASM_WEAKEN_LABEL(FILE,NAME) \
408 do { fputs ("\t.weak\t", FILE); \
409 assemble_name (FILE, NAME); \
410 fputc ('\n', FILE); \
411 if (! FUNCTION_NAME_P (NAME)) \
412 { \
413 fputs ("\t.EXPORT ", FILE); \
414 assemble_name (FILE, NAME); \
415 fputs (",DATA\n", FILE); \
416 } \
417 } while (0)
418
419 /* We can't handle weak aliases, and therefore can't support pragma weak.
420 Suppress the use of pragma weak in gthr-dce.h and gthr-posix.h. */
421 #define GTHREAD_USE_WEAK 0