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