/* Collect static initialization info into data structures that can be
traversed by C++ initialization and finalization routines.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Contributed by Chris Smith (csmith@convex.com).
Heavily modified by Michael Meissner (meissner@cygnus.com),
Per Bothner (bothner@cygnus.com), and John Gilmore (gnu@cygnus.com).
/* This must match tree.h. */
#define DEFAULT_INIT_PRIORITY 65535
+#ifndef COLLECT_SHARED_INIT_FUNC
+#define COLLECT_SHARED_INIT_FUNC(STREAM, FUNC) \
+ fprintf ((STREAM), "void _GLOBAL__DI() {\n\t%s();\n}\n", (FUNC))
+#endif
+#ifndef COLLECT_SHARED_FINI_FUNC
+#define COLLECT_SHARED_FINI_FUNC(STREAM, FUNC) \
+ fprintf ((STREAM), "void _GLOBAL__DD() {\n\t%s();\n}\n", (FUNC))
+#endif
+
#if defined (LDD_SUFFIX) || SUNOS4_SHARED_LIBRARIES
#define SCAN_LIBRARIES
#endif
static struct path_prefix libpath_lib_dirs; /* directories in LIBPATH */
static struct path_prefix *libpaths[3] = {&cmdline_lib_dirs,
&libpath_lib_dirs, NULL};
-static const char *const libexts[3] = {"a", "so", NULL}; /* possible library extentions */
+static const char *const libexts[3] = {"a", "so", NULL}; /* possible library extensions */
#endif
static void handler PARAMS ((int));
static int is_in_args PARAMS ((const char *, const char **, const char **));
#endif
#ifdef COLLECT_EXPORT_LIST
+#if 0
static int is_in_list PARAMS ((const char *, struct id *));
+#endif
static void write_aix_file PARAMS ((FILE *, struct id *));
static char *resolve_lib_name PARAMS ((const char *));
static int ignore_library PARAMS ((const char *));
#endif
static char *extract_string PARAMS ((const char **));
\f
-#ifdef NO_DUP2
-int
+#ifndef HAVE_DUP2
+static int dup2 PARAMS ((int, int));
+static int
dup2 (oldfd, newfd)
int oldfd;
int newfd;
return fd;
}
-#endif
+#endif /* ! HAVE_DUP2 */
\f
/* Delete tempfiles and exit function. */
if (no_demangle)
result = 0;
else
- result = cplus_demangle (p, DMGL_PARAMS | DMGL_ANSI);
+ result = cplus_demangle (p, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
if (result)
{
struct names { const char *const name; const int len; const int ret;
const int two_underscores; };
- struct names *p;
+ const struct names *p;
int ch;
const char *orig_s = s;
- static struct names special[] = {
+ static const struct names special[] = {
{ "GLOBAL__I_", sizeof ("GLOBAL__I_")-1, 1, 0 },
{ "GLOBAL__D_", sizeof ("GLOBAL__D_")-1, 2, 0 },
{ "GLOBAL__F_", sizeof ("GLOBAL__F_")-1, 5, 0 },
*c_ptr++ = obstack_copy0 (&permanent_obstack, q, strlen (q));
if (strcmp (q, "-EL") == 0 || strcmp (q, "-EB") == 0)
*c_ptr++ = obstack_copy0 (&permanent_obstack, q, strlen (q));
- if (strncmp (q, "-shared", sizeof ("-shared") - 1) == 0)
+ if (strcmp (q, "-shared") == 0)
shared_obj = 1;
if (*q == '-' && q[1] == 'B')
{
dup2 (stdout_save, STDOUT_FILENO);
dup2 (stderr_save, STDERR_FILENO);
- /* Close reponse file. */
+ /* Close response file. */
close (redir_handle);
}
#ifdef COLLECT_EXPORT_LIST
/* This function is really used only on AIX, but may be useful. */
+#if 0
static int
is_in_list (prefix, list)
const char *prefix;
return 0;
}
#endif
+#endif /* COLLECT_EXPORT_LIST */
/* Added for debugging purpose. */
#ifdef COLLECT_EXPORT_LIST
if (shared_obj)
{
- fprintf (stream, "void _GLOBAL__DI() {\n\t%s();\n}\n", initname);
- fprintf (stream, "void _GLOBAL__DD() {\n\t%s();\n}\n", fininame);
+ COLLECT_SHARED_INIT_FUNC(stream, initname);
+ COLLECT_SHARED_FINI_FUNC(stream, fininame);
}
}
(void) ldclose(ldptr);
#endif
}
-
+#endif /* OBJECT_FORMAT_COFF */
#ifdef COLLECT_EXPORT_LIST
/* Given a library name without "lib" prefix, this function
if (debug)
fprintf (stderr, "not found\n");
else
- fatal ("Library lib%s not found", name);
+ fatal ("library lib%s not found", name);
return (NULL);
}
if (! strcmp (name, *p)) return 1;
return 0;
}
-#endif
-
-#endif /* OBJECT_FORMAT_COFF */
+#endif /* COLLECT_EXPORT_LIST */
\f
/*