* alias.c, c-common.h, c-incpath.c, c-incpath.h, expr.c,
[official-gcc.git] / gcc / config / pa / pa64-hpux.h
blob75573ed6cbab166ed53fab34182bc8a9a4de8c7c
1 /* Definitions of target machine for GNU compiler, for HPs running
2 HPUX using the 64bit runtime model.
3 Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation,
4 Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
23 #undef SUBTARGET_SWITCHES
24 #define SUBTARGET_SWITCHES \
25 { "sio", MASK_SIO, \
26 N_("Generate cpp defines for server IO") }, \
27 { "wsio", -MASK_SIO, \
28 N_("Generate cpp defines for workstation IO") }, \
29 {"gnu-ld", MASK_GNU_LD, \
30 N_("Assume code will be linked by GNU ld") }, \
31 {"hp-ld", -MASK_GNU_LD, \
32 N_("Assume code will be linked by HP ld") },
34 /* We can debug dynamically linked executables on hpux11; we also
35 want dereferencing of a NULL pointer to cause a SEGV. Do not move
36 the "+Accept TypeMismatch" switch. We check for it in collect2
37 to determine which init/fini is needed. */
38 #undef LINK_SPEC
39 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
40 #define LINK_SPEC \
41 "%{!shared:%{p:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
42 %nWarning: consider linking with `-static' as system libraries with\n\
43 %n profiling support are only provided in archive format}}}\
44 %{!shared:%{pg:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
45 %nWarning: consider linking with `-static' as system libraries with\n\
46 %n profiling support are only provided in archive format}}}\
47 %{mhp-ld:+Accept TypeMismatch -z} -E %{mlinker-opt:-O} %{!shared:-u main}\
48 %{static:-a archive} %{shared:%{mhp-ld:-b}%{!mhp-ld:-shared}}"
49 #else
50 #define LINK_SPEC \
51 "%{!shared:%{p:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
52 %nWarning: consider linking with `-static' as system libraries with\n\
53 %n profiling support are only provided in archive format}}}\
54 %{!shared:%{pg:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
55 %nWarning: consider linking with `-static' as system libraries with\n\
56 %n profiling support are only provided in archive format}}}\
57 %{!mgnu-ld:+Accept TypeMismatch -z} -E %{mlinker-opt:-O} %{!shared:-u main}\
58 %{static:-a archive} %{shared:%{mgnu-ld:-shared}%{!mgnu-ld:-b}}"
59 #endif
61 /* Profiling support is only provided in libc.a. However, libprof and
62 libgprof are only available in shared form on HP-UX 11.00. We use
63 the shared form if we are using the GNU linker or an archive form
64 isn't available. We also usually need to link with libdld and it's
65 only available in shared form. */
66 #undef LIB_SPEC
67 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
68 #define LIB_SPEC \
69 "%{!shared:\
70 %{!p:%{!pg: -lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
71 %{p:%{!pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\
72 -lprof %{static:-a archive} -lc\
73 %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
74 %{pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\
75 -lgprof %{static:-a archive} -lc\
76 %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
77 /usr/lib/pa20_64/milli.a"
78 #else
79 #define LIB_SPEC \
80 "%{!shared:\
81 %{!p:%{!pg: -lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
82 %{p:%{!pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\
83 -lprof %{static:-a archive} -lc\
84 %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
85 %{pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\
86 -lgprof %{static:-a archive} -lc\
87 %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
88 /usr/lib/pa20_64/milli.a"
89 #endif
91 /* Under hpux11, the normal location of the `ld' and `as' programs is the
92 /usr/ccs/bin directory. */
94 #ifndef CROSS_COMPILE
95 #undef MD_EXEC_PREFIX
96 #define MD_EXEC_PREFIX "/usr/ccs/bin"
97 #endif
99 /* Default prefixes. */
101 #undef STANDARD_STARTFILE_PREFIX_1
102 #define STANDARD_STARTFILE_PREFIX_1 "/lib/pa20_64/"
104 #undef STANDARD_STARTFILE_PREFIX_2
105 #define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/pa20_64/"
107 /* Under hpux11 the normal location of the various pa20_64 *crt*.o files
108 is the /usr/ccs/lib/pa20_64 directory. Some files may also be in the
109 /opt/langtools/lib/pa20_64 directory. */
111 #ifndef CROSS_COMPILE
112 #undef MD_STARTFILE_PREFIX
113 #define MD_STARTFILE_PREFIX "/usr/ccs/lib/pa20_64/"
114 #endif
116 #ifndef CROSS_COMPILE
117 #undef MD_STARTFILE_PREFIX_1
118 #define MD_STARTFILE_PREFIX_1 "/opt/langtools/lib/pa20_64/"
119 #endif
121 /* This macro specifies the biggest alignment supported by the object
122 file format of this machine.
124 The .align directive in the HP assembler allows alignments up to
125 4096 bytes. However, the maximum alignment of a global common symbol
126 is 16 bytes using HP ld. Unfortunately, this macro doesn't provide
127 a method to check for common symbols. */
128 #undef MAX_OFILE_ALIGNMENT
129 #define MAX_OFILE_ALIGNMENT 32768
131 /* Due to limitations in the target structure, it isn't currently possible
132 to dynamically switch between the GNU and HP assemblers. */
133 #undef TARGET_GAS
135 /* Configure selects the standard ELFOS defines for use with GAS. */
136 #ifdef USING_ELFOS_H
138 /* We are using GAS. */
139 #define TARGET_GAS 1
141 #undef TARGET_ASM_FILE_START
142 #define TARGET_ASM_FILE_START pa_hpux64_gas_file_start
144 /* This is how we output a null terminated string. */
145 #undef STRING_ASM_OP
146 #define STRING_ASM_OP "\t.stringz\t"
148 #define TEXT_SECTION_ASM_OP "\t.text"
149 #define DATA_SECTION_ASM_OP "\t.data"
150 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
152 #define JCR_SECTION_NAME ".jcr"
154 #define HP_INIT_ARRAY_SECTION_ASM_OP "\t.section\t.init"
155 #define GNU_INIT_ARRAY_SECTION_ASM_OP "\t.section\t.init_array"
156 #define HP_FINI_ARRAY_SECTION_ASM_OP "\t.section\t.fini"
157 #define GNU_FINI_ARRAY_SECTION_ASM_OP "\t.section\t.fini_array"
159 /* We need to override the following two macros defined in elfos.h since
160 the .comm directive has a different syntax and it can't be used for
161 local common symbols. */
162 #undef ASM_OUTPUT_ALIGNED_COMMON
163 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
164 pa_asm_output_aligned_common (FILE, NAME, SIZE, ALIGN)
166 #undef ASM_OUTPUT_ALIGNED_LOCAL
167 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
168 pa_asm_output_aligned_local (FILE, NAME, SIZE, ALIGN)
170 /* The define in pa.h doesn't work with the alias attribute. The
171 default is ok with the following define for GLOBAL_ASM_OP. */
172 #undef TARGET_ASM_GLOBALIZE_LABEL
174 /* This is how we globalize a label. */
175 #define GLOBAL_ASM_OP "\t.globl\t"
177 /* Hacked version from elfos.h that doesn't output a label. */
178 #undef ASM_DECLARE_FUNCTION_NAME
179 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
180 do { \
181 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
182 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
183 } while (0)
185 /* The type of external references must be set correctly for the
186 dynamic loader to work correctly. This is equivalent to the
187 HP assembler's .IMPORT directive but relates more directly to
188 ELF object file types. */
189 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
190 do { \
191 int save_referenced; \
192 save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL));\
193 if (FUNCTION_NAME_P (NAME)) \
194 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
195 else \
196 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
197 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced;\
198 } while (0)
200 /* We need set the type for external libcalls. Also note that not all
201 libcall names are passed to targetm.encode_section_info (e.g., __main).
202 Thus, we also have to do the section encoding if it hasn't been done
203 already. */
204 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
205 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
206 do { \
207 if (!FUNCTION_NAME_P (XSTR (FUN, 0))) \
208 hppa_encode_label (FUN); \
209 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, XSTR (FUN, 0), "function"); \
210 } while (0)
212 /* We need to use the HP style for internal labels. */
213 #undef ASM_GENERATE_INTERNAL_LABEL
214 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
215 sprintf (LABEL, "*%c$%s%04ld", (PREFIX)[0], (PREFIX) + 1, (long)(NUM))
217 #else /* USING_ELFOS_H */
219 /* We are not using GAS. */
220 #define TARGET_GAS 0
222 /* HPUX 11 has the "new" HP assembler. It's still lousy, but it's a whole
223 lot better than the assembler shipped with older versions of hpux.
224 However, it doesn't support weak symbols and is a bad fit with ELF. */
225 #undef NEW_HP_ASSEMBLER
226 #define NEW_HP_ASSEMBLER 1
228 /* It looks like DWARF2 will be the easiest debug format to handle on this
229 platform. */
230 #define DWARF2_DEBUGGING_INFO 1
231 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
233 /* This target uses the ELF object file format. */
234 #define OBJECT_FORMAT_ELF
236 #undef TARGET_ASM_FILE_START
237 #define TARGET_ASM_FILE_START pa_hpux64_hpas_file_start
239 #undef TEXT_SECTION_ASM_OP
240 #define TEXT_SECTION_ASM_OP "\t.SUBSPA $CODE$\n"
241 #undef READONLY_DATA_SECTION_ASM_OP
242 #define READONLY_DATA_SECTION_ASM_OP "\t.SUBSPA $LIT$\n"
243 #undef DATA_SECTION_ASM_OP
244 #define DATA_SECTION_ASM_OP "\t.SUBSPA $DATA$\n"
245 #undef BSS_SECTION_ASM_OP
246 #define BSS_SECTION_ASM_OP "\t.SUBSPA $BSS$\n"
248 /* We provide explicit defines for CTORS_SECTION_ASM_OP and
249 DTORS_SECTION_ASM_OP since we don't yet have support for
250 named sections with the HP assembler. */
251 #undef CTORS_SECTION_ASM_OP
252 #define CTORS_SECTION_ASM_OP "\t.SUBSPA \\.ctors,QUAD=1,ALIGN=8,ACCESS=31"
253 #undef DTORS_SECTION_ASM_OP
254 #define DTORS_SECTION_ASM_OP "\t.SUBSPA \\.dtors,QUAD=1,ALIGN=8,ACCESS=31"
256 #define HP_INIT_ARRAY_SECTION_ASM_OP \
257 "\t.SUBSPA \\.init,QUAD=1,ALIGN=8,ACCESS=31"
258 #define GNU_INIT_ARRAY_SECTION_ASM_OP \
259 "\t.SUBSPA \\.init_array,QUAD=1,ALIGN=8,ACCESS=31"
260 #define HP_FINI_ARRAY_SECTION_ASM_OP \
261 "\t.SUBSPA \\.fini,QUAD=1,ALIGN=8,ACCESS=31"
262 #define GNU_FINI_ARRAY_SECTION_ASM_OP \
263 "\t.SUBSPA \\.fini_array,QUAD=1,ALIGN=8,ACCESS=31"
265 #endif /* USING_ELFOS_H */
267 /* The following defines, used to run constructors and destructors with
268 the SOM linker under HP-UX 11, are not needed. */
269 #undef HAS_INIT_SECTION
270 #undef LD_INIT_SWITCH
271 #undef LD_FINI_SWITCH
273 /* The following STARTFILE_SPEC and ENDFILE_SPEC defines provide the
274 magic needed to run initializers and finalizers. */
275 #undef STARTFILE_SPEC
276 #if TARGET_HPUX_11_11
277 #define STARTFILE_SPEC \
278 "%{!shared: %{!symbolic: crt0%O%s} %{munix=95:unix95.o%s} \
279 %{!munix=93:%{!munix=95:unix98%O%s}}} %{static:crtbeginT%O%s} \
280 %{!static:%{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}"
281 #else
282 #define STARTFILE_SPEC \
283 "%{!shared: %{!symbolic: crt0%O%s} %{munix=95:unix95%O%s}} \
284 %{static:crtbeginT%O%s} %{!static:%{!shared:crtbegin%O%s} \
285 %{shared:crtbeginS%O%s}}"
286 #endif
287 #undef ENDFILE_SPEC
288 #define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
290 /* Since HP uses the .init and .fini sections for array initializers
291 and finalizers, we need different defines for INIT_SECTION_ASM_OP
292 and FINI_SECTION_ASM_OP. With the implementation adopted below,
293 the sections are not actually used. However, we still must provide
294 defines to select the proper code path. */
295 #undef INIT_SECTION_ASM_OP
296 #define INIT_SECTION_ASM_OP
297 #undef FINI_SECTION_ASM_OP
298 #define FINI_SECTION_ASM_OP
300 /* We are using array initializers and don't want calls in the INIT
301 and FINI sections. */
302 #undef CRT_CALL_STATIC_FUNCTION
303 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)
305 /* The init_priority attribute is not supported with HP ld. This could be
306 supported if collect2 was used with LD_INIT_SWITCH. Unfortunately, this
307 approach doesn't work with GNU ld since HP-UX doesn't support DT_INIT,
308 and therefore the -init and -fini GNU ld switches. */
309 #undef SUPPORTS_INIT_PRIORITY
310 #define SUPPORTS_INIT_PRIORITY (TARGET_GNU_LD ? 1 : 0)
312 /* We use DTOR_LIST_BEGIN to carry a bunch of hacks to allow us to use
313 the init and fini array sections with both the HP and GNU linkers.
314 The linkers setup the required dynamic entries in the dynamic segment
315 and the dynamic linker does the calls. This approach avoids using
316 collect2.
318 The first hack is to implement __do_global_ctors_aux in crtbegin as
319 it needs to be the first entry in the init array so that it is called
320 last. HP got the order of the init array backwards. The DT_INIT_ARRAY
321 is supposed to be executed in the same order as the addresses appear in
322 the array. DT_FINI_ARRAY is supposed to be executed in the opposite
323 order.
325 The second hack is stubs for __cxa_finalize and _Jv_RegisterClasses.
326 The HP implementation of undefined weak symbols is broken. The linker
327 and dynamic loader both search for undefined weak symbols contrary the
328 generic System V ABI. An undefined weak symbol should resolve to a
329 value of 0 rather than causing an error. The prototypes for
330 __cxa_finalize and _Jv_RegisterClasses in crtstuff.c are weak when
331 weak is supported (GNU as), so in theory a strong define should override
332 the stub functions provided here.
334 The final hack is a set of plabels to implement the effect of
335 CRT_CALL_STATIC_FUNCTION. HP-UX 11 only supports DI_INIT_ARRAY and
336 DT_FINI_ARRAY and they put the arrays in .init and .fini, rather than
337 in .init_array and .fini_array. The standard defines for .init and
338 .fini have the execute flag set. So, the assembler has to be hacked
339 to munge the standard flags for these sections to make them agree
340 with what the HP linker expects. With the GNU linker, we need to
341 used the .init_array and .fini_array sections. So, we set up for
342 both just in case. Once we have built the table, the linker does
343 the rest of the work.
345 The order is significant. Placing __do_global_ctors_aux first in
346 the list, results in it being called last. User specified initializers,
347 either using the linker +init command or a plabel, run before the
348 initializers specified here. */
350 /* We need a __cxa_finalize stub if CRTSTUFFS_O is defined. */
351 #ifdef CRTSTUFFS_O
352 #define PA_CXA_FINALIZE_STUB \
353 extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK; \
354 void \
355 __cxa_finalize (void *p __attribute__((unused))) {}
356 #else
357 #define PA_CXA_FINALIZE_STUB
358 #endif
360 /* We need a _Jv_RegisterClasses stub if JCR_SECTION_NAME is defined. */
361 #ifdef JCR_SECTION_NAME
362 #define PA_JV_REGISTERCLASSES_STUB \
363 void \
364 _Jv_RegisterClasses (void *p __attribute__((unused))) {}
365 #else
366 #define PA_JV_REGISTERCLASSES_STUB
367 #endif
369 /* We need to add frame_dummy to the initializer list if EH_FRAME_SECTION_NAME
370 or JCR_SECTION_NAME is defined. */
371 #if defined(EH_FRAME_SECTION_NAME) || defined(JCR_SECTION_NAME)
372 #define PA_INIT_FRAME_DUMMY_ASM_OP ".dword P%frame_dummy"
373 #else
374 #define PA_INIT_FRAME_DUMMY_ASM_OP ""
375 #endif
377 #define PA_INIT_FINI_HACK \
378 static void __attribute__((used)) \
379 __do_global_ctors_aux (void) \
381 func_ptr *p = __CTOR_LIST__; \
382 while (*(p + 1)) \
383 p++; \
384 for (; *p != (func_ptr) -1; p--) \
385 (*p) (); \
388 PA_CXA_FINALIZE_STUB \
389 PA_JV_REGISTERCLASSES_STUB \
391 asm (HP_INIT_ARRAY_SECTION_ASM_OP); \
392 asm (".dword P%__do_global_ctors_aux"); \
393 asm (PA_INIT_FRAME_DUMMY_ASM_OP); \
394 asm (GNU_INIT_ARRAY_SECTION_ASM_OP); \
395 asm (".dword P%__do_global_ctors_aux"); \
396 asm (PA_INIT_FRAME_DUMMY_ASM_OP); \
397 asm (HP_FINI_ARRAY_SECTION_ASM_OP); \
398 asm (".dword P%__do_global_dtors_aux"); \
399 asm (GNU_FINI_ARRAY_SECTION_ASM_OP); \
400 asm (".dword P%__do_global_dtors_aux")
402 /* The following two variants of DTOR_LIST_BEGIN are identical to those
403 in crtstuff.c except for the addition of the above init-fini hack. */
404 #ifdef DTORS_SECTION_ASM_OP
405 #define DTOR_LIST_BEGIN \
406 asm (DTORS_SECTION_ASM_OP); \
407 STATIC func_ptr __DTOR_LIST__[1] \
408 __attribute__ ((aligned(sizeof(func_ptr)))) \
409 = { (func_ptr) (-1) }; \
410 PA_INIT_FINI_HACK
411 #else
412 #define DTOR_LIST_BEGIN \
413 STATIC func_ptr __DTOR_LIST__[1] \
414 __attribute__ ((section(".dtors"), aligned(sizeof(func_ptr)))) \
415 = { (func_ptr) (-1) }; \
416 PA_INIT_FINI_HACK
417 #endif
419 /* If using HP ld do not call pxdb. Use size as a program that does nothing
420 and returns 0. /bin/true cannot be used because it is a script without
421 an interpreter. */
422 #define INIT_ENVIRONMENT "LD_PXDB=/usr/ccs/bin/size"
424 /* The HPUX dynamic linker objects to weak symbols with no
425 definitions, so do not use them in gthr-posix.h. */
426 #define GTHREAD_USE_WEAK 0