]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/pa/pa64-hpux.h
Merge basic-improvements-branch to trunk
[thirdparty/gcc.git] / gcc / config / pa / pa64-hpux.h
CommitLineData
a7e184fc
AM
1/* Definitions of target machine for GNU compiler, for HPs running
2 HPUX using the 64bit runtime model.
85e79f96 3 Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
a7e184fc
AM
4
5This file is part of GNU CC.
6
7GNU CC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU CC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU CC; see the file COPYING. If not, write to
19the Free Software Foundation, 59 Temple Place - Suite 330,
20Boston, MA 02111-1307, USA. */
21
83eb95f9
SE
22#undef SUBTARGET_SWITCHES
23#define SUBTARGET_SWITCHES \
24 { "sio", MASK_SIO, \
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") },
32
a7e184fc 33/* We can debug dynamically linked executables on hpux11; we also
08ec53e7
JDA
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. */
a7e184fc 37#undef LINK_SPEC
83eb95f9
SE
38#if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD)
39#define LINK_SPEC \
08ec53e7 40 "%{mhp-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:%{mhp-ld:-b}%{!mhp-ld:-shared}}"
83eb95f9 41#else
a7e184fc 42#define LINK_SPEC \
08ec53e7 43 "%{!mgnu-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:%{mgnu-ld:-shared}%{!mgnu-ld:-b}}"
83eb95f9 44#endif
a7e184fc
AM
45
46/* Like the default, except no -lg. */
47#undef LIB_SPEC
48#define LIB_SPEC \
49 "%{!shared:\
50 %{!p:\
a9b11d44
JDA
51 %{!pg: %{!threads:-lc} %{threads:-lcma -lc_r}}\
52 %{pg: -L/usr/lib/pa20_64/libp/ -lgprof -lc}}\
53 %{p: -L/usr/lib/pa20_64/libp/ -lprof -lc}} /usr/lib/pa20_64/milli.a"
a7e184fc
AM
54
55/* Under hpux11, the normal location of the `ld' and `as' programs is the
56 /usr/ccs/bin directory. */
57
58#ifndef CROSS_COMPILE
59#undef MD_EXEC_PREFIX
85e79f96 60#define MD_EXEC_PREFIX "/usr/ccs/bin"
a7e184fc
AM
61#endif
62
85e79f96
JDA
63/* Under hpux11 the normal location of the various pa20_64 *crt*.o files
64 is the /usr/ccs/lib/pa20_64 directory. Some files may also be in the
65 /opt/langtools/lib/pa20_64 directory. */
a7e184fc
AM
66
67#ifndef CROSS_COMPILE
68#undef MD_STARTFILE_PREFIX
85e79f96
JDA
69#define MD_STARTFILE_PREFIX "/usr/ccs/lib/pa20_64/"
70#endif
71
72#ifndef CROSS_COMPILE
73#undef MD_STARTFILE_PREFIX_1
74#define MD_STARTFILE_PREFIX_1 "/opt/langtools/lib/pa20_64/"
a7e184fc
AM
75#endif
76
581d9404
JDA
77/* Due to limitations in the target structure, it isn't currently possible
78 to dynamically switch between the GNU and HP assemblers. */
79#undef TARGET_GAS
80
81/* Configure selects the standard ELFOS defines for use with GAS. */
82#ifdef USING_ELFOS_H
83
84/* We are using GAS. */
85#define TARGET_GAS 1
a7e184fc
AM
86
87#undef ASM_FILE_START
88#define ASM_FILE_START(FILE) \
581d9404
JDA
89do { \
90 if (TARGET_64BIT) \
91 fputs("\t.LEVEL 2.0w\n", FILE); \
92 else if (TARGET_PA_20) \
93 fputs("\t.LEVEL 2.0\n", FILE); \
94 else if (TARGET_PA_11) \
95 fputs("\t.LEVEL 1.1\n", FILE); \
96 else \
97 fputs("\t.LEVEL 1.0\n", FILE); \
98 if (profile_flag) \
99 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, "_mcount", "function"); \
100 if (write_symbols != NO_DEBUG) \
101 { \
102 output_file_directive ((FILE), main_input_filename); \
103 fputs ("\t.version\t\"01.01\"\n", FILE); \
104 } \
105} while (0)
106
107/* This is how we output a null terminated string. */
108#undef STRING_ASM_OP
109#define STRING_ASM_OP "\t.stringz\t"
110
111#define TEXT_SECTION_ASM_OP "\t.text"
112#define DATA_SECTION_ASM_OP "\t.data"
113#define BSS_SECTION_ASM_OP "\t.section\t.bss"
114
115#undef ASM_OUTPUT_ALIGNED_COMMON
116#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
117do { \
118 bss_section (); \
119 assemble_name ((FILE), (NAME)); \
120 fputs ("\t.comm ", (FILE)); \
121 fprintf ((FILE), "%d\n", MAX ((SIZE), ((ALIGN) / BITS_PER_UNIT))); \
122} while (0)
123
124#undef ASM_OUTPUT_ALIGNED_LOCAL
125#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
126do { \
127 bss_section (); \
128 fprintf ((FILE), "\t.align %d\n", ((ALIGN) / BITS_PER_UNIT)); \
129 assemble_name ((FILE), (NAME)); \
130 fprintf ((FILE), "\n\t.block %d\n", (SIZE)); \
131} while (0)
132
133/* The define in pa.h doesn't work with the alias attribute. The
134 default is ok with the following define for GLOBAL_ASM_OP. */
135#undef TARGET_ASM_GLOBALIZE_LABEL
136
137/* This is how we globalize a label. */
138#define GLOBAL_ASM_OP "\t.globl\t"
139
140/* Hacked version from elfos.h that doesn't output a label. */
141#undef ASM_DECLARE_FUNCTION_NAME
142#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
143do { \
144 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
145 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
146} while (0)
147
148/* The type of external references must be set correctly for the
149 dynamic loader to work correctly. This is equivalent to the
150 HP assembler's .IMPORT directive but relates more directly to
151 ELF object file types. */
152#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
153do { \
154 int save_referenced; \
155 save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL));\
156 if (FUNCTION_NAME_P (NAME)) \
157 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
158 else \
159 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
160 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced;\
161} while (0)
162
163/* We need set the type for external libcalls. Also note that not all
164 libcall names are passed to targetm.encode_section_info (e.g., __main).
165 Thus, we also have to do the section encoding if it hasn't been done
166 already. */
167#undef ASM_OUTPUT_EXTERNAL_LIBCALL
168#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
169do { \
170 if (!FUNCTION_NAME_P (XSTR (FUN, 0))) \
171 hppa_encode_label (FUN); \
172 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, XSTR (FUN, 0), "function"); \
173} while (0)
174
175/* We need to use the HP style for internal labels. */
581d9404
JDA
176#undef ASM_GENERATE_INTERNAL_LABEL
177#define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
178 sprintf (LABEL, "*%c$%s%04ld", (PREFIX)[0], (PREFIX) + 1, (long)(NUM))
179
180#else /* USING_ELFOS_H */
181
182/* We are not using GAS. */
183#define TARGET_GAS 0
184
185/* HPUX 11 has the "new" HP assembler. It's still lousy, but it's a whole
186 lot better than the assembler shipped with older versions of hpux.
187 However, it doesn't support weak symbols and is a bad fit with ELF. */
188#undef NEW_HP_ASSEMBLER
189#define NEW_HP_ASSEMBLER 1
a7e184fc
AM
190
191/* It looks like DWARF2 will be the easiest debug format to handle on this
192 platform. */
23532de9 193#define DWARF2_DEBUGGING_INFO 1
a7e184fc 194#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
a7e184fc 195
581d9404
JDA
196/* This target uses the ELF object file format. */
197#define OBJECT_FORMAT_ELF
a7e184fc 198
581d9404
JDA
199#undef ASM_FILE_START
200#define ASM_FILE_START(FILE) \
201do { \
202 if (TARGET_64BIT) \
203 fputs("\t.LEVEL 2.0w\n", FILE); \
204 else if (TARGET_PA_20) \
205 fputs("\t.LEVEL 2.0\n", FILE); \
206 else if (TARGET_PA_11) \
207 fputs("\t.LEVEL 1.1\n", FILE); \
208 else \
209 fputs("\t.LEVEL 1.0\n", FILE); \
210 fputs("\t.SPACE $PRIVATE$,SORT=16\n\
211\t.SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31\n\
212\t.SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82\n\
213\t.SPACE $TEXT$,SORT=8\n\
214\t.SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44\n\
215\t.SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \
216 if (profile_flag) \
217 fprintf (FILE, "\t.IMPORT _mcount, CODE\n"); \
218 if (write_symbols != NO_DEBUG) \
219 output_file_directive ((FILE), main_input_filename); \
220} while (0)
a7e184fc 221
581d9404
JDA
222#undef TEXT_SECTION_ASM_OP
223#define TEXT_SECTION_ASM_OP "\t.SUBSPA $CODE$\n"
224#undef READONLY_DATA_SECTION_ASM_OP
225#define READONLY_DATA_SECTION_ASM_OP "\t.SUBSPA $LIT$\n"
226#undef DATA_SECTION_ASM_OP
227#define DATA_SECTION_ASM_OP "\t.SUBSPA $DATA$\n"
228#undef BSS_SECTION_ASM_OP
229#define BSS_SECTION_ASM_OP "\t.SUBSPA $BSS$\n"
a7e184fc 230
581d9404 231#endif /* USING_ELFOS_H */
a7e184fc 232
85e79f96
JDA
233/* For the time being, we aren't using init sections. `P' relocations
234 are currently used for function references. However, P relocations are
235 treated as data references and data references are bound by dld.sl
236 immediately at program startup. This causes an abort due to undefined
237 weak symbols in crtbegin.o (e.g., __register_frame_info). Possibly
238 Q relocations might avoid this problem but the GNU assembler doesn't
239 support them. */
581d9404
JDA
240#undef INIT_SECTION_ASM_OP
241#undef FINI_SECTION_ASM_OP
242
85e79f96
JDA
243#define EH_FRAME_IN_DATA_SECTION 1
244
245#undef ENDFILE_SPEC
246#define ENDFILE_SPEC ""
247
248#undef STARTFILE_SPEC
a9b11d44 249#define STARTFILE_SPEC "%{!shared: %{!symbolic: crt0.o%s}}"
81e5bc3d
JDA
250
251/* Since we are not yet using .init and .fini sections, we need to
252 explicitly arrange to run the global constructors and destructors.
08ec53e7
JDA
253 We could use ldd for this but it depends on LD_LIBRARY_PATH being
254 correctly set. So, we use the ld init and fini switches. However,
255 we need to support different switches for the GNU and HP linkers.
256 We can't check TARGET_GNU_LD in collect2, so we need a different
257 test. The +Accept switch is always the first switch when we are
258 using the HP linker (see define for LINK_SPEC). Checking for it
259 is a somewhat fragile as it depends on internal details of the
260 collect2 program but it is better than testing ld_file_name.
261
262 FIXME: The GNU linker is broken. The -init/-fini switches don't
263 work and ldd can't determine the dynamic dependences of executables
264 linked with GNU ld. The init and fini routines are not executed
265 although DT_INIT and DT_FINI appear ok. As a result, defining
266 LD_INIT_SWITCH and LD_FINI_SWITCH causes more harm than good when
267 using GNU ld. However, the definitions appear to work fine with
268 the HP linker. */
269#if 0
270#define LD_INIT_SWITCH (strcmp ("+Accept", ld2_argv[1]) ? "-init" : "+init")
271#define LD_FINI_SWITCH (strcmp ("+Accept", ld2_argv[1]) ? "-fini" : "+fini")
272#endif
882affa8
SE
273
274/* If using HP ld do not call pxdb. Use size as a program that does nothing
275 and returns 0. /bin/true cannot be used because it is a script without
276 an interpreter. */
277#define INIT_ENVIRONMENT "LD_PXDB=/usr/ccs/bin/size"