This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] collect2 ctor name mismatch
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 20 Jul 2002 23:21:45 -0400
- Subject: [PATCH] collect2 ctor name mismatch
For targets without init/fini or ctor/dtor sections, collect2 uses
the is_ctor_dtor function to build the list of constructors and
destructors. This function looks for special function names, e.g.,
GLOBAL__I_ for static constructors.
When init priority was added to G++, it generates names using:
/* Make ctor or dtor function. METHOD_TYPE may be 'I' or 'D'. */
if (initp != DEFAULT_INIT_PRIORITY)
{
char joiner;
#ifdef JOINER
joiner = JOINER;
#else
joiner = '_';
#endif
sprintf (type, "%c%c%.5u", method_type, joiner, initp);
}
Because "joiner" normally isn't an underscore, if a constructor has an
initialization priority, its name looks like
_GLOBAL__I$05000_foo
or
_GLOBAL__I.05000_foo
Note, that does not match GLOBAL__I_. Therefore, collect2 did not find
ctors and dtors, unless the target happened to define both
NO_DOLLAR_IN_LABEL and NO_DOT_IN_LABEL.
The following patch removes the trailing underscore from the
strings that is_ctor_dtor tries to match. I think that the string still
will not be confused with anything else and is in a protected namespace.
This should fix at least five G++ testsuite failures on AIX.
Thanks, David
* collect2.c (is_ctor_dtor): Remove trailing underscore from ctor
and dtor special strings.
Index: collect2.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/collect2.c,v
retrieving revision 1.135
diff -c -p -r1.135 collect2.c
*** collect2.c 29 Jun 2002 22:51:11 -0000 1.135
--- collect2.c 21 Jul 2002 03:07:26 -0000
*************** is_ctor_dtor (s)
*** 577,584 ****
const char *orig_s = s;
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 },
{ "GLOBAL__FI_", sizeof ("GLOBAL__FI_")-1, 3, 0 },
{ "GLOBAL__FD_", sizeof ("GLOBAL__FD_")-1, 4, 0 },
--- 577,584 ----
const char *orig_s = s;
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 },
{ "GLOBAL__FI_", sizeof ("GLOBAL__FI_")-1, 3, 0 },
{ "GLOBAL__FD_", sizeof ("GLOBAL__FD_")-1, 4, 0 },