aboutsummaryrefslogtreecommitdiff
path: root/gcc/crtstuff.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/crtstuff.c')
-rw-r--r--gcc/crtstuff.c70
1 files changed, 52 insertions, 18 deletions
diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c
index ce2c9561e64..ccebde1d2c9 100644
--- a/gcc/crtstuff.c
+++ b/gcc/crtstuff.c
@@ -56,6 +56,34 @@ Boston, MA 02111-1307, USA. */
#include <stddef.h>
#include "frame.h"
+/* We do not want to add the weak attribute to the declarations of these
+ routines in frame.h because that will cause the definition of these
+ symbols to be weak as well.
+
+ This exposes a core issue, how to handle creating weak references vs
+ how to create weak definitions. Either we have to have the definition
+ of TARGET_WEAK_ATTRIBUTE be conditional in the shared header files or
+ have a second declaration if we want a function's references to be weak,
+ but not its definition.
+
+ Making TARGET_WEAK_ATTRIBUTE conditional seems like a good solution until
+ one thinks about scaling to larger problems -- ie, the condition under
+ which TARGET_WEAK_ATTRIBUTE is active will eventually get far too
+ complicated.
+
+ So, we take an approach similar to #pragma weak -- we have a second
+ declaration for functions that we want to have weak references.
+
+ Neither way is particularly good. */
+
+/* References to __register_frame_info and __deregister_frame_info should
+ be weak in this file if at all possible. */
+extern void __register_frame_info (void *, struct object *)
+ TARGET_ATTRIBUTE_WEAK;
+
+extern void *__deregister_frame_info (void *)
+ TARGET_ATTRIBUTE_WEAK;
+
#ifndef OBJECT_FORMAT_MACHO
/* Provide default definitions for the pseudo-ops used to switch to the
@@ -129,7 +157,7 @@ typedef void (*func_ptr) (void);
static char __EH_FRAME_BEGIN__[];
static func_ptr __DTOR_LIST__[];
static void
-__do_global_dtors_aux ()
+__do_global_dtors_aux (void)
{
static func_ptr *p = __DTOR_LIST__ + 1;
static int completed = 0;
@@ -144,7 +172,8 @@ __do_global_dtors_aux ()
}
#ifdef EH_FRAME_SECTION_ASM_OP
- __deregister_frame_info (__EH_FRAME_BEGIN__);
+ if (__deregister_frame_info)
+ __deregister_frame_info (__EH_FRAME_BEGIN__);
#endif
completed = 1;
}
@@ -153,7 +182,7 @@ __do_global_dtors_aux ()
/* Stick a call to __do_global_dtors_aux into the .fini section. */
static void __attribute__ ((__unused__))
-fini_dummy ()
+fini_dummy (void)
{
asm (FINI_SECTION_ASM_OP);
__do_global_dtors_aux ();
@@ -169,14 +198,15 @@ fini_dummy ()
call in another function. */
static void
-frame_dummy ()
+frame_dummy (void)
{
static struct object object;
- __register_frame_info (__EH_FRAME_BEGIN__, &object);
+ if (__register_frame_info)
+ __register_frame_info (__EH_FRAME_BEGIN__, &object);
}
static void __attribute__ ((__unused__))
-init_dummy ()
+init_dummy (void)
{
asm (INIT_SECTION_ASM_OP);
frame_dummy ();
@@ -197,7 +227,8 @@ init_dummy ()
to switch to the .text section. */
static void __do_global_ctors_aux ();
-void __do_global_ctors ()
+void
+__do_global_ctors (void)
{
#ifdef INVOKE__main /* If __main won't actually call __do_global_ctors
then it doesn't matter what's inside the function.
@@ -227,7 +258,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_aux () /* prologue goes in .init section */
+__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 */
@@ -249,14 +280,15 @@ __do_global_ctors_aux () /* prologue goes in .init section */
static char __EH_FRAME_BEGIN__[];
static func_ptr __DTOR_LIST__[];
void
-__do_global_dtors ()
+__do_global_dtors (void)
{
func_ptr *p;
for (p = __DTOR_LIST__ + 1; *p; p++)
(*p) ();
#ifdef EH_FRAME_SECTION_ASM_OP
- __deregister_frame_info (__EH_FRAME_BEGIN__);
+ if (__deregister_frame_info)
+ __deregister_frame_info (__EH_FRAME_BEGIN__);
#endif
}
@@ -265,10 +297,11 @@ __do_global_dtors ()
after libgcc.a, and hence can't call libgcc.a functions directly. That
can lead to unresolved function references. */
void
-__frame_dummy ()
+__frame_dummy (void)
{
static struct object object;
- __register_frame_info (__EH_FRAME_BEGIN__, &object);
+ if (__register_frame_info)
+ __register_frame_info (__EH_FRAME_BEGIN__, &object);
}
#endif
#endif
@@ -328,7 +361,7 @@ char __EH_FRAME_BEGIN__[] = { };
static func_ptr __CTOR_END__[];
static void
-__do_global_ctors_aux ()
+__do_global_ctors_aux (void)
{
func_ptr *p;
for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
@@ -338,7 +371,7 @@ __do_global_ctors_aux ()
/* Stick a call to __do_global_ctors_aux into the .init section. */
static void __attribute__ ((__unused__))
-init_dummy ()
+init_dummy (void)
{
asm (INIT_SECTION_ASM_OP);
__do_global_ctors_aux ();
@@ -387,7 +420,7 @@ init_dummy ()
before we start to execute any of the user's code. */
static void
-__do_global_ctors_aux () /* prologue goes in .text section */
+__do_global_ctors_aux (void) /* prologue goes in .text section */
{
asm (INIT_SECTION_ASM_OP);
DO_GLOBAL_CTORS_BODY;
@@ -413,7 +446,7 @@ static func_ptr __CTOR_END__[];
extern void __frame_dummy (void);
#endif
void
-__do_global_ctors ()
+__do_global_ctors (void)
{
func_ptr *p;
#ifdef EH_FRAME_SECTION_ASM_OP
@@ -489,7 +522,7 @@ extern const struct section *
static void __reg_frame_ctor () __attribute__ ((constructor));
static void
-__reg_frame_ctor ()
+__reg_frame_ctor (void)
{
static struct object object;
const struct section *eh_frame;
@@ -506,7 +539,8 @@ __reg_frame_ctor ()
static void __dereg_frame_dtor () __attribute__ ((destructor));
static
-void __dereg_frame_dtor ()
+void
+__dereg_frame_dtor (void)
{
const struct section *eh_frame;