aboutsummaryrefslogtreecommitdiff
path: root/gcc/crtstuff.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2002-01-27 04:18:12 +0000
committerRichard Henderson <rth@redhat.com>2002-01-27 04:18:12 +0000
commit4ab9bee2f691e85b76ecfb2650297adad1fc234b (patch)
treee5878dd8630022a33d8797b199100a5b12fc5c7f /gcc/crtstuff.c
parent456bc62fa037cc93b62979fc35c6add46b61a313 (diff)
* Makefile.in (CRTSTUFF_CFLAGS): New.
(crtbegin.o, crtend.o, crtbeginS.o, crtendS.o, crtbeginT.o): Use it. * config.gcc (alpha-linux, alpha-freebsd, alpha-netbsd): Use plain crtstuff.c instead of alpha assembly version. * crtstuff.c (CRT_CALL_STATIC_FUNCTION): Rewrite to assume the entire dummy function sequence. Use FORCE_CODE_SECTION_ALIGN not FORCE_{INIT,FINI}_SECTION_ALIGN. (__do_global_dtors_aux): Mark used. (frame_dummy, __do_global_ctors_aux): Mark used. (fini_dummy, init_dummy): Remove. * config/alpha/crtbegin.asm: Remove file. * config/alpha/crtend.asm: Remove file. * config/alpha/t-crtbe: Remove file. * config/alpha/elf.h (CRT_CALL_STATIC_FUNCTION): New. (LINK_EH_SPEC): New. * config/cris/cris.h (CRT_CALL_STATIC_FUNCTION): Rewrite old FORCE_INIT_SECTION_ALIGN hack. Register __fini_start before calling constructors. * config/cris/linux.h (CRT_CALL_STATIC_FUNCTION): Undef. * config/i386/i386.h (CRT_CALL_STATIC_FUNCTION): New. * config/i386/linux.h (CRT_CALL_STATIC_FUNCTION): Replace old CRT_END_INIT_DUMMY hack. * config/i386/sol2.h (FORCE_CODE_SECTION_ALIGN): Replace FORCE_{INIT,FINI}_SECTION_ALIGN. * config/mcore/mcore-elf.h (FORCE_CODE_SECTION_ALIGN): Replace FORCE_{INIT,FINI}_SECTION_ALIGN. * config/s390/s390.h (CRT_CALL_STATIC_FUNCTION): Update for new invocation sequence. * config/sh/sh.h (CRT_CALL_STATIC_FUNCTION): Likewise. * doc/tm.texi (CRT_CALL_STATIC_FUNCTION): Update. (FORCE_CODE_SECTION_ALIGN): New. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@49261 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/crtstuff.c')
-rw-r--r--gcc/crtstuff.c76
1 files changed, 24 insertions, 52 deletions
diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c
index 4c6fc58c0e6..e3b2607ea5d 100644
--- a/gcc/crtstuff.c
+++ b/gcc/crtstuff.c
@@ -1,7 +1,7 @@
/* Specialized bits of code needed to support construction and
destruction of file-scope objects in C++ code.
Copyright (C) 1991, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Ron Guilmette (rfg@monkeys.com).
This file is part of GCC.
@@ -62,8 +62,20 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "tsystem.h"
#include "unwind-dw2-fde.h"
+#ifndef FORCE_CODE_SECTION_ALIGN
+# define FORCE_CODE_SECTION_ALIGN
+#endif
+
#ifndef CRT_CALL_STATIC_FUNCTION
-# define CRT_CALL_STATIC_FUNCTION(func) func ()
+# define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \
+static void __attribute__((__used__)) \
+call_ ## FUNC (void) \
+{ \
+ asm (SECTION_OP); \
+ FUNC (); \
+ FORCE_CODE_SECTION_ALIGN \
+ asm (TEXT_SECTION_ASM_OP); \
+}
#endif
#if defined(OBJECT_FORMAT_ELF) && defined(HAVE_LD_EH_FRAME_HDR) \
@@ -237,11 +249,11 @@ extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK;
the list we left off processing, and we resume at that point,
should we be re-invoked. */
-static void
+static void __attribute__((used))
__do_global_dtors_aux (void)
{
static func_ptr *p = __DTOR_LIST__ + 1;
- static int completed;
+ static _Bool completed;
func_ptr f;
if (__builtin_expect (completed, 0))
@@ -273,26 +285,15 @@ __do_global_dtors_aux (void)
completed = 1;
}
-
/* Stick a call to __do_global_dtors_aux into the .fini section. */
-
-static void __attribute__ ((__unused__))
-fini_dummy (void)
-{
- asm (FINI_SECTION_ASM_OP);
- CRT_CALL_STATIC_FUNCTION (__do_global_dtors_aux);
-#ifdef FORCE_FINI_SECTION_ALIGN
- FORCE_FINI_SECTION_ALIGN;
-#endif
- asm (TEXT_SECTION_ASM_OP);
-}
+CRT_CALL_STATIC_FUNCTION (FINI_SECTION_ASM_OP, __do_global_dtors_aux)
#if defined(USE_EH_FRAME_REGISTRY) || defined(JCR_SECTION_NAME)
/* Stick a call to __register_frame_info into the .init section. For some
reason calls with no arguments work more reliably in .init, so stick the
call in another function. */
-static void
+static void __attribute__((used))
frame_dummy (void)
{
#ifdef USE_EH_FRAME_REGISTRY
@@ -322,16 +323,7 @@ frame_dummy (void)
#endif /* JCR_SECTION_NAME */
}
-static void __attribute__ ((__unused__))
-init_dummy (void)
-{
- asm (INIT_SECTION_ASM_OP);
- CRT_CALL_STATIC_FUNCTION (frame_dummy);
-#ifdef FORCE_INIT_SECTION_ALIGN
- FORCE_INIT_SECTION_ALIGN;
-#endif
- asm (TEXT_SECTION_ASM_OP);
-}
+CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, frame_dummy)
#endif /* EH_FRAME_SECTION_NAME || JCR_SECTION_NAME */
#else /* OBJECT_FORMAT_ELF */
@@ -373,12 +365,10 @@ asm (INIT_SECTION_ASM_OP); /* cc1 doesn't know that we are switching! */
such a thing) so that we can properly perform the construction of
file-scope static-storage C++ objects within shared libraries. */
-static void
+static void __attribute__((used))
__do_global_ctors_aux (void) /* prologue goes in .init section */
{
-#ifdef FORCE_INIT_SECTION_ALIGN
- FORCE_INIT_SECTION_ALIGN; /* Explicit align before switch to .text */
-#endif
+ FORCE_CODE_SECTION_ALIGN /* explicit align before switch to .text */
asm (TEXT_SECTION_ASM_OP); /* don't put epilogue and body in .init */
DO_GLOBAL_CTORS_BODY;
atexit (__do_global_dtors);
@@ -486,8 +476,7 @@ STATIC void *__JCR_END__[1]
#ifdef INIT_SECTION_ASM_OP
#ifdef OBJECT_FORMAT_ELF
-
-static void
+static void __attribute__((used))
__do_global_ctors_aux (void)
{
func_ptr *p;
@@ -496,21 +485,7 @@ __do_global_ctors_aux (void)
}
/* Stick a call to __do_global_ctors_aux into the .init section. */
-
-static void __attribute__ ((__unused__))
-init_dummy (void)
-{
- asm (INIT_SECTION_ASM_OP);
- CRT_CALL_STATIC_FUNCTION (__do_global_ctors_aux);
-#ifdef FORCE_INIT_SECTION_ALIGN
- FORCE_INIT_SECTION_ALIGN;
-#endif
- asm (TEXT_SECTION_ASM_OP);
-#ifdef CRT_END_INIT_DUMMY
- CRT_END_INIT_DUMMY;
-#endif
-}
-
+CRT_CALL_STATIC_FUNCTION (INIT_SECTION_ASM_OP, __do_global_ctors_aux)
#else /* OBJECT_FORMAT_ELF */
/* Stick the real initialization code, followed by a normal sort of
@@ -542,10 +517,7 @@ __do_global_ctors_aux (void) /* prologue goes in .text section */
atexit (__do_global_dtors);
} /* epilogue and body go in .init section */
-#ifdef FORCE_INIT_SECTION_ALIGN
-FORCE_INIT_SECTION_ALIGN;
-#endif
-
+FORCE_CODE_SECTION_ALIGN
asm (TEXT_SECTION_ASM_OP);
#endif /* OBJECT_FORMAT_ELF */