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 Free Software Foundation, Inc.
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 #undef SUBTARGET_SWITCHES
23 #define SUBTARGET_SWITCHES \
25 N_("Generate cpp defines for server IO") }, \
26 { "wsio", -MASK_SIO, \
27 N_("Generate cpp defines for workstation IO") }, \
28 {"gnu-ld", MASK_GNU_LD, \
29 N_("Assume code will be linked by GNU ld") }, \
30 {"hp-ld", -MASK_GNU_LD, \
31 N_("Assume code will be linked by HP ld") },
33 /* We can debug dynamically linked executables on hpux11; we also
34 want dereferencing of a NULL pointer to cause a SEGV. Do not move
35 the "+Accept TypeMismatch" switch. We check for it in collect2
36 to determine which init/fini is needed. */
38 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
40 "%{!shared:%{p:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
41 %nWarning: consider linking with `-static' as system libraries with\n\
42 %n profiling support are only provided in archive format}}}\
43 %{!shared:%{pg:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
44 %nWarning: consider linking with `-static' as system libraries with\n\
45 %n profiling support are only provided in archive format}}}\
46 %{mhp-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main}\
47 %{static:-a archive} %{shared:%{mhp-ld:-b}%{!mhp-ld:-shared}}"
50 "%{!shared:%{p:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
51 %nWarning: consider linking with `-static' as system libraries with\n\
52 %n profiling support are only provided in archive format}}}\
53 %{!shared:%{pg:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
54 %nWarning: consider linking with `-static' as system libraries with\n\
55 %n profiling support are only provided in archive format}}}\
56 %{!mgnu-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main}\
57 %{static:-a archive} %{shared:%{mgnu-ld:-shared}%{!mgnu-ld:-b}}"
60 /* Like the default, except no -lg. */
64 %{!p:%{!pg: -lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
66 %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
68 %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
69 /usr/lib/pa20_64/milli.a"
71 /* Under hpux11, the normal location of the `ld' and `as' programs is the
72 /usr/ccs/bin directory. */
76 #define MD_EXEC_PREFIX "/usr/ccs/bin"
79 /* Under hpux11 the normal location of the various pa20_64 *crt*.o files
80 is the /usr/ccs/lib/pa20_64 directory. Some files may also be in the
81 /opt/langtools/lib/pa20_64 directory. */
84 #undef MD_STARTFILE_PREFIX
85 #define MD_STARTFILE_PREFIX "/usr/ccs/lib/pa20_64/"
89 #undef MD_STARTFILE_PREFIX_1
90 #define MD_STARTFILE_PREFIX_1 "/opt/langtools/lib/pa20_64/"
93 /* Due to limitations in the target structure, it isn't currently possible
94 to dynamically switch between the GNU and HP assemblers. */
97 /* Configure selects the standard ELFOS defines for use with GAS. */
100 /* We are using GAS. */
103 #undef TARGET_ASM_FILE_START
104 #define TARGET_ASM_FILE_START pa_hpux64_gas_file_start
106 /* This is how we output a null terminated string. */
108 #define STRING_ASM_OP "\t.stringz\t"
110 #define TEXT_SECTION_ASM_OP "\t.text"
111 #define DATA_SECTION_ASM_OP "\t.data"
112 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
114 #define JCR_SECTION_NAME ".jcr"
116 #define HP_INIT_ARRAY_SECTION_ASM_OP "\t.section\t.init"
117 #define GNU_INIT_ARRAY_SECTION_ASM_OP "\t.section\t.init_array"
118 #define HP_FINI_ARRAY_SECTION_ASM_OP "\t.section\t.fini"
119 #define GNU_FINI_ARRAY_SECTION_ASM_OP "\t.section\t.fini_array"
121 #undef ASM_OUTPUT_ALIGNED_COMMON
122 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
125 assemble_name ((FILE), (NAME)); \
126 fprintf ((FILE), "\t.comm "HOST_WIDE_INT_PRINT_UNSIGNED"\n", \
127 MAX ((unsigned HOST_WIDE_INT)(SIZE), \
128 ((unsigned HOST_WIDE_INT)(ALIGN) / BITS_PER_UNIT))); \
131 #undef ASM_OUTPUT_ALIGNED_LOCAL
132 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
135 fprintf ((FILE), "\t.align %d\n", ((ALIGN) / BITS_PER_UNIT)); \
136 assemble_name ((FILE), (NAME)); \
137 fprintf ((FILE), "\n\t.block "HOST_WIDE_INT_PRINT_UNSIGNED"\n", \
138 (unsigned HOST_WIDE_INT)(SIZE)); \
141 /* The define in pa.h doesn't work with the alias attribute. The
142 default is ok with the following define for GLOBAL_ASM_OP. */
143 #undef TARGET_ASM_GLOBALIZE_LABEL
145 /* This is how we globalize a label. */
146 #define GLOBAL_ASM_OP "\t.globl\t"
148 /* Hacked version from elfos.h that doesn't output a label. */
149 #undef ASM_DECLARE_FUNCTION_NAME
150 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
152 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
153 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
156 /* The type of external references must be set correctly for the
157 dynamic loader to work correctly. This is equivalent to the
158 HP assembler's .IMPORT directive but relates more directly to
159 ELF object file types. */
160 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
162 int save_referenced; \
163 save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL));\
164 if (FUNCTION_NAME_P (NAME)) \
165 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
167 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
168 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced;\
171 /* We need set the type for external libcalls. Also note that not all
172 libcall names are passed to targetm.encode_section_info (e.g., __main).
173 Thus, we also have to do the section encoding if it hasn't been done
175 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
176 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
178 if (!FUNCTION_NAME_P (XSTR (FUN, 0))) \
179 hppa_encode_label (FUN); \
180 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, XSTR (FUN, 0), "function"); \
183 /* We need to use the HP style for internal labels. */
184 #undef ASM_GENERATE_INTERNAL_LABEL
185 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
186 sprintf (LABEL, "*%c$%s%04ld", (PREFIX)[0], (PREFIX) + 1, (long)(NUM))
188 #else /* USING_ELFOS_H */
190 /* We are not using GAS. */
193 /* HPUX 11 has the "new" HP assembler. It's still lousy, but it's a whole
194 lot better than the assembler shipped with older versions of hpux.
195 However, it doesn't support weak symbols and is a bad fit with ELF. */
196 #undef NEW_HP_ASSEMBLER
197 #define NEW_HP_ASSEMBLER 1
199 /* It looks like DWARF2 will be the easiest debug format to handle on this
201 #define DWARF2_DEBUGGING_INFO 1
202 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
204 /* This target uses the ELF object file format. */
205 #define OBJECT_FORMAT_ELF
207 #undef TARGET_ASM_FILE_START
208 #define TARGET_ASM_FILE_START pa_hpux64_hpas_file_start
210 #undef TEXT_SECTION_ASM_OP
211 #define TEXT_SECTION_ASM_OP "\t.SUBSPA $CODE$\n"
212 #undef READONLY_DATA_SECTION_ASM_OP
213 #define READONLY_DATA_SECTION_ASM_OP "\t.SUBSPA $LIT$\n"
214 #undef DATA_SECTION_ASM_OP
215 #define DATA_SECTION_ASM_OP "\t.SUBSPA $DATA$\n"
216 #undef BSS_SECTION_ASM_OP
217 #define BSS_SECTION_ASM_OP "\t.SUBSPA $BSS$\n"
219 /* We provide explicit defines for CTORS_SECTION_ASM_OP and
220 DTORS_SECTION_ASM_OP since we don't yet have support for
221 named sections with the HP assembler. */
222 #undef CTORS_SECTION_ASM_OP
223 #define CTORS_SECTION_ASM_OP "\t.SUBSPA \\.ctors,QUAD=1,ALIGN=8,ACCESS=31"
224 #undef DTORS_SECTION_ASM_OP
225 #define DTORS_SECTION_ASM_OP "\t.SUBSPA \\.dtors,QUAD=1,ALIGN=8,ACCESS=31"
227 #define HP_INIT_ARRAY_SECTION_ASM_OP \
228 "\t.SUBSPA \\.init,QUAD=1,ALIGN=8,ACCESS=31"
229 #define GNU_INIT_ARRAY_SECTION_ASM_OP \
230 "\t.SUBSPA \\.init_array,QUAD=1,ALIGN=8,ACCESS=31"
231 #define HP_FINI_ARRAY_SECTION_ASM_OP \
232 "\t.SUBSPA \\.fini,QUAD=1,ALIGN=8,ACCESS=31"
233 #define GNU_FINI_ARRAY_SECTION_ASM_OP \
234 "\t.SUBSPA \\.fini_array,QUAD=1,ALIGN=8,ACCESS=31"
236 #endif /* USING_ELFOS_H */
238 /* The following defines, used to run constructors and destructors with
239 the SOM linker under HP-UX 11, are not needed. */
240 #undef HAS_INIT_SECTION
241 #undef LD_INIT_SWITCH
242 #undef LD_FINI_SWITCH
244 /* The following STARTFILE_SPEC and ENDFILE_SPEC defines provide the
245 magic needed to run initializers and finalizers. */
246 #undef STARTFILE_SPEC
247 #define STARTFILE_SPEC \
248 "%{!shared: %{!symbolic: crt0.o%s}} %{static:crtbeginT.o%s} \
249 %{!static:%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
251 #define ENDFILE_SPEC "%{!shared:crtend.o%s} %{shared:crtendS.o%s}"
253 /* Since HP uses the .init and .fini sections for array initializers
254 and finalizers, we need different defines for INIT_SECTION_ASM_OP
255 and FINI_SECTION_ASM_OP. With the implementation adopted below,
256 the sections are not actually used. However, we still must provide
257 defines to select the proper code path. */
258 #undef INIT_SECTION_ASM_OP
259 #define INIT_SECTION_ASM_OP
260 #undef FINI_SECTION_ASM_OP
261 #define FINI_SECTION_ASM_OP
263 /* We are using array initializers and don't want calls in the INIT
264 and FINI sections. */
265 #undef CRT_CALL_STATIC_FUNCTION
266 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)
268 /* The init_priority attribute is not supported with HP ld. This could be
269 supported if collect2 was used with LD_INIT_SWITCH. Unfortunately, this
270 approach doesn't work with GNU ld since HP-UX doesn't support DT_INIT,
271 and therefore the -init and -fini GNU ld switches. */
272 #undef SUPPORTS_INIT_PRIORITY
273 #define SUPPORTS_INIT_PRIORITY (TARGET_GNU_LD ? 1 : 0)
275 /* We use DTOR_LIST_BEGIN to carry a bunch of hacks to allow us to use
276 the init and fini array sections with both the HP and GNU linkers.
277 The linkers setup the required dynamic entries in the dynamic segment
278 and the dynamic linker does the calls. This approach avoids using
281 The first hack is to implement __do_global_ctors_aux in crtbegin as
282 it needs to be the first entry in the init array so that it is called
283 last. HP got the order of the init array backwards. The DT_INIT_ARRAY
284 is supposed to be executed in the same order as the addresses appear in
285 the array. DT_FINI_ARRAY is supposed to be executed in the opposite
288 The second hack is stubs for __cxa_finalize and _Jv_RegisterClasses.
289 The HP implementation of undefined weak symbols is broken. The linker
290 and dynamic loader both search for undefined weak symbols contrary the
291 generic System V ABI. An undefined weak symbol should resolve to a
292 value of 0 rather than causing an error. The prototypes for
293 __cxa_finalize and _Jv_RegisterClasses in crtstuff.c are weak when
294 weak is supported (GNU as), so in theory a strong define should override
295 the stub functions provided here.
297 The final hack is a set of plabels to implement the effect of
298 CRT_CALL_STATIC_FUNCTION. HP-UX 11 only supports DI_INIT_ARRAY and
299 DT_FINI_ARRAY and they put the arrays in .init and .fini, rather than
300 in .init_array and .fini_array. The standard defines for .init and
301 .fini have the execute flag set. So, the assembler has to be hacked
302 to munge the standard flags for these sections to make them agree
303 with what the HP linker expects. With the GNU linker, we need to
304 used the .init_array and .fini_array sections. So, we set up for
305 both just in case. Once we have built the table, the linker does
306 the rest of the work.
308 The order is significant. Placing __do_global_ctors_aux first in
309 the list, results in it being called last. User specified initializers,
310 either using the linker +init command or a plabel, run before the
311 initializers specified here. */
313 /* We need a __cxa_finalize stub if CRTSTUFFS_O is defined. */
315 #define PA_CXA_FINALIZE_STUB \
316 extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK; \
318 __cxa_finalize (void *p __attribute__((unused))) {}
320 #define PA_CXA_FINALIZE_STUB
323 /* We need a _Jv_RegisterClasses stub if JCR_SECTION_NAME is defined. */
324 #ifdef JCR_SECTION_NAME
325 #define PA_JV_REGISTERCLASSES_STUB \
327 _Jv_RegisterClasses (void *p __attribute__((unused))) {}
329 #define PA_JV_REGISTERCLASSES_STUB
332 /* We need to add frame_dummy to the initializer list if EH_FRAME_SECTION_NAME
333 or JCR_SECTION_NAME is defined. */
334 #if defined(EH_FRAME_SECTION_NAME) || defined(JCR_SECTION_NAME)
335 #define PA_INIT_FRAME_DUMMY_ASM_OP ".dword P%frame_dummy"
337 #define PA_INIT_FRAME_DUMMY_ASM_OP ""
340 #define PA_INIT_FINI_HACK \
341 static void __attribute__((used)) \
342 __do_global_ctors_aux (void) \
344 func_ptr *p = __CTOR_LIST__; \
347 for (; *p != (func_ptr) -1; p--) \
351 PA_CXA_FINALIZE_STUB \
352 PA_JV_REGISTERCLASSES_STUB \
354 asm (HP_INIT_ARRAY_SECTION_ASM_OP); \
355 asm (".dword P%__do_global_ctors_aux"); \
356 asm (PA_INIT_FRAME_DUMMY_ASM_OP); \
357 asm (GNU_INIT_ARRAY_SECTION_ASM_OP); \
358 asm (".dword P%__do_global_ctors_aux"); \
359 asm (PA_INIT_FRAME_DUMMY_ASM_OP); \
360 asm (HP_FINI_ARRAY_SECTION_ASM_OP); \
361 asm (".dword P%__do_global_dtors_aux"); \
362 asm (GNU_FINI_ARRAY_SECTION_ASM_OP); \
363 asm (".dword P%__do_global_dtors_aux")
365 /* The following two variants of DTOR_LIST_BEGIN are identical to those
366 in crtstuff.c except for the addition of the above init-fini hack. */
367 #ifdef DTORS_SECTION_ASM_OP
368 #define DTOR_LIST_BEGIN \
369 asm (DTORS_SECTION_ASM_OP); \
370 STATIC func_ptr __DTOR_LIST__[1] \
371 __attribute__ ((aligned(sizeof(func_ptr)))) \
372 = { (func_ptr) (-1) }; \
375 #define DTOR_LIST_BEGIN \
376 STATIC func_ptr __DTOR_LIST__[1] \
377 __attribute__ ((section(".dtors"), aligned(sizeof(func_ptr)))) \
378 = { (func_ptr) (-1) }; \
382 /* If using HP ld do not call pxdb. Use size as a program that does nothing
383 and returns 0. /bin/true cannot be used because it is a script without
385 #define INIT_ENVIRONMENT "LD_PXDB=/usr/ccs/bin/size"
387 /* The HPUX dynamic linker objects to weak symbols with no
388 definitions, so do not use them in gthr-posix.h. */
389 #define GTHREAD_USE_WEAK 0