summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnu/egcs/gcc/collect2.c53
-rw-r--r--gnu/egcs/gcc/gcc-local.114
2 files changed, 63 insertions, 4 deletions
diff --git a/gnu/egcs/gcc/collect2.c b/gnu/egcs/gcc/collect2.c
index 50bb9feb804..cad8dd45d78 100644
--- a/gnu/egcs/gcc/collect2.c
+++ b/gnu/egcs/gcc/collect2.c
@@ -195,6 +195,7 @@ int debug; /* true if -debug */
static int shared_obj; /* true if -shared */
+static int trace_ctors_dtors;
static char *c_file; /* <xxx>.c for constructor/destructor list. */
static char *o_file; /* <xxx>.o for constructor/destructor list. */
#ifdef COLLECT_EXPORT_LIST
@@ -1038,9 +1039,12 @@ main (argc, argv)
{
int i;
- for (i = 1; argv[i] != NULL; i ++)
+ for (i = 1; argv[i] != NULL; i ++) {
if (! strcmp (argv[i], "-debug"))
debug = 1;
+ if (! strcmp (argv[i], "-trace-ctors-dtors"))
+ trace_ctors_dtors = 1;
+ }
vflag = debug;
}
@@ -1369,6 +1373,14 @@ main (argc, argv)
ld1--;
}
break;
+ case 't':
+ if (!strcmp(arg, "-trace-ctors-dtors"))
+ {
+ /* Already parsed. */
+ ld1--;
+ ld2--;
+ }
+ break;
case 'v':
if (arg[2] == '\0')
@@ -2081,6 +2093,8 @@ write_c_file_stat (stream, name)
fprintf (stream, "\t}\n");
}
+ if (trace_ctors_dtors)
+ fprintf (stream, "#include <syslog.h>\n");
fprintf (stream, "void %s() {\n", initname);
if (constructors.number > 0 || frames)
{
@@ -2089,10 +2103,26 @@ write_c_file_stat (stream, name)
if (frames)
fprintf (stream, "\treg_frame,\n");
fprintf (stream, "\t};\n");
+ if (trace_ctors_dtors) {
+ struct id *list;
+ fprintf(stream, "\tstatic const char *names[] = {\n");
+ for (list = constructors.first; list; list = list->next)
+ fprintf (stream, "\t\t\"%s\",\n", list->name);
+ fprintf(stream, "\t};\n");
+ fprintf(stream, "\tconst char **n;\n");
+ fprintf(stream, "\tstruct syslog_data data = SYSLOG_DATA_INIT;\n");
+ }
fprintf (stream, "\tentry_pt **p;\n");
fprintf (stream, "\tif (count++ != 0) return;\n");
fprintf (stream, "\tp = ctors + %d;\n", constructors.number + frames);
- fprintf (stream, "\twhile (p > ctors) (*--p)();\n");
+ if (trace_ctors_dtors) {
+ fprintf(stream, "\tn = names + %d;\n", constructors.number + frames);
+ fprintf(stream, "\twhile (p > ctors) {\n");
+ fprintf(stream, "\t syslog_r(LOG_DEBUG, &data, \"%%s\", *(--n));\n");
+ fprintf(stream, "\t (*--p)();\n");
+ fprintf(stream, "\t}\n");
+ } else
+ fprintf (stream, "\twhile (p > ctors) (*--p)();\n");
}
else
fprintf (stream, "\t++count;\n");
@@ -2106,10 +2136,27 @@ write_c_file_stat (stream, name)
if (frames)
fprintf (stream, "\tdereg_frame,\n");
fprintf (stream, "\t};\n");
+ if (trace_ctors_dtors) {
+ struct id *list;
+ fprintf(stream, "\tstatic const char *names[] = {\n");
+ for (list = destructors.first; list; list = list->next)
+ fprintf (stream, "\t\t\"%s\",\n", list->name);
+ fprintf(stream, "\t};\n");
+ fprintf(stream, "\tconst char **n;\n");
+ fprintf(stream, "\tstruct syslog_data data = SYSLOG_DATA_INIT;\n");
+ }
fprintf (stream, "\tentry_pt **p;\n");
fprintf (stream, "\tif (--count != 0) return;\n");
fprintf (stream, "\tp = dtors;\n");
- fprintf (stream, "\twhile (p < dtors + %d) (*p++)();\n",
+ if (trace_ctors_dtors) {
+ fprintf(stream, "\tn = names;\n");
+ fprintf(stream, "\twhile (p < dtors + %d) {\n",
+ destructors.number + frames);
+ fprintf(stream, "\t syslog_r(LOG_DEBUG, &data, \"%%s\", *(n++));\n");
+ fprintf(stream, "\t (*p++)();\n");
+ fprintf(stream, "\t}\n");
+ } else
+ fprintf (stream, "\twhile (p < dtors + %d) (*p++)();\n",
destructors.number + frames);
}
fprintf (stream, "}\n");
diff --git a/gnu/egcs/gcc/gcc-local.1 b/gnu/egcs/gcc/gcc-local.1
index 274fc49b55b..19e89796b6b 100644
--- a/gnu/egcs/gcc/gcc-local.1
+++ b/gnu/egcs/gcc/gcc-local.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: gcc-local.1,v 1.5 2003/02/27 16:22:31 millert Exp $
+.\" $OpenBSD: gcc-local.1,v 1.6 2003/02/27 21:02:49 espie Exp $
.\"
.\" Copyright (c) 2002 Marc Espie
.\"
@@ -101,6 +101,18 @@ still uses
.Xr longjmp 3 -
style exceptions, and so needs extra fixes beyond the pure 2.95.3 release.
.It
+On some
+platforms (mostly a.out),
+.Nm gcc
+uses a linker wrapper to write stubs that call global constructors and
+destructors.
+On
+.Ox
+Those calls can be traced using
+.Fl Wl,-trace-ctors-dtors ,
+using
+.Xr syslog_r 3 .
+.It
On i386, the optimizer features an extra peephole which reduces the function
prologues enough to allow for the ramdisk to fit on one floppy.
.It