]>
Commit | Line | Data |
---|---|---|
562445dd | 1 | /* Definitions of target machine for GNU compiler, for HPs running |
2 | HPUX using the 64bit runtime model. | |
f1717362 | 3 | Copyright (C) 1999-2016 Free Software Foundation, Inc. |
562445dd | 4 | |
5c1d8983 | 5 | This file is part of GCC. |
562445dd | 6 | |
5c1d8983 | 7 | GCC is free software; you can redistribute it and/or modify |
562445dd | 8 | it under the terms of the GNU General Public License as published by |
038d1e19 | 9 | the Free Software Foundation; either version 3, or (at your option) |
562445dd | 10 | any later version. |
11 | ||
5c1d8983 | 12 | GCC is distributed in the hope that it will be useful, |
562445dd | 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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
038d1e19 | 18 | along with GCC; see the file COPYING3. If not see |
19 | <http://www.gnu.org/licenses/>. */ | |
562445dd | 20 | |
21 | /* We can debug dynamically linked executables on hpux11; we also | |
85eccb17 | 22 | want dereferencing of a NULL pointer to cause a SEGV. Do not move |
23 | the "+Accept TypeMismatch" switch. We check for it in collect2 | |
24 | to determine which init/fini is needed. */ | |
562445dd | 25 | #undef LINK_SPEC |
b166f502 | 26 | #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD) |
27 | #define LINK_SPEC \ | |
ae204ba4 | 28 | "%{!shared:%{p:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\ |
bf776685 | 29 | %nwarning: consider linking with '-static' as system libraries with\n\ |
ae204ba4 | 30 | %n profiling support are only provided in archive format}}}\ |
31 | %{!shared:%{pg:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\ | |
bf776685 | 32 | %nwarning: consider linking with '-static' as system libraries with\n\ |
ae204ba4 | 33 | %n profiling support are only provided in archive format}}}\ |
24e8b77b | 34 | %{!shared:%{!static:%{rdynamic:-E}}}\ |
35 | %{mhp-ld:+Accept TypeMismatch -z} %{mlinker-opt:-O}\ | |
22ae655f | 36 | %{!shared:-u main %{!nostdlib:%{!nodefaultlibs:-u __cxa_finalize}}}\ |
ae204ba4 | 37 | %{static:-a archive} %{shared:%{mhp-ld:-b}%{!mhp-ld:-shared}}" |
b166f502 | 38 | #else |
562445dd | 39 | #define LINK_SPEC \ |
ae204ba4 | 40 | "%{!shared:%{p:-L/lib/pa20_64/libp -L/usr/lib/pa20_64/libp %{!static:\ |
bf776685 | 41 | %nwarning: consider linking with '-static' as system libraries with\n\ |
ae204ba4 | 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:\ | |
bf776685 | 44 | %nwarning: consider linking with '-static' as system libraries with\n\ |
ae204ba4 | 45 | %n profiling support are only provided in archive format}}}\ |
24e8b77b | 46 | %{!shared:%{!static:%{rdynamic:-E}}}\ |
47 | %{!mgnu-ld:+Accept TypeMismatch -z} %{mlinker-opt:-O}\ | |
22ae655f | 48 | %{!shared:-u main %{!nostdlib:%{!nodefaultlibs:-u __cxa_finalize}}}\ |
ae204ba4 | 49 | %{static:-a archive} %{shared:%{mgnu-ld:-shared}%{!mgnu-ld:-b}}" |
b166f502 | 50 | #endif |
562445dd | 51 | |
08404d9c | 52 | /* Profiling support is only provided in libc.a. However, libprof and |
53 | libgprof are only available in shared form on HP-UX 11.00. We use | |
54 | the shared form if we are using the GNU linker or an archive form | |
55 | isn't available. We also usually need to link with libdld and it's | |
56 | only available in shared form. */ | |
562445dd | 57 | #undef LIB_SPEC |
ce782e06 | 58 | #if ((TARGET_DEFAULT | TARGET_CPU_DEFAULT) & MASK_GNU_LD) |
59 | #define LIB_SPEC \ | |
60 | "%{!shared:\ | |
ca4c3545 | 61 | %{!p:%{!pg:%{fopenacc|fopenmp|ftree-parallelize-loops=*:\ |
62 | %{static:-a shared} -lrt %{static:-a archive}}\ | |
698b676d | 63 | %{mt|pthread:-lpthread} -lc\ |
dfdc9106 | 64 | %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ |
65 | %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ | |
ce782e06 | 66 | %{p:%{!pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\ |
544e9d05 | 67 | -lprof %{static:-a archive}\ |
ca4c3545 | 68 | %{fopenacc|fopenmp|ftree-parallelize-loops=*:\ |
69 | %{static:-a shared} -lrt %{static:-a archive}}\ | |
698b676d | 70 | %{mt|pthread:-lpthread} -lc\ |
dfdc9106 | 71 | %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ |
72 | %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ | |
ce782e06 | 73 | %{pg:%{static:%{!mhp-ld:-a shared}%{mhp-ld:-a archive_shared}}\ |
544e9d05 | 74 | -lgprof %{static:-a archive}\ |
ca4c3545 | 75 | %{fopenacc|fopenmp|ftree-parallelize-loops=*:\ |
76 | %{static:-a shared} -lrt %{static:-a archive}}\ | |
698b676d | 77 | %{mt|pthread:-lpthread} -lc\ |
dfdc9106 | 78 | %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ |
79 | %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ | |
99113fcf | 80 | %{shared:%{mt|pthread:-lpthread}}" |
ce782e06 | 81 | #else |
562445dd | 82 | #define LIB_SPEC \ |
83 | "%{!shared:\ | |
ca4c3545 | 84 | %{!p:%{!pg:%{fopenacc|fopenmp|ftree-parallelize-loops=*:\ |
85 | %{static:-a shared} -lrt %{static:-a archive}}\ | |
698b676d | 86 | %{mt|pthread:-lpthread} -lc\ |
dfdc9106 | 87 | %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ |
88 | %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ | |
08404d9c | 89 | %{p:%{!pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\ |
544e9d05 | 90 | -lprof %{static:-a archive}\ |
ca4c3545 | 91 | %{fopenacc|fopenmp|ftree-parallelize-loops=*:\ |
92 | %{static:-a shared} -lrt %{static:-a archive}}\ | |
698b676d | 93 | %{mt|pthread:-lpthread} -lc\ |
dfdc9106 | 94 | %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ |
95 | %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ | |
08404d9c | 96 | %{pg:%{static:%{mgnu-ld:-a shared}%{!mgnu-ld:-a archive_shared}}\ |
544e9d05 | 97 | -lgprof %{static:-a archive}\ |
ca4c3545 | 98 | %{fopenacc|fopenmp|ftree-parallelize-loops=*:\ |
99 | %{static:-a shared} -lrt %{static:-a archive}}\ | |
698b676d | 100 | %{mt|pthread:-lpthread} -lc\ |
dfdc9106 | 101 | %{static:%{!nolibdld:-a shared -ldld -a archive -lc}\ |
102 | %{!mt:%{!pthread:-a shared -lc -a archive}}}}}\ | |
99113fcf | 103 | %{shared:%{mt|pthread:-lpthread}}" |
ce782e06 | 104 | #endif |
562445dd | 105 | |
25e266ae | 106 | /* The libgcc_stub.a and milli.a libraries need to come last. */ |
107 | #undef LINK_GCC_C_SEQUENCE_SPEC | |
108 | #define LINK_GCC_C_SEQUENCE_SPEC "\ | |
109 | %G %L %G %{!nostdlib:%{!nodefaultlibs:%{!shared:-lgcc_stub}\ | |
2ff99232 | 110 | milli.a%s}}" |
25e266ae | 111 | |
562445dd | 112 | /* Under hpux11, the normal location of the `ld' and `as' programs is the |
113 | /usr/ccs/bin directory. */ | |
114 | ||
29d774d0 | 115 | #ifndef CROSS_DIRECTORY_STRUCTURE |
562445dd | 116 | #undef MD_EXEC_PREFIX |
29192431 | 117 | #define MD_EXEC_PREFIX "/usr/ccs/bin" |
562445dd | 118 | #endif |
119 | ||
8ab32933 | 120 | /* Default prefixes. */ |
121 | ||
122 | #undef STANDARD_STARTFILE_PREFIX_1 | |
123 | #define STANDARD_STARTFILE_PREFIX_1 "/lib/pa20_64/" | |
124 | ||
125 | #undef STANDARD_STARTFILE_PREFIX_2 | |
126 | #define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/pa20_64/" | |
127 | ||
29192431 | 128 | /* Under hpux11 the normal location of the various pa20_64 *crt*.o files |
129 | is the /usr/ccs/lib/pa20_64 directory. Some files may also be in the | |
130 | /opt/langtools/lib/pa20_64 directory. */ | |
562445dd | 131 | |
29d774d0 | 132 | #ifndef CROSS_DIRECTORY_STRUCTURE |
562445dd | 133 | #undef MD_STARTFILE_PREFIX |
29192431 | 134 | #define MD_STARTFILE_PREFIX "/usr/ccs/lib/pa20_64/" |
135 | #endif | |
136 | ||
29d774d0 | 137 | #ifndef CROSS_DIRECTORY_STRUCTURE |
29192431 | 138 | #undef MD_STARTFILE_PREFIX_1 |
139 | #define MD_STARTFILE_PREFIX_1 "/opt/langtools/lib/pa20_64/" | |
562445dd | 140 | #endif |
141 | ||
ff59d376 | 142 | /* This macro specifies the biggest alignment supported by the object |
143 | file format of this machine. | |
144 | ||
145 | The .align directive in the HP assembler allows alignments up to | |
146 | 4096 bytes. However, the maximum alignment of a global common symbol | |
33cd7888 | 147 | is 16 bytes using HP ld. Unfortunately, this macro doesn't provide |
148 | a method to check for common symbols. */ | |
ff59d376 | 149 | #undef MAX_OFILE_ALIGNMENT |
33cd7888 | 150 | #define MAX_OFILE_ALIGNMENT 32768 |
ff59d376 | 151 | |
9bd9af5d | 152 | /* Due to limitations in the target structure, it isn't currently possible |
153 | to dynamically switch between the GNU and HP assemblers. */ | |
154 | #undef TARGET_GAS | |
155 | ||
156 | /* Configure selects the standard ELFOS defines for use with GAS. */ | |
157 | #ifdef USING_ELFOS_H | |
158 | ||
159 | /* We are using GAS. */ | |
160 | #define TARGET_GAS 1 | |
562445dd | 161 | |
92c473b8 | 162 | #undef TARGET_ASM_FILE_START |
163 | #define TARGET_ASM_FILE_START pa_hpux64_gas_file_start | |
9bd9af5d | 164 | |
165 | /* This is how we output a null terminated string. */ | |
166 | #undef STRING_ASM_OP | |
167 | #define STRING_ASM_OP "\t.stringz\t" | |
168 | ||
169 | #define TEXT_SECTION_ASM_OP "\t.text" | |
170 | #define DATA_SECTION_ASM_OP "\t.data" | |
171 | #define BSS_SECTION_ASM_OP "\t.section\t.bss" | |
172 | ||
d59aa441 | 173 | #define JCR_SECTION_NAME ".jcr" |
174 | ||
de419443 | 175 | #define HP_INIT_ARRAY_SECTION_ASM_OP "\t.section\t.init" |
176 | #define GNU_INIT_ARRAY_SECTION_ASM_OP "\t.section\t.init_array" | |
177 | #define HP_FINI_ARRAY_SECTION_ASM_OP "\t.section\t.fini" | |
178 | #define GNU_FINI_ARRAY_SECTION_ASM_OP "\t.section\t.fini_array" | |
179 | ||
ff59d376 | 180 | /* We need to override the following two macros defined in elfos.h since |
181 | the .comm directive has a different syntax and it can't be used for | |
182 | local common symbols. */ | |
9bd9af5d | 183 | #undef ASM_OUTPUT_ALIGNED_COMMON |
184 | #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ | |
ff59d376 | 185 | pa_asm_output_aligned_common (FILE, NAME, SIZE, ALIGN) |
9bd9af5d | 186 | |
187 | #undef ASM_OUTPUT_ALIGNED_LOCAL | |
188 | #define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \ | |
ff59d376 | 189 | pa_asm_output_aligned_local (FILE, NAME, SIZE, ALIGN) |
9bd9af5d | 190 | |
191 | /* The define in pa.h doesn't work with the alias attribute. The | |
192 | default is ok with the following define for GLOBAL_ASM_OP. */ | |
193 | #undef TARGET_ASM_GLOBALIZE_LABEL | |
194 | ||
195 | /* This is how we globalize a label. */ | |
196 | #define GLOBAL_ASM_OP "\t.globl\t" | |
197 | ||
02604695 | 198 | /* Hacked version from defaults.h that uses assemble_name_raw |
199 | instead of assemble_name. A symbol in a type directive that | |
200 | isn't otherwise referenced doesn't cause the symbol to be | |
201 | placed in the symbol table of the assembled object. */ | |
202 | #undef ASM_OUTPUT_TYPE_DIRECTIVE | |
203 | #define ASM_OUTPUT_TYPE_DIRECTIVE(STREAM, NAME, TYPE) \ | |
204 | do { \ | |
205 | fputs (TYPE_ASM_OP, STREAM); \ | |
206 | assemble_name_raw (STREAM, NAME); \ | |
207 | fputs (", ", STREAM); \ | |
208 | fprintf (STREAM, TYPE_OPERAND_FMT, TYPE); \ | |
209 | putc ('\n', STREAM); \ | |
210 | } while (0) | |
211 | ||
9bd9af5d | 212 | /* Hacked version from elfos.h that doesn't output a label. */ |
213 | #undef ASM_DECLARE_FUNCTION_NAME | |
214 | #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ | |
215 | do { \ | |
216 | ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ | |
217 | ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ | |
218 | } while (0) | |
219 | ||
220 | /* The type of external references must be set correctly for the | |
221 | dynamic loader to work correctly. This is equivalent to the | |
222 | HP assembler's .IMPORT directive but relates more directly to | |
223 | ELF object file types. */ | |
429fcf75 | 224 | #undef ASM_OUTPUT_EXTERNAL |
02604695 | 225 | #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \ |
5f43b4f6 | 226 | pa_hpux_asm_output_external ((FILE), (DECL), (NAME)) |
227 | #define ASM_OUTPUT_EXTERNAL_REAL(FILE, DECL, NAME) \ | |
02604695 | 228 | do { \ |
229 | if (FUNCTION_NAME_P (NAME)) \ | |
230 | ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ | |
231 | else \ | |
232 | ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "object"); \ | |
8ee2e619 | 233 | default_elf_asm_output_external (FILE, DECL, NAME); \ |
9bd9af5d | 234 | } while (0) |
235 | ||
236 | /* We need set the type for external libcalls. Also note that not all | |
237 | libcall names are passed to targetm.encode_section_info (e.g., __main). | |
238 | Thus, we also have to do the section encoding if it hasn't been done | |
239 | already. */ | |
240 | #undef ASM_OUTPUT_EXTERNAL_LIBCALL | |
241 | #define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ | |
242 | do { \ | |
243 | if (!FUNCTION_NAME_P (XSTR (FUN, 0))) \ | |
e202682d | 244 | pa_encode_label (FUN); \ |
9bd9af5d | 245 | ASM_OUTPUT_TYPE_DIRECTIVE (FILE, XSTR (FUN, 0), "function"); \ |
246 | } while (0) | |
247 | ||
248 | /* We need to use the HP style for internal labels. */ | |
9bd9af5d | 249 | #undef ASM_GENERATE_INTERNAL_LABEL |
250 | #define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \ | |
251 | sprintf (LABEL, "*%c$%s%04ld", (PREFIX)[0], (PREFIX) + 1, (long)(NUM)) | |
252 | ||
253 | #else /* USING_ELFOS_H */ | |
254 | ||
255 | /* We are not using GAS. */ | |
256 | #define TARGET_GAS 0 | |
257 | ||
258 | /* HPUX 11 has the "new" HP assembler. It's still lousy, but it's a whole | |
259 | lot better than the assembler shipped with older versions of hpux. | |
260 | However, it doesn't support weak symbols and is a bad fit with ELF. */ | |
261 | #undef NEW_HP_ASSEMBLER | |
262 | #define NEW_HP_ASSEMBLER 1 | |
562445dd | 263 | |
264 | /* It looks like DWARF2 will be the easiest debug format to handle on this | |
265 | platform. */ | |
a4cad234 | 266 | #define DWARF2_DEBUGGING_INFO 1 |
562445dd | 267 | #define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG |
562445dd | 268 | |
9bd9af5d | 269 | /* This target uses the ELF object file format. */ |
270 | #define OBJECT_FORMAT_ELF | |
562445dd | 271 | |
92c473b8 | 272 | #undef TARGET_ASM_FILE_START |
273 | #define TARGET_ASM_FILE_START pa_hpux64_hpas_file_start | |
562445dd | 274 | |
9bd9af5d | 275 | #undef TEXT_SECTION_ASM_OP |
de419443 | 276 | #define TEXT_SECTION_ASM_OP "\t.SUBSPA $CODE$\n" |
9bd9af5d | 277 | #undef READONLY_DATA_SECTION_ASM_OP |
de419443 | 278 | #define READONLY_DATA_SECTION_ASM_OP "\t.SUBSPA $LIT$\n" |
9bd9af5d | 279 | #undef DATA_SECTION_ASM_OP |
de419443 | 280 | #define DATA_SECTION_ASM_OP "\t.SUBSPA $DATA$\n" |
9bd9af5d | 281 | #undef BSS_SECTION_ASM_OP |
de419443 | 282 | #define BSS_SECTION_ASM_OP "\t.SUBSPA $BSS$\n" |
283 | ||
284 | /* We provide explicit defines for CTORS_SECTION_ASM_OP and | |
285 | DTORS_SECTION_ASM_OP since we don't yet have support for | |
286 | named sections with the HP assembler. */ | |
287 | #undef CTORS_SECTION_ASM_OP | |
288 | #define CTORS_SECTION_ASM_OP "\t.SUBSPA \\.ctors,QUAD=1,ALIGN=8,ACCESS=31" | |
289 | #undef DTORS_SECTION_ASM_OP | |
290 | #define DTORS_SECTION_ASM_OP "\t.SUBSPA \\.dtors,QUAD=1,ALIGN=8,ACCESS=31" | |
291 | ||
292 | #define HP_INIT_ARRAY_SECTION_ASM_OP \ | |
293 | "\t.SUBSPA \\.init,QUAD=1,ALIGN=8,ACCESS=31" | |
294 | #define GNU_INIT_ARRAY_SECTION_ASM_OP \ | |
295 | "\t.SUBSPA \\.init_array,QUAD=1,ALIGN=8,ACCESS=31" | |
296 | #define HP_FINI_ARRAY_SECTION_ASM_OP \ | |
297 | "\t.SUBSPA \\.fini,QUAD=1,ALIGN=8,ACCESS=31" | |
298 | #define GNU_FINI_ARRAY_SECTION_ASM_OP \ | |
299 | "\t.SUBSPA \\.fini_array,QUAD=1,ALIGN=8,ACCESS=31" | |
562445dd | 300 | |
9bd9af5d | 301 | #endif /* USING_ELFOS_H */ |
562445dd | 302 | |
de419443 | 303 | /* The following defines, used to run constructors and destructors with |
304 | the SOM linker under HP-UX 11, are not needed. */ | |
305 | #undef HAS_INIT_SECTION | |
306 | #undef LD_INIT_SWITCH | |
307 | #undef LD_FINI_SWITCH | |
308 | ||
309 | /* The following STARTFILE_SPEC and ENDFILE_SPEC defines provide the | |
310 | magic needed to run initializers and finalizers. */ | |
311 | #undef STARTFILE_SPEC | |
637c9296 | 312 | #if TARGET_HPUX_11_31 |
313 | #define STARTFILE_SPEC \ | |
314 | "%{!shared: %{!symbolic: crt0%O%s} \ | |
315 | %{munix=95:unix95.o%s} %{munix=98:unix98.o%s} \ | |
316 | %{!munix=93:%{!munix=95:%{!munix=98:unix2003%O%s}}}} \ | |
317 | %{static:crtbeginT%O%s} \ | |
318 | %{!static:%{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}" | |
319 | #elif TARGET_HPUX_11_11 | |
de419443 | 320 | #define STARTFILE_SPEC \ |
8ab32933 | 321 | "%{!shared: %{!symbolic: crt0%O%s} %{munix=95:unix95.o%s} \ |
f5a2d4f6 | 322 | %{!munix=93:%{!munix=95:unix98%O%s}}} %{static:crtbeginT%O%s} \ |
8ab32933 | 323 | %{!static:%{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}" |
324 | #else | |
325 | #define STARTFILE_SPEC \ | |
326 | "%{!shared: %{!symbolic: crt0%O%s} %{munix=95:unix95%O%s}} \ | |
327 | %{static:crtbeginT%O%s} %{!static:%{!shared:crtbegin%O%s} \ | |
328 | %{shared:crtbeginS%O%s}}" | |
329 | #endif | |
de419443 | 330 | #undef ENDFILE_SPEC |
8ab32933 | 331 | #define ENDFILE_SPEC "%{!shared:crtend%O%s} %{shared:crtendS%O%s}" |
de419443 | 332 | |
333 | /* Since HP uses the .init and .fini sections for array initializers | |
334 | and finalizers, we need different defines for INIT_SECTION_ASM_OP | |
335 | and FINI_SECTION_ASM_OP. With the implementation adopted below, | |
336 | the sections are not actually used. However, we still must provide | |
337 | defines to select the proper code path. */ | |
9bd9af5d | 338 | #undef INIT_SECTION_ASM_OP |
7b139b05 | 339 | #define INIT_SECTION_ASM_OP "" |
9bd9af5d | 340 | #undef FINI_SECTION_ASM_OP |
de419443 | 341 | #define FINI_SECTION_ASM_OP |
342 | ||
343 | /* We are using array initializers and don't want calls in the INIT | |
344 | and FINI sections. */ | |
345 | #undef CRT_CALL_STATIC_FUNCTION | |
346 | #define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) | |
347 | ||
348 | /* The init_priority attribute is not supported with HP ld. This could be | |
349 | supported if collect2 was used with LD_INIT_SWITCH. Unfortunately, this | |
350 | approach doesn't work with GNU ld since HP-UX doesn't support DT_INIT, | |
351 | and therefore the -init and -fini GNU ld switches. */ | |
352 | #undef SUPPORTS_INIT_PRIORITY | |
353 | #define SUPPORTS_INIT_PRIORITY (TARGET_GNU_LD ? 1 : 0) | |
354 | ||
355 | /* We use DTOR_LIST_BEGIN to carry a bunch of hacks to allow us to use | |
356 | the init and fini array sections with both the HP and GNU linkers. | |
357 | The linkers setup the required dynamic entries in the dynamic segment | |
358 | and the dynamic linker does the calls. This approach avoids using | |
359 | collect2. | |
360 | ||
361 | The first hack is to implement __do_global_ctors_aux in crtbegin as | |
362 | it needs to be the first entry in the init array so that it is called | |
363 | last. HP got the order of the init array backwards. The DT_INIT_ARRAY | |
364 | is supposed to be executed in the same order as the addresses appear in | |
365 | the array. DT_FINI_ARRAY is supposed to be executed in the opposite | |
366 | order. | |
367 | ||
25e266ae | 368 | The second hack is a set of plabels to implement the effect of |
de419443 | 369 | CRT_CALL_STATIC_FUNCTION. HP-UX 11 only supports DI_INIT_ARRAY and |
370 | DT_FINI_ARRAY and they put the arrays in .init and .fini, rather than | |
371 | in .init_array and .fini_array. The standard defines for .init and | |
372 | .fini have the execute flag set. So, the assembler has to be hacked | |
373 | to munge the standard flags for these sections to make them agree | |
374 | with what the HP linker expects. With the GNU linker, we need to | |
375 | used the .init_array and .fini_array sections. So, we set up for | |
376 | both just in case. Once we have built the table, the linker does | |
377 | the rest of the work. | |
378 | ||
379 | The order is significant. Placing __do_global_ctors_aux first in | |
380 | the list, results in it being called last. User specified initializers, | |
381 | either using the linker +init command or a plabel, run before the | |
382 | initializers specified here. */ | |
383 | ||
d59aa441 | 384 | /* We need to add frame_dummy to the initializer list if EH_FRAME_SECTION_NAME |
de419443 | 385 | or JCR_SECTION_NAME is defined. */ |
d59aa441 | 386 | #if defined(EH_FRAME_SECTION_NAME) || defined(JCR_SECTION_NAME) |
de419443 | 387 | #define PA_INIT_FRAME_DUMMY_ASM_OP ".dword P%frame_dummy" |
388 | #else | |
389 | #define PA_INIT_FRAME_DUMMY_ASM_OP "" | |
390 | #endif | |
29192431 | 391 | |
25e266ae | 392 | /* The following hack sets up the .init, .init_array, .fini and |
393 | .fini_array sections. */ | |
394 | #define PA_CRTBEGIN_HACK \ | |
395 | asm (TEXT_SECTION_ASM_OP); \ | |
de419443 | 396 | static void __attribute__((used)) \ |
397 | __do_global_ctors_aux (void) \ | |
398 | { \ | |
399 | func_ptr *p = __CTOR_LIST__; \ | |
400 | while (*(p + 1)) \ | |
401 | p++; \ | |
402 | for (; *p != (func_ptr) -1; p--) \ | |
403 | (*p) (); \ | |
404 | } \ | |
405 | \ | |
de419443 | 406 | asm (HP_INIT_ARRAY_SECTION_ASM_OP); \ |
25e266ae | 407 | asm (".align 8"); \ |
de419443 | 408 | asm (".dword P%__do_global_ctors_aux"); \ |
409 | asm (PA_INIT_FRAME_DUMMY_ASM_OP); \ | |
410 | asm (GNU_INIT_ARRAY_SECTION_ASM_OP); \ | |
25e266ae | 411 | asm (".align 8"); \ |
de419443 | 412 | asm (".dword P%__do_global_ctors_aux"); \ |
413 | asm (PA_INIT_FRAME_DUMMY_ASM_OP); \ | |
414 | asm (HP_FINI_ARRAY_SECTION_ASM_OP); \ | |
25e266ae | 415 | asm (".align 8"); \ |
de419443 | 416 | asm (".dword P%__do_global_dtors_aux"); \ |
417 | asm (GNU_FINI_ARRAY_SECTION_ASM_OP); \ | |
25e266ae | 418 | asm (".align 8"); \ |
de419443 | 419 | asm (".dword P%__do_global_dtors_aux") |
420 | ||
421 | /* The following two variants of DTOR_LIST_BEGIN are identical to those | |
25e266ae | 422 | in crtstuff.c except for the addition of the above crtbegin hack. */ |
de419443 | 423 | #ifdef DTORS_SECTION_ASM_OP |
424 | #define DTOR_LIST_BEGIN \ | |
425 | asm (DTORS_SECTION_ASM_OP); \ | |
426 | STATIC func_ptr __DTOR_LIST__[1] \ | |
427 | __attribute__ ((aligned(sizeof(func_ptr)))) \ | |
428 | = { (func_ptr) (-1) }; \ | |
25e266ae | 429 | PA_CRTBEGIN_HACK |
de419443 | 430 | #else |
431 | #define DTOR_LIST_BEGIN \ | |
432 | STATIC func_ptr __DTOR_LIST__[1] \ | |
433 | __attribute__ ((section(".dtors"), aligned(sizeof(func_ptr)))) \ | |
434 | = { (func_ptr) (-1) }; \ | |
25e266ae | 435 | PA_CRTBEGIN_HACK |
85eccb17 | 436 | #endif |
c4ee3071 | 437 | |
438 | /* If using HP ld do not call pxdb. Use size as a program that does nothing | |
439 | and returns 0. /bin/true cannot be used because it is a script without | |
440 | an interpreter. */ | |
441 | #define INIT_ENVIRONMENT "LD_PXDB=/usr/ccs/bin/size" | |
120a2fed | 442 | |
25e266ae | 443 | /* The HPUX dynamic linker objects to undefined weak symbols, so do |
444 | not use them in gthr-posix.h. */ | |
120a2fed | 445 | #define GTHREAD_USE_WEAK 0 |
25e266ae | 446 | |
447 | /* We don't want undefined weak references to __register_frame_info, | |
448 | __deregister_frame_info, _Jv_RegisterClasses and __cxa_finalize | |
449 | introduced by crtbegin.o. The GNU linker only resolves weak | |
450 | references if they appear in a shared library. Thus, it would be | |
451 | impossible to create a static executable if the symbols were weak. | |
452 | So, the best solution seems to be to make the symbols strong and | |
453 | provide an archive library of empty stub functions. */ | |
454 | #define TARGET_ATTRIBUTE_WEAK |