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,
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)
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, 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* We can debug dynamically linked executables on hpux11; we also
24 want dereferencing of a NULL pointer to cause a SEGV. Do not move
25 the "+Accept TypeMismatch" switch. We check for it in collect2
26 to determine which init/fini is needed. */
28 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
30 "%{!shared:%{p:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
31 %nWarning: consider linking with `-static' as system libraries with\n\
32 %n profiling support are only provided in archive format}}}\
33 %{!shared:%{pg:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\
34 %nWarning: consider linking with `-static' as system libraries with\n\
35 %n profiling support are only provided in archive format}}}\
36 %{mhp-ld:+Accept TypeMismatch -z} -E %{mlinker-opt:-O} %{!shared:-u main}\
37 %{static:-a archive} %{shared:%{mhp-ld:-b}%{!mhp-ld:-shared}}"
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 %{!mgnu-ld:+Accept TypeMismatch -z} -E %{mlinker-opt:-O} %{!shared:-u main}\
47 %{static:-a archive} %{shared:%{mgnu-ld:-shared}%{!mgnu-ld:-b}}"
50 /* Profiling support is only provided in libc.a. However, libprof and
51 libgprof are only available in shared form on HP-UX 11.00. We use
52 the shared form if we are using the GNU linker or an archive form
53 isn't available. We also usually need to link with libdld and it's
54 only available in shared form. */
56 #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
59 %{!p:%{!pg: -lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
60 %{p:%{!pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\
61 -lprof %{static:-a archive} -lc\
62 %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
63 %{pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\
64 -lgprof %{static:-a archive} -lc\
65 %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
66 /usr/lib/pa20_64/milli.a"
70 %{!p:%{!pg: -lc %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
71 %{p:%{!pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\
72 -lprof %{static:-a archive} -lc\
73 %{static:%{!nolibdld:-a shared -ldld -a archive -lc}}}}\
74 %{pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-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"
80 /* Under hpux11, the normal location of the `ld' and `as' programs is the
81 /usr/ccs/bin directory. */
85 #define MD_EXEC_PREFIX "/usr/ccs/bin"
88 /* Default prefixes. */
90 #undef STANDARD_STARTFILE_PREFIX_1
91 #define STANDARD_STARTFILE_PREFIX_1 "/lib/pa20_64/"
93 #undef STANDARD_STARTFILE_PREFIX_2
94 #define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/pa20_64/"
96 /* Under hpux11 the normal location of the various pa20_64 *crt*.o files
97 is the /usr/ccs/lib/pa20_64 directory. Some files may also be in the
98 /opt/langtools/lib/pa20_64 directory. */
100 #ifndef CROSS_COMPILE
101 #undef MD_STARTFILE_PREFIX
102 #define MD_STARTFILE_PREFIX "/usr/ccs/lib/pa20_64/"
105 #ifndef CROSS_COMPILE
106 #undef MD_STARTFILE_PREFIX_1
107 #define MD_STARTFILE_PREFIX_1 "/opt/langtools/lib/pa20_64/"
110 /* This macro specifies the biggest alignment supported by the object
111 file format of this machine.
113 The .align directive in the HP assembler allows alignments up to
114 4096 bytes. However, the maximum alignment of a global common symbol
115 is 16 bytes using HP ld. Unfortunately, this macro doesn't provide
116 a method to check for common symbols. */
117 #undef MAX_OFILE_ALIGNMENT
118 #define MAX_OFILE_ALIGNMENT 32768
120 /* Due to limitations in the target structure, it isn't currently possible
121 to dynamically switch between the GNU and HP assemblers. */
124 /* Configure selects the standard ELFOS defines for use with GAS. */
127 /* We are using GAS. */
130 #undef TARGET_ASM_FILE_START
131 #define TARGET_ASM_FILE_START pa_hpux64_gas_file_start
133 /* This is how we output a null terminated string. */
135 #define STRING_ASM_OP "\t.stringz\t"
137 #define TEXT_SECTION_ASM_OP "\t.text"
138 #define DATA_SECTION_ASM_OP "\t.data"
139 #define BSS_SECTION_ASM_OP "\t.section\t.bss"
141 #define JCR_SECTION_NAME ".jcr"
143 #define HP_INIT_ARRAY_SECTION_ASM_OP "\t.section\t.init"
144 #define GNU_INIT_ARRAY_SECTION_ASM_OP "\t.section\t.init_array"
145 #define HP_FINI_ARRAY_SECTION_ASM_OP "\t.section\t.fini"
146 #define GNU_FINI_ARRAY_SECTION_ASM_OP "\t.section\t.fini_array"
148 /* We need to override the following two macros defined in elfos.h since
149 the .comm directive has a different syntax and it can't be used for
150 local common symbols. */
151 #undef ASM_OUTPUT_ALIGNED_COMMON
152 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
153 pa_asm_output_aligned_common (FILE, NAME, SIZE, ALIGN)
155 #undef ASM_OUTPUT_ALIGNED_LOCAL
156 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
157 pa_asm_output_aligned_local (FILE, NAME, SIZE, ALIGN)
159 /* The define in pa.h doesn't work with the alias attribute. The
160 default is ok with the following define for GLOBAL_ASM_OP. */
161 #undef TARGET_ASM_GLOBALIZE_LABEL
163 /* This is how we globalize a label. */
164 #define GLOBAL_ASM_OP "\t.globl\t"
166 /* Hacked version from defaults.h that uses assemble_name_raw
167 instead of assemble_name. A symbol in a type directive that
168 isn't otherwise referenced doesn't cause the symbol to be
169 placed in the symbol table of the assembled object. */
170 #undef ASM_OUTPUT_TYPE_DIRECTIVE
171 #define ASM_OUTPUT_TYPE_DIRECTIVE(STREAM, NAME, TYPE) \
173 fputs (TYPE_ASM_OP, STREAM); \
174 assemble_name_raw (STREAM, NAME); \
175 fputs (", ", STREAM); \
176 fprintf (STREAM, TYPE_OPERAND_FMT, TYPE); \
177 putc ('\n', STREAM); \
180 /* Hacked version from elfos.h that doesn't output a label. */
181 #undef ASM_DECLARE_FUNCTION_NAME
182 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
184 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
185 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
188 /* The type of external references must be set correctly for the
189 dynamic loader to work correctly. This is equivalent to the
190 HP assembler's .IMPORT directive but relates more directly to
191 ELF object file types. */
192 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
193 pa_hpux_asm_output_external ((FILE), (DECL), (NAME))
194 #define ASM_OUTPUT_EXTERNAL_REAL(FILE, DECL, NAME) \
196 if (FUNCTION_NAME_P (NAME)) \
197 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
199 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
202 /* We need set the type for external libcalls. Also note that not all
203 libcall names are passed to targetm.encode_section_info (e.g., __main).
204 Thus, we also have to do the section encoding if it hasn't been done
206 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
207 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
209 if (!FUNCTION_NAME_P (XSTR (FUN, 0))) \
210 hppa_encode_label (FUN); \
211 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, XSTR (FUN, 0), "function"); \
214 /* We need to use the HP style for internal labels. */
215 #undef ASM_GENERATE_INTERNAL_LABEL
216 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
217 sprintf (LABEL, "*%c$%s%04ld", (PREFIX)[0], (PREFIX) + 1, (long)(NUM))
219 #else /* USING_ELFOS_H */
221 /* We are not using GAS. */
224 /* HPUX 11 has the "new" HP assembler. It's still lousy, but it's a whole
225 lot better than the assembler shipped with older versions of hpux.
226 However, it doesn't support weak symbols and is a bad fit with ELF. */
227 #undef NEW_HP_ASSEMBLER
228 #define NEW_HP_ASSEMBLER 1
230 /* It looks like DWARF2 will be the easiest debug format to handle on this
232 #define DWARF2_DEBUGGING_INFO 1
233 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
235 /* This target uses the ELF object file format. */
236 #define OBJECT_FORMAT_ELF
238 #undef TARGET_ASM_FILE_START
239 #define TARGET_ASM_FILE_START pa_hpux64_hpas_file_start
241 #undef TEXT_SECTION_ASM_OP
242 #define TEXT_SECTION_ASM_OP "\t.SUBSPA $CODE$\n"
243 #undef READONLY_DATA_SECTION_ASM_OP
244 #define READONLY_DATA_SECTION_ASM_OP "\t.SUBSPA $LIT$\n"
245 #undef DATA_SECTION_ASM_OP
246 #define DATA_SECTION_ASM_OP "\t.SUBSPA $DATA$\n"
247 #undef BSS_SECTION_ASM_OP
248 #define BSS_SECTION_ASM_OP "\t.SUBSPA $BSS$\n"
250 /* We provide explicit defines for CTORS_SECTION_ASM_OP and
251 DTORS_SECTION_ASM_OP since we don't yet have support for
252 named sections with the HP assembler. */
253 #undef CTORS_SECTION_ASM_OP
254 #define CTORS_SECTION_ASM_OP "\t.SUBSPA \\.ctors,QUAD=1,ALIGN=8,ACCESS=31"
255 #undef DTORS_SECTION_ASM_OP
256 #define DTORS_SECTION_ASM_OP "\t.SUBSPA \\.dtors,QUAD=1,ALIGN=8,ACCESS=31"
258 #define HP_INIT_ARRAY_SECTION_ASM_OP \
259 "\t.SUBSPA \\.init,QUAD=1,ALIGN=8,ACCESS=31"
260 #define GNU_INIT_ARRAY_SECTION_ASM_OP \
261 "\t.SUBSPA \\.init_array,QUAD=1,ALIGN=8,ACCESS=31"
262 #define HP_FINI_ARRAY_SECTION_ASM_OP \
263 "\t.SUBSPA \\.fini,QUAD=1,ALIGN=8,ACCESS=31"
264 #define GNU_FINI_ARRAY_SECTION_ASM_OP \
265 "\t.SUBSPA \\.fini_array,QUAD=1,ALIGN=8,ACCESS=31"
267 #endif /* USING_ELFOS_H */
269 /* The following defines, used to run constructors and destructors with
270 the SOM linker under HP-UX 11, are not needed. */
271 #undef HAS_INIT_SECTION
272 #undef LD_INIT_SWITCH
273 #undef LD_FINI_SWITCH
275 /* The following STARTFILE_SPEC and ENDFILE_SPEC defines provide the
276 magic needed to run initializers and finalizers. */
277 #undef STARTFILE_SPEC
278 #if TARGET_HPUX_11_11
279 #define STARTFILE_SPEC \
280 "%{!shared: %{!symbolic: crt0%O%s} %{munix=95:unix95.o%s} \
281 %{!munix=93:%{!munix=95:unix98%O%s}}} %{static:crtbeginT%O%s} \
282 %{!static:%{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}"
284 #define STARTFILE_SPEC \
285 "%{!shared: %{!symbolic: crt0%O%s} %{munix=95:unix95%O%s}} \
286 %{static:crtbeginT%O%s} %{!static:%{!shared:crtbegin%O%s} \
287 %{shared:crtbeginS%O%s}}"
290 #define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}"
292 /* Since HP uses the .init and .fini sections for array initializers
293 and finalizers, we need different defines for INIT_SECTION_ASM_OP
294 and FINI_SECTION_ASM_OP. With the implementation adopted below,
295 the sections are not actually used. However, we still must provide
296 defines to select the proper code path. */
297 #undef INIT_SECTION_ASM_OP
298 #define INIT_SECTION_ASM_OP
299 #undef FINI_SECTION_ASM_OP
300 #define FINI_SECTION_ASM_OP
302 /* We are using array initializers and don't want calls in the INIT
303 and FINI sections. */
304 #undef CRT_CALL_STATIC_FUNCTION
305 #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC)
307 /* The init_priority attribute is not supported with HP ld. This could be
308 supported if collect2 was used with LD_INIT_SWITCH. Unfortunately, this
309 approach doesn't work with GNU ld since HP-UX doesn't support DT_INIT,
310 and therefore the -init and -fini GNU ld switches. */
311 #undef SUPPORTS_INIT_PRIORITY
312 #define SUPPORTS_INIT_PRIORITY (TARGET_GNU_LD ? 1 : 0)
314 /* We use DTOR_LIST_BEGIN to carry a bunch of hacks to allow us to use
315 the init and fini array sections with both the HP and GNU linkers.
316 The linkers setup the required dynamic entries in the dynamic segment
317 and the dynamic linker does the calls. This approach avoids using
320 The first hack is to implement __do_global_ctors_aux in crtbegin as
321 it needs to be the first entry in the init array so that it is called
322 last. HP got the order of the init array backwards. The DT_INIT_ARRAY
323 is supposed to be executed in the same order as the addresses appear in
324 the array. DT_FINI_ARRAY is supposed to be executed in the opposite
327 The second hack is stubs for __cxa_finalize and _Jv_RegisterClasses.
328 The HP implementation of undefined weak symbols is broken. The linker
329 and dynamic loader both search for undefined weak symbols contrary the
330 generic System V ABI. An undefined weak symbol should resolve to a
331 value of 0 rather than causing an error. The prototypes for
332 __cxa_finalize and _Jv_RegisterClasses in crtstuff.c are weak when
333 weak is supported (GNU as), so in theory a strong define should override
334 the stub functions provided here.
336 The final hack is a set of plabels to implement the effect of
337 CRT_CALL_STATIC_FUNCTION. HP-UX 11 only supports DI_INIT_ARRAY and
338 DT_FINI_ARRAY and they put the arrays in .init and .fini, rather than
339 in .init_array and .fini_array. The standard defines for .init and
340 .fini have the execute flag set. So, the assembler has to be hacked
341 to munge the standard flags for these sections to make them agree
342 with what the HP linker expects. With the GNU linker, we need to
343 used the .init_array and .fini_array sections. So, we set up for
344 both just in case. Once we have built the table, the linker does
345 the rest of the work.
347 The order is significant. Placing __do_global_ctors_aux first in
348 the list, results in it being called last. User specified initializers,
349 either using the linker +init command or a plabel, run before the
350 initializers specified here. */
352 /* We need a __cxa_finalize stub if CRTSTUFFS_O is defined. */
354 #define PA_CXA_FINALIZE_STUB \
355 extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK; \
357 __cxa_finalize (void *p __attribute__((unused))) {}
359 #define PA_CXA_FINALIZE_STUB
362 /* We need a _Jv_RegisterClasses stub if JCR_SECTION_NAME is defined. */
363 #ifdef JCR_SECTION_NAME
364 #define PA_JV_REGISTERCLASSES_STUB \
366 _Jv_RegisterClasses (void *p __attribute__((unused))) {}
368 #define PA_JV_REGISTERCLASSES_STUB
371 /* We need to add frame_dummy to the initializer list if EH_FRAME_SECTION_NAME
372 or JCR_SECTION_NAME is defined. */
373 #if defined(EH_FRAME_SECTION_NAME) || defined(JCR_SECTION_NAME)
374 #define PA_INIT_FRAME_DUMMY_ASM_OP ".dword P%frame_dummy"
376 #define PA_INIT_FRAME_DUMMY_ASM_OP ""
379 #define PA_INIT_FINI_HACK \
380 static void __attribute__((used)) \
381 __do_global_ctors_aux (void) \
383 func_ptr *p = __CTOR_LIST__; \
386 for (; *p != (func_ptr) -1; p--) \
390 PA_CXA_FINALIZE_STUB \
391 PA_JV_REGISTERCLASSES_STUB \
393 asm (HP_INIT_ARRAY_SECTION_ASM_OP); \
394 asm (".dword P%__do_global_ctors_aux"); \
395 asm (PA_INIT_FRAME_DUMMY_ASM_OP); \
396 asm (GNU_INIT_ARRAY_SECTION_ASM_OP); \
397 asm (".dword P%__do_global_ctors_aux"); \
398 asm (PA_INIT_FRAME_DUMMY_ASM_OP); \
399 asm (HP_FINI_ARRAY_SECTION_ASM_OP); \
400 asm (".dword P%__do_global_dtors_aux"); \
401 asm (GNU_FINI_ARRAY_SECTION_ASM_OP); \
402 asm (".dword P%__do_global_dtors_aux")
404 /* The following two variants of DTOR_LIST_BEGIN are identical to those
405 in crtstuff.c except for the addition of the above init-fini hack. */
406 #ifdef DTORS_SECTION_ASM_OP
407 #define DTOR_LIST_BEGIN \
408 asm (DTORS_SECTION_ASM_OP); \
409 STATIC func_ptr __DTOR_LIST__[1] \
410 __attribute__ ((aligned(sizeof(func_ptr)))) \
411 = { (func_ptr) (-1) }; \
414 #define DTOR_LIST_BEGIN \
415 STATIC func_ptr __DTOR_LIST__[1] \
416 __attribute__ ((section(".dtors"), aligned(sizeof(func_ptr)))) \
417 = { (func_ptr) (-1) }; \
421 /* If using HP ld do not call pxdb. Use size as a program that does nothing
422 and returns 0. /bin/true cannot be used because it is a script without
424 #define INIT_ENVIRONMENT "LD_PXDB=/usr/ccs/bin/size"
426 /* The HPUX dynamic linker objects to weak symbols with no
427 definitions, so do not use them in gthr-posix.h. */
428 #define GTHREAD_USE_WEAK 0