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 GNU CC.
7 GNU CC 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 GNU CC 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 GNU CC; 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 "%{mhp-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:%{mhp-ld:-b}%{!mhp-ld:-shared}}"
43 "%{!mgnu-ld:+Accept TypeMismatch} -E %{mlinker-opt:-O} %{!shared:-u main} %{static:-a archive} %{shared:%{mgnu-ld:-shared}%{!mgnu-ld:-b}}"
46 /* Like the default, except no -lg. */
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"
55 /* Under hpux11, the normal location of the `ld' and `as' programs is the
56 /usr/ccs/bin directory. */
60 #define MD_EXEC_PREFIX "/usr/ccs/bin"
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. */
68 #undef MD_STARTFILE_PREFIX
69 #define MD_STARTFILE_PREFIX "/usr/ccs/lib/pa20_64/"
73 #undef MD_STARTFILE_PREFIX_1
74 #define MD_STARTFILE_PREFIX_1 "/opt/langtools/lib/pa20_64/"
77 /* Due to limitations in the target structure, it isn't currently possible
78 to dynamically switch between the GNU and HP assemblers. */
81 /* Configure selects the standard ELFOS defines for use with GAS. */
84 /* We are using GAS. */
88 #define ASM_FILE_START(FILE) \
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); \
97 fputs("\t.LEVEL 1.0\n", FILE); \
99 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, "_mcount", "function"); \
100 if (write_symbols != NO_DEBUG) \
102 output_file_directive ((FILE), main_input_filename); \
103 fputs ("\t.version\t\"01.01\"\n", FILE); \
107 /* This is how we output a null terminated string. */
109 #define STRING_ASM_OP "\t.stringz\t"
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"
115 #undef ASM_OUTPUT_ALIGNED_COMMON
116 #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \
119 assemble_name ((FILE), (NAME)); \
120 fputs ("\t.comm ", (FILE)); \
121 fprintf ((FILE), "%d\n", MAX ((SIZE), ((ALIGN) / BITS_PER_UNIT))); \
124 #undef ASM_OUTPUT_ALIGNED_LOCAL
125 #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
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)); \
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
137 /* This is how we globalize a label. */
138 #define GLOBAL_ASM_OP "\t.globl\t"
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) \
144 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \
145 ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \
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) \
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"); \
159 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \
160 TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL)) = save_referenced;\
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
167 #undef ASM_OUTPUT_EXTERNAL_LIBCALL
168 #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \
170 if (!FUNCTION_NAME_P (XSTR (FUN, 0))) \
171 hppa_encode_label (FUN); \
172 ASM_OUTPUT_TYPE_DIRECTIVE (FILE, XSTR (FUN, 0), "function"); \
175 /* We need to use the HP style for internal labels. */
176 #undef ASM_OUTPUT_INTERNAL_LABEL
177 #define ASM_OUTPUT_INTERNAL_LABEL(FILE, PREFIX, NUM) \
178 fprintf (FILE, "%c$%s%04d\n", (PREFIX)[0], (PREFIX) + 1, NUM)
180 #undef ASM_GENERATE_INTERNAL_LABEL
181 #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \
182 sprintf (LABEL, "*%c$%s%04ld", (PREFIX)[0], (PREFIX) + 1, (long)(NUM))
184 #else /* USING_ELFOS_H */
186 /* We are not using GAS. */
189 /* HPUX 11 has the "new" HP assembler. It's still lousy, but it's a whole
190 lot better than the assembler shipped with older versions of hpux.
191 However, it doesn't support weak symbols and is a bad fit with ELF. */
192 #undef NEW_HP_ASSEMBLER
193 #define NEW_HP_ASSEMBLER 1
195 /* It looks like DWARF2 will be the easiest debug format to handle on this
197 #define DWARF2_DEBUGGING_INFO 1
198 #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
200 /* This target uses the ELF object file format. */
201 #define OBJECT_FORMAT_ELF
203 #undef ASM_FILE_START
204 #define ASM_FILE_START(FILE) \
207 fputs("\t.LEVEL 2.0w\n", FILE); \
208 else if (TARGET_PA_20) \
209 fputs("\t.LEVEL 2.0\n", FILE); \
210 else if (TARGET_PA_11) \
211 fputs("\t.LEVEL 1.1\n", FILE); \
213 fputs("\t.LEVEL 1.0\n", FILE); \
214 fputs("\t.SPACE $PRIVATE$,SORT=16\n\
215 \t.SUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31\n\
216 \t.SUBSPA $BSS$,QUAD=1,ALIGN=8,ACCESS=31,ZERO,SORT=82\n\
217 \t.SPACE $TEXT$,SORT=8\n\
218 \t.SUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=44\n\
219 \t.SUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \
221 fprintf (FILE, "\t.IMPORT _mcount, CODE\n"); \
222 if (write_symbols != NO_DEBUG) \
223 output_file_directive ((FILE), main_input_filename); \
226 #undef TEXT_SECTION_ASM_OP
227 #define TEXT_SECTION_ASM_OP "\t.SUBSPA $CODE$\n"
228 #undef READONLY_DATA_SECTION_ASM_OP
229 #define READONLY_DATA_SECTION_ASM_OP "\t.SUBSPA $LIT$\n"
230 #undef DATA_SECTION_ASM_OP
231 #define DATA_SECTION_ASM_OP "\t.SUBSPA $DATA$\n"
232 #undef BSS_SECTION_ASM_OP
233 #define BSS_SECTION_ASM_OP "\t.SUBSPA $BSS$\n"
235 #endif /* USING_ELFOS_H */
237 /* For the time being, we aren't using init sections. `P' relocations
238 are currently used for function references. However, P relocations are
239 treated as data references and data references are bound by dld.sl
240 immediately at program startup. This causes an abort due to undefined
241 weak symbols in crtbegin.o (e.g., __register_frame_info). Possibly
242 Q relocations might avoid this problem but the GNU assembler doesn't
244 #undef INIT_SECTION_ASM_OP
245 #undef FINI_SECTION_ASM_OP
247 #define EH_FRAME_IN_DATA_SECTION 1
250 #define ENDFILE_SPEC ""
252 #undef STARTFILE_SPEC
253 #define STARTFILE_SPEC "%{!shared: %{!symbolic: crt0.o%s}}"
255 /* Since we are not yet using .init and .fini sections, we need to
256 explicitly arrange to run the global constructors and destructors.
257 We could use ldd for this but it depends on LD_LIBRARY_PATH being
258 correctly set. So, we use the ld init and fini switches. However,
259 we need to support different switches for the GNU and HP linkers.
260 We can't check TARGET_GNU_LD in collect2, so we need a different
261 test. The +Accept switch is always the first switch when we are
262 using the HP linker (see define for LINK_SPEC). Checking for it
263 is a somewhat fragile as it depends on internal details of the
264 collect2 program but it is better than testing ld_file_name.
266 FIXME: The GNU linker is broken. The -init/-fini switches don't
267 work and ldd can't determine the dynamic dependences of executables
268 linked with GNU ld. The init and fini routines are not executed
269 although DT_INIT and DT_FINI appear ok. As a result, defining
270 LD_INIT_SWITCH and LD_FINI_SWITCH causes more harm than good when
271 using GNU ld. However, the definitions appear to work fine with
274 #define LD_INIT_SWITCH (strcmp ("+Accept", ld2_argv[1]) ? "-init" : "+init")
275 #define LD_FINI_SWITCH (strcmp ("+Accept", ld2_argv[1]) ? "-fini" : "+fini")
278 /* If using HP ld do not call pxdb. Use size as a program that does nothing
279 and returns 0. /bin/true cannot be used because it is a script without
281 #define INIT_ENVIRONMENT "LD_PXDB=/usr/ccs/bin/size"