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