]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/crtstuff.c
* sh.h (EXTRA_CONSTRAINT_Z): New macro.
[thirdparty/gcc.git] / gcc / crtstuff.c
CommitLineData
9d13f5c4 1/* Specialized bits of code needed to support construction and
2 destruction of file-scope objects in C++ code.
00059bc7 3 Copyright (C) 1991, 1994, 1995, 1996, 1997, 1998,
e1ff7102 4 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
31dcf09a 5 Contributed by Ron Guilmette (rfg@monkeys.com).
9d13f5c4 6
f12b58b3 7This file is part of GCC.
9d13f5c4 8
f12b58b3 9GCC is free software; you can redistribute it and/or modify it under
10the terms of the GNU General Public License as published by the Free
11Software Foundation; either version 2, or (at your option) any later
12version.
9d13f5c4 13
4c9b6e71 14In addition to the permissions in the GNU General Public License, the
15Free Software Foundation gives you unlimited permission to link the
16compiled version of this file into combinations with other programs,
17and to distribute those combinations without any restriction coming
18from the use of this file. (The General Public License restrictions
19do apply in other respects; for example, they cover modification of
20the file, and distribution when not linked into a combine
21executable.)
22
f12b58b3 23GCC is distributed in the hope that it will be useful, but WITHOUT ANY
24WARRANTY; without even the implied warranty of MERCHANTABILITY or
25FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26for more details.
9d13f5c4 27
28You should have received a copy of the GNU General Public License
f12b58b3 29along with GCC; see the file COPYING. If not, write to the Free
30Software Foundation, 59 Temple Place - Suite 330, Boston, MA
3102111-1307, USA. */
9d13f5c4 32
23573244 33/* This file is a bit like libgcc2.c in that it is compiled
9d13f5c4 34 multiple times and yields multiple .o files.
35
36 This file is useful on target machines where the object file format
37 supports multiple "user-defined" sections (e.g. COFF, ELF, ROSE). On
38 such systems, this file allows us to avoid running collect (or any
39 other such slow and painful kludge). Additionally, if the target
40 system supports a .init section, this file allows us to support the
41 linking of C++ code with a non-C++ main program.
42
43 Note that if INIT_SECTION_ASM_OP is defined in the tm.h file, then
44 this file *will* make use of the .init section. If that symbol is
45 not defined however, then the .init section will not be used.
46
5dd605c6 47 Currently, only ELF and COFF are supported. It is likely however that
48 ROSE could also be supported, if someone was willing to do the work to
49 make whatever (small?) adaptations are needed. (Some work may be
50 needed on the ROSE assembler and linker also.)
9d13f5c4 51
52 This file must be compiled with gcc. */
53
54/* It is incorrect to include config.h here, because this file is being
55 compiled for the target, and hence definitions concerning only the host
56 do not apply. */
57
d07e08fa 58/* We include auto-host.h here to get HAVE_GAS_HIDDEN. This is
59 supposedly valid even though this is a "target" file. */
60#include "auto-host.h"
d826737c 61#include "tconfig.h"
069631e1 62#include "tsystem.h"
df4b504c 63#include "unwind-dw2-fde.h"
9d13f5c4 64
e1ff7102 65#ifndef FORCE_CODE_SECTION_ALIGN
66# define FORCE_CODE_SECTION_ALIGN
67#endif
68
a815e00c 69#ifndef CRT_CALL_STATIC_FUNCTION
e1ff7102 70# define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
71static void __attribute__((__used__)) \
72call_ ## FUNC (void) \
73{ \
74 asm (SECTION_OP); \
75 FUNC (); \
76 FORCE_CODE_SECTION_ALIGN \
77 asm (TEXT_SECTION_ASM_OP); \
78}
a815e00c 79#endif
80
0d6378a9 81#if defined(OBJECT_FORMAT_ELF) && defined(HAVE_LD_EH_FRAME_HDR) \
3cfa3aba 82 && !defined(inhibit_libc) && !defined(CRTSTUFFT_O) \
0d6378a9 83 && defined(__GLIBC__) && __GLIBC__ >= 2
84#include <link.h>
85# if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
86 || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG)))
87# define USE_PT_GNU_EH_FRAME
88# endif
89#endif
90#if defined(EH_FRAME_SECTION_NAME) && !defined(USE_PT_GNU_EH_FRAME)
91# define USE_EH_FRAME_REGISTRY
92#endif
d5720b0c 93#if defined(EH_FRAME_SECTION_NAME) && defined(HAVE_LD_RO_RW_SECTION_MIXING)
94# define EH_FRAME_SECTION_CONST const
95#else
96# define EH_FRAME_SECTION_CONST
97#endif
0d6378a9 98
ee055d40 99/* We do not want to add the weak attribute to the declarations of these
df4b504c 100 routines in unwind-dw2-fde.h because that will cause the definition of
101 these symbols to be weak as well.
ee055d40 102
103 This exposes a core issue, how to handle creating weak references vs
104 how to create weak definitions. Either we have to have the definition
105 of TARGET_WEAK_ATTRIBUTE be conditional in the shared header files or
106 have a second declaration if we want a function's references to be weak,
107 but not its definition.
108
109 Making TARGET_WEAK_ATTRIBUTE conditional seems like a good solution until
110 one thinks about scaling to larger problems -- ie, the condition under
111 which TARGET_WEAK_ATTRIBUTE is active will eventually get far too
112 complicated.
113
114 So, we take an approach similar to #pragma weak -- we have a second
115 declaration for functions that we want to have weak references.
116
117 Neither way is particularly good. */
118
119/* References to __register_frame_info and __deregister_frame_info should
120 be weak in this file if at all possible. */
121extern void __register_frame_info (void *, struct object *)
122 TARGET_ATTRIBUTE_WEAK;
f6338f42 123extern void __register_frame_info_bases (void *, struct object *,
124 void *, void *)
125 TARGET_ATTRIBUTE_WEAK;
ee055d40 126extern void *__deregister_frame_info (void *)
127 TARGET_ATTRIBUTE_WEAK;
ce32d35f 128extern void *__deregister_frame_info_bases (void *)
129 TARGET_ATTRIBUTE_WEAK;
ee055d40 130
f313c0e1 131/* Likewise for _Jv_RegisterClasses. */
132extern void _Jv_RegisterClasses (void *) TARGET_ATTRIBUTE_WEAK;
133
b7c87ff2 134#ifdef OBJECT_FORMAT_ELF
135
136/* Declare a pointer to void function type. */
137typedef void (*func_ptr) (void);
138#define STATIC static
139
140#else /* OBJECT_FORMAT_ELF */
141
9d13f5c4 142#include "gbl-ctors.h"
143
b7c87ff2 144#define STATIC
145
146#endif /* OBJECT_FORMAT_ELF */
9d13f5c4 147
148#ifdef CRT_BEGIN
149
f313c0e1 150/* NOTE: In order to be able to support SVR4 shared libraries, we arrange
151 to have one set of symbols { __CTOR_LIST__, __DTOR_LIST__, __CTOR_END__,
152 __DTOR_END__ } per root executable and also one set of these symbols
153 per shared library. So in any given whole process image, we may have
154 multiple definitions of each of these symbols. In order to prevent
155 these definitions from conflicting with one another, and in order to
156 ensure that the proper lists are used for the initialization/finalization
157 of each individual shared library (respectively), we give these symbols
158 only internal (i.e. `static') linkage, and we also make it a point to
159 refer to only the __CTOR_END__ symbol in crtend.o and the __DTOR_LIST__
160 symbol in crtbegin.o, where they are defined. */
161
162/* The -1 is a flag to __do_global_[cd]tors indicating that this table
163 does not start with a count of elements. */
164#ifdef CTOR_LIST_BEGIN
165CTOR_LIST_BEGIN;
166#elif defined(CTORS_SECTION_ASM_OP)
167/* Hack: force cc1 to switch to .data section early, so that assembling
168 __CTOR_LIST__ does not undo our behind-the-back change to .ctors. */
169static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
170asm (CTORS_SECTION_ASM_OP);
171STATIC func_ptr __CTOR_LIST__[1]
172 __attribute__ ((__unused__, aligned(sizeof(func_ptr))))
173 = { (func_ptr) (-1) };
174#else
175STATIC func_ptr __CTOR_LIST__[1]
176 __attribute__ ((__unused__, section(".ctors"), aligned(sizeof(func_ptr))))
177 = { (func_ptr) (-1) };
178#endif /* __CTOR_LIST__ alternatives */
179
180#ifdef DTOR_LIST_BEGIN
181DTOR_LIST_BEGIN;
182#elif defined(DTORS_SECTION_ASM_OP)
183asm (DTORS_SECTION_ASM_OP);
184STATIC func_ptr __DTOR_LIST__[1]
185 __attribute__ ((aligned(sizeof(func_ptr))))
186 = { (func_ptr) (-1) };
187#else
188STATIC func_ptr __DTOR_LIST__[1]
189 __attribute__((section(".dtors"), aligned(sizeof(func_ptr))))
190 = { (func_ptr) (-1) };
191#endif /* __DTOR_LIST__ alternatives */
192
fabbeb08 193#ifdef USE_EH_FRAME_REGISTRY
f313c0e1 194/* Stick a label at the beginning of the frame unwind info so we can register
195 and deregister it with the exception handling library code. */
d5720b0c 196STATIC EH_FRAME_SECTION_CONST char __EH_FRAME_BEGIN__[]
f313c0e1 197 __attribute__((section(EH_FRAME_SECTION_NAME), aligned(4)))
198 = { };
fabbeb08 199#endif /* USE_EH_FRAME_REGISTRY */
f313c0e1 200
201#ifdef JCR_SECTION_NAME
202/* Stick a label at the beginning of the java class registration info
203 so we can register them properly. */
f313c0e1 204STATIC void *__JCR_LIST__[]
205 __attribute__ ((unused, section(JCR_SECTION_NAME), aligned(sizeof(void*))))
206 = { };
207#endif /* JCR_SECTION_NAME */
208
584907e7 209#ifdef INIT_SECTION_ASM_OP
210
b7c87ff2 211#ifdef OBJECT_FORMAT_ELF
212
39b6af4b 213/* Declare the __dso_handle variable. It should have a unique value
5be729c9 214 in every shared-object; in a main program its value is zero. The
215 object should in any case be protected. This means the instance
216 in one DSO or the main program is not used in another object. The
217 dynamic linker takes care of this. */
218
5be729c9 219#ifdef HAVE_GAS_HIDDEN
b4cf9ec1 220extern void *__dso_handle __attribute__ ((__visibility__ ("hidden")));
5be729c9 221#endif
39b6af4b 222#ifdef CRTSTUFFS_O
223void *__dso_handle = &__dso_handle;
224#else
225void *__dso_handle = 0;
226#endif
227
228/* The __cxa_finalize function may not be available so we use only a
229 weak declaration. */
230extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK;
231
b7c87ff2 232/* Run all the global destructors on exit from the program. */
233
234/* Some systems place the number of pointers in the first word of the
235 table. On SVR4 however, that word is -1. In all cases, the table is
236 null-terminated. On SVR4, we start from the beginning of the list and
237 invoke each per-compilation-unit destructor routine in order
238 until we find that null.
239
240 Note that this function MUST be static. There will be one of these
241 functions in each root executable and one in each shared library, but
242 although they all have the same code, each one is unique in that it
243 refers to one particular associated `__DTOR_LIST__' which belongs to the
113f9ca7 244 same particular root executable or shared library file.
245
246 On some systems, this routine is run more than once from the .fini,
247 when exit is called recursively, so we arrange to remember where in
248 the list we left off processing, and we resume at that point,
249 should we be re-invoked. */
b7c87ff2 250
e1ff7102 251static void __attribute__((used))
aedb00bf 252__do_global_dtors_aux (void)
b7c87ff2 253{
113f9ca7 254 static func_ptr *p = __DTOR_LIST__ + 1;
e1ff7102 255 static _Bool completed;
f6338f42 256 func_ptr f;
dade0711 257
f6338f42 258 if (__builtin_expect (completed, 0))
dade0711 259 return;
260
f4513b3d 261#ifdef CRTSTUFFS_O
262 if (__cxa_finalize)
39b6af4b 263 __cxa_finalize (__dso_handle);
f4513b3d 264#endif
39b6af4b 265
f6338f42 266 while ((f = *p))
113f9ca7 267 {
268 p++;
f6338f42 269 f ();
113f9ca7 270 }
d757b8c9 271
0d6378a9 272#ifdef USE_EH_FRAME_REGISTRY
ce32d35f 273#if defined(CRT_GET_RFIB_TEXT) || defined(CRT_GET_RFIB_DATA)
274 /* If we used the new __register_frame_info_bases interface,
275 make sure that we deregister from the same place. */
276 if (__deregister_frame_info_bases)
277 __deregister_frame_info_bases (__EH_FRAME_BEGIN__);
278#else
ee055d40 279 if (__deregister_frame_info)
280 __deregister_frame_info (__EH_FRAME_BEGIN__);
d757b8c9 281#endif
ce32d35f 282#endif
283
dade0711 284 completed = 1;
b7c87ff2 285}
286
287/* Stick a call to __do_global_dtors_aux into the .fini section. */
e1ff7102 288CRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux)
b7c87ff2 289
0d6378a9 290#if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
c4fa4c4d 291/* Stick a call to __register_frame_info into the .init section. For some
292 reason calls with no arguments work more reliably in .init, so stick the
293 call in another function. */
d757b8c9 294
e1ff7102 295static void __attribute__((used))
aedb00bf 296frame_dummy (void)
d757b8c9 297{
0d6378a9 298#ifdef USE_EH_FRAME_REGISTRY
ad87de1e 299 static struct object object;
f6338f42 300#if defined(CRT_GET_RFIB_TEXT) || defined(CRT_GET_RFIB_DATA)
301 void *tbase, *dbase;
302#ifdef CRT_GET_RFIB_TEXT
303 CRT_GET_RFIB_TEXT (tbase);
304#else
305 tbase = 0;
306#endif
307#ifdef CRT_GET_RFIB_DATA
308 CRT_GET_RFIB_DATA (dbase);
309#else
310 dbase = 0;
311#endif
312 if (__register_frame_info_bases)
313 __register_frame_info_bases (__EH_FRAME_BEGIN__, &object, tbase, dbase);
314#else
ee055d40 315 if (__register_frame_info)
316 __register_frame_info (__EH_FRAME_BEGIN__, &object);
f6338f42 317#endif
71fcebb2 318#endif /* USE_EH_FRAME_REGISTRY */
f313c0e1 319#ifdef JCR_SECTION_NAME
320 if (__JCR_LIST__[0] && _Jv_RegisterClasses)
321 _Jv_RegisterClasses (__JCR_LIST__);
322#endif /* JCR_SECTION_NAME */
d757b8c9 323}
324
e1ff7102 325CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, frame_dummy)
71fcebb2 326#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME */
d757b8c9 327
b7c87ff2 328#else /* OBJECT_FORMAT_ELF */
329
b13ae905 330/* The function __do_global_ctors_aux is compiled twice (once in crtbegin.o
d8fa92ab 331 and once in crtend.o). It must be declared static to avoid a link
b13ae905 332 error. Here, we define __do_global_ctors as an externally callable
333 function. It is externally callable so that __main can invoke it when
334 INVOKE__main is defined. This has the additional effect of forcing cc1
335 to switch to the .text section. */
a92771b8 336
205b5771 337static void __do_global_ctors_aux (void);
aedb00bf 338void
339__do_global_ctors (void)
84b64a19 340{
584907e7 341#ifdef INVOKE__main
342 /* If __main won't actually call __do_global_ctors then it doesn't matter
343 what's inside the function. The inside of __do_global_ctors_aux is
344 called automatically in that case. And the Alliant fx2800 linker
345 crashes on this reference. So prevent the crash. */
84b64a19 346 __do_global_ctors_aux ();
347#endif
348}
9d13f5c4 349
350asm (INIT_SECTION_ASM_OP); /* cc1 doesn't know that we are switching! */
351
3c67709e 352/* On some svr4 systems, the initial .init section preamble code provided in
353 crti.o may do something, such as bump the stack, which we have to
354 undo before we reach the function prologue code for __do_global_ctors
355 (directly below). For such systems, define the macro INIT_SECTION_PREAMBLE
a92771b8 356 to expand into the code needed to undo the actions of the crti.o file. */
3c67709e 357
358#ifdef INIT_SECTION_PREAMBLE
359 INIT_SECTION_PREAMBLE;
360#endif
361
9d13f5c4 362/* A routine to invoke all of the global constructors upon entry to the
363 program. We put this into the .init section (for systems that have
364 such a thing) so that we can properly perform the construction of
1e625a2e 365 file-scope static-storage C++ objects within shared libraries. */
9d13f5c4 366
e1ff7102 367static void __attribute__((used))
aedb00bf 368__do_global_ctors_aux (void) /* prologue goes in .init section */
9d13f5c4 369{
e1ff7102 370 FORCE_CODE_SECTION_ALIGN /* explicit align before switch to .text */
9d13f5c4 371 asm (TEXT_SECTION_ASM_OP); /* don't put epilogue and body in .init */
372 DO_GLOBAL_CTORS_BODY;
75d3a87b 373 atexit (__do_global_dtors);
9d13f5c4 374}
375
b7c87ff2 376#endif /* OBJECT_FORMAT_ELF */
8313a782 377
584907e7 378#elif defined(HAS_INIT_SECTION) /* ! INIT_SECTION_ASM_OP */
8313a782 379
380/* This case is used by the Irix 6 port, which supports named sections but
381 not an SVR4-style .fini section. __do_global_dtors can be non-static
d757b8c9 382 in this case because we protect it with -hidden_symbol. */
383
8313a782 384void
aedb00bf 385__do_global_dtors (void)
8313a782 386{
f6338f42 387 func_ptr *p, f;
388 for (p = __DTOR_LIST__ + 1; (f = *p); p++)
389 f ();
d757b8c9 390
0d6378a9 391#ifdef USE_EH_FRAME_REGISTRY
ee055d40 392 if (__deregister_frame_info)
393 __deregister_frame_info (__EH_FRAME_BEGIN__);
d757b8c9 394#endif
8313a782 395}
72ac783d 396
0d6378a9 397#if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
584907e7 398/* A helper function for __do_global_ctors, which is in crtend.o. Here
399 in crtbegin.o, we can reference a couple of symbols not visible there.
400 Plus, since we're before libgcc.a, we have no problems referencing
401 functions from there. */
72ac783d 402void
584907e7 403__do_global_ctors_1(void)
72ac783d 404{
0d6378a9 405#ifdef USE_EH_FRAME_REGISTRY
72ac783d 406 static struct object object;
ee055d40 407 if (__register_frame_info)
408 __register_frame_info (__EH_FRAME_BEGIN__, &object);
b13ae905 409#endif
2cee371f 410#ifdef JCR_SECTION_NAME
f313c0e1 411 if (__JCR_LIST__[0] && _Jv_RegisterClasses)
412 _Jv_RegisterClasses (__JCR_LIST__);
413#endif
414}
71fcebb2 415#endif /* USE_EH_FRAME_REGISTRY || JCR_SECTION_NAME */
2cee371f 416
584907e7 417#else /* ! INIT_SECTION_ASM_OP && ! HAS_INIT_SECTION */
418#error "What are you doing with crtstuff.c, then?"
419#endif
420
421#elif defined(CRT_END) /* ! CRT_BEGIN */
422
423/* Put a word containing zero at the end of each of our two lists of function
424 addresses. Note that the words defined here go into the .ctors and .dtors
425 sections of the crtend.o file, and since that file is always linked in
426 last, these words naturally end up at the very ends of the two lists
427 contained in these two sections. */
428
429#ifdef CTOR_LIST_END
430CTOR_LIST_END;
431#elif defined(CTORS_SECTION_ASM_OP)
432/* Hack: force cc1 to switch to .data section early, so that assembling
433 __CTOR_LIST__ does not undo our behind-the-back change to .ctors. */
434static func_ptr force_to_data[1] __attribute__ ((__unused__)) = { };
435asm (CTORS_SECTION_ASM_OP);
436STATIC func_ptr __CTOR_END__[1]
437 __attribute__((aligned(sizeof(func_ptr))))
438 = { (func_ptr) 0 };
439#else
440STATIC func_ptr __CTOR_END__[1]
441 __attribute__((section(".ctors"), aligned(sizeof(func_ptr))))
442 = { (func_ptr) 0 };
443#endif
444
445#ifdef DTOR_LIST_END
446DTOR_LIST_END;
447#elif defined(DTORS_SECTION_ASM_OP)
448asm (DTORS_SECTION_ASM_OP);
449STATIC func_ptr __DTOR_END__[1]
450 __attribute__ ((unused, aligned(sizeof(func_ptr))))
451 = { (func_ptr) 0 };
452#else
453STATIC func_ptr __DTOR_END__[1]
454 __attribute__((unused, section(".dtors"), aligned(sizeof(func_ptr))))
455 = { (func_ptr) 0 };
456#endif
9d13f5c4 457
584907e7 458#ifdef EH_FRAME_SECTION_NAME
459/* Terminate the frame unwind info section with a 4byte 0 as a sentinel;
460 this would be the 'length' field in a real FDE. */
d5720b0c 461STATIC EH_FRAME_SECTION_CONST int __FRAME_END__[]
584907e7 462 __attribute__ ((unused, mode(SI), section(EH_FRAME_SECTION_NAME),
463 aligned(4)))
464 = { 0 };
13c14f1c 465#endif /* EH_FRAME_SECTION_NAME */
584907e7 466
467#ifdef JCR_SECTION_NAME
468/* Null terminate the .jcr section array. */
469STATIC void *__JCR_END__[1]
470 __attribute__ ((unused, section(JCR_SECTION_NAME),
471 aligned(sizeof(void *))))
472 = { 0 };
473#endif /* JCR_SECTION_NAME */
9d13f5c4 474
475#ifdef INIT_SECTION_ASM_OP
476
b7c87ff2 477#ifdef OBJECT_FORMAT_ELF
e1ff7102 478static void __attribute__((used))
aedb00bf 479__do_global_ctors_aux (void)
b7c87ff2 480{
481 func_ptr *p;
482 for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
483 (*p) ();
484}
485
486/* Stick a call to __do_global_ctors_aux into the .init section. */
e1ff7102 487CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, __do_global_ctors_aux)
b7c87ff2 488#else /* OBJECT_FORMAT_ELF */
489
490/* Stick the real initialization code, followed by a normal sort of
491 function epilogue at the very end of the .init section for this
492 entire root executable file or for this entire shared library file.
493
494 Note that we use some tricks here to get *just* the body and just
495 a function epilogue (but no function prologue) into the .init
c3418f42 496 section of the crtend.o file. Specifically, we switch to the .text
b7c87ff2 497 section, start to define a function, and then we switch to the .init
498 section just before the body code.
499
500 Earlier on, we put the corresponding function prologue into the .init
501 section of the crtbegin.o file (which will be linked in first).
502
503 Note that we want to invoke all constructors for C++ file-scope static-
504 storage objects AFTER any other possible initialization actions which
505 may be performed by the code in the .init section contributions made by
506 other libraries, etc. That's because those other initializations may
507 include setup operations for very primitive things (e.g. initializing
508 the state of the floating-point coprocessor, etc.) which should be done
a92771b8 509 before we start to execute any of the user's code. */
9d13f5c4 510
511static void
aedb00bf 512__do_global_ctors_aux (void) /* prologue goes in .text section */
9d13f5c4 513{
514 asm (INIT_SECTION_ASM_OP);
515 DO_GLOBAL_CTORS_BODY;
75d3a87b 516 atexit (__do_global_dtors);
997d68fe 517} /* epilogue and body go in .init section */
518
e1ff7102 519FORCE_CODE_SECTION_ALIGN
997d68fe 520asm (TEXT_SECTION_ASM_OP);
9d13f5c4 521
b7c87ff2 522#endif /* OBJECT_FORMAT_ELF */
523
584907e7 524#elif defined(HAS_INIT_SECTION) /* ! INIT_SECTION_ASM_OP */
8313a782 525
526/* This case is used by the Irix 6 port, which supports named sections but
527 not an SVR4-style .init section. __do_global_ctors can be non-static
d757b8c9 528 in this case because we protect it with -hidden_symbol. */
584907e7 529extern void __do_global_ctors_1(void);
8313a782 530void
aedb00bf 531__do_global_ctors (void)
8313a782 532{
533 func_ptr *p;
0d6378a9 534#if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
584907e7 535 __do_global_ctors_1();
d757b8c9 536#endif
8313a782 537 for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
538 (*p) ();
539}
b7c87ff2 540
584907e7 541#else /* ! INIT_SECTION_ASM_OP && ! HAS_INIT_SECTION */
542#error "What are you doing with crtstuff.c, then?"
b13ae905 543#endif
9d13f5c4 544
584907e7 545#else /* ! CRT_BEGIN && ! CRT_END */
546#error "One of CRT_BEGIN or CRT_END must be defined."
b13ae905 547#endif