]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/crtstuff.c
(reg_sign_bit_copies): New variable.
[gcc.git] / gcc / crtstuff.c
index e377d83ab7c54ac0b3f0ee30cd837158fae14b6d..0b8fc36b9acfbeefd5b010781258e8ecea21648e 100644 (file)
@@ -41,8 +41,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
    this file *will* make use of the .init section.  If that symbol is
    not defined however, then the .init section will not be used.
 
-   Currently, only ELF is actually supported.
-   The other formats probably need just alternative macro definitions.
+   Currently, only ELF and COFF are supported.  It is likely however that
+   ROSE could also be supported, if someone was willing to do the work to
+   make whatever (small?) adaptations are needed.  (Some work may be
+   needed on the ROSE assembler and linker also.)
 
    This file must be compiled with gcc.  */
 
@@ -53,10 +55,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "tm.h"
 
 #ifndef CTORS_SECTION_ASM_OP
-#define CTORS_SECTION_ASM_OP   "\t.section\t.ctors,\"a\",@progbits"
+#define CTORS_SECTION_ASM_OP   ".section\t.ctors,\"a\",@progbits"
 #endif
 #ifndef DTORS_SECTION_ASM_OP
-#define DTORS_SECTION_ASM_OP   "\t.section\t.dtors,\"a\",@progbits"
+#define DTORS_SECTION_ASM_OP   ".section\t.dtors,\"a\",@progbits"
 #endif
 
 #include "gbl-ctors.h"
@@ -69,8 +71,24 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #ifdef INIT_SECTION_ASM_OP
 
-/* Force cc1 to switch to .text section.  */
-static void force_to_text () { }
+/* The function __do_global_ctors_aux is compiled twice (once in crtbegin.o
+   and once in crtend.o).  It must be declared static to avoid a link
+   error.  Here, we define __do_global_ctors as an externally callable
+   function.  It is externally callable so that __main can invoke it when
+   INVOKE__main is defined.  This has the additional effect of forcing cc1
+   to switch to the .text section.  */
+static void __do_global_ctors_aux ();
+void __do_global_ctors ()
+{
+#ifdef INVOKE__main  /* If __main won't actually call __do_global_ctors
+                       then it doesn't matter what's inside the function.
+                       The inside of __do_global_ctors_aux is called
+                       automatically in that case.
+                       And the Alliant fx2800 linker crashes
+                       on this reference.  So prevent the crash.  */
+  __do_global_ctors_aux ();
+#endif
+}
 
 asm (INIT_SECTION_ASM_OP);     /* cc1 doesn't know that we are switching! */
 
@@ -90,7 +108,7 @@ asm (INIT_SECTION_ASM_OP);   /* cc1 doesn't know that we are switching! */
    file-scope static-storage C++ objects within shared libraries.   */
 
 static void
-__do_global_ctors ()           /* prologue goes in .init section */
+__do_global_ctors_aux ()       /* prologue goes in .init section */
 {
   asm (TEXT_SECTION_ASM_OP);   /* don't put epilogue and body in .init */
   DO_GLOBAL_CTORS_BODY;
@@ -104,11 +122,19 @@ static func_ptr force_to_data[0] = { };
 
 /* The -1 is a flag to __do_global_[cd]tors
    indicating that this table does not start with a count of elements.  */
+#ifdef CTOR_LIST_BEGIN
+CTOR_LIST_BEGIN;
+#else
 asm (CTORS_SECTION_ASM_OP);    /* cc1 doesn't know that we are switching! */
 func_ptr __CTOR_LIST__[1] = { (func_ptr) (-1) };
+#endif
 
+#ifdef DTOR_LIST_BEGIN
+DTOR_LIST_BEGIN;
+#else
 asm (DTORS_SECTION_ASM_OP);    /* cc1 doesn't know that we are switching! */
 func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) };
+#endif
 
 #endif /* defined(CRT_BEGIN) */
 
@@ -129,7 +155,7 @@ func_ptr __DTOR_LIST__[1] = { (func_ptr) (-1) };
 */
 
 static void
-__do_global_ctors ()           /* prologue goes in .text section */
+__do_global_ctors_aux ()       /* prologue goes in .text section */
 {
   asm (INIT_SECTION_ASM_OP);
   DO_GLOBAL_CTORS_BODY;
@@ -141,10 +167,18 @@ __do_global_ctors ()              /* prologue goes in .text section */
 /* Force cc1 to switch to .data section.  */
 static func_ptr force_to_data[0] = { };
 
+#ifdef CTOR_LIST_END
+CTOR_LIST_END;
+#else
 asm (CTORS_SECTION_ASM_OP);    /* cc1 doesn't know that we are switching! */
 func_ptr __CTOR_END__[1] = { (func_ptr) 0 };
+#endif
 
+#ifdef DTOR_LIST_END
+DTOR_LIST_END;
+#else
 asm (DTORS_SECTION_ASM_OP);    /* cc1 doesn't know that we are switching! */
 func_ptr __DTOR_END__[1] = { (func_ptr) 0 };
+#endif
 
 #endif /* defined(CRT_END) */
This page took 0.03162 seconds and 5 git commands to generate.