From 5f3d5c2bbb4757e9cc5b30bc66b1d7555739bc4a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 17 Jan 1996 02:29:57 +0000 Subject: * csu/initfini.c (_init): Call __gmon_start__ if defined (weak ref). * csu/gmon-start.c (__gmon_start__): Renamed from gmon_start, made global. [! HAVE_INITFINI]: Only make it a constructor in this case. --- csu/initfini.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'csu/initfini.c') diff --git a/csu/initfini.c b/csu/initfini.c index b0d0e68..a3c3b3b 100644 --- a/csu/initfini.c +++ b/csu/initfini.c @@ -63,6 +63,17 @@ SECTION (".init") void _init (void) { + /* We cannot use the normal constructor mechanism in gcrt1.o because it + appears before crtbegin.o in the link, so the header elt of .ctors + would come after the elt for __gmon_start__. One approach is for + gcrt1.o to reference a symbol which would be defined by some library + module which has a constructor; but then user code's constructors + would come first, and not be profiled. */ + extern void __gmon_start__ (void) __attribute__ ((weak)); + weak_symbol (__gmon_start__) + if (&__gmon_start__) + __gmon_start__ (); + /* End the here document containing the .init prologue code. Then fetch the .section directive just written and append that to crtn.s-new, followed by the function epilogue. */ -- cgit v1.1