Bad linker behaviour

Jon Thackray
Tue Oct 7 02:50:00 GMT 1997 writes:
 > >Ah well, it turns out that this is caused by C++ attempted name
 > >mangling, and only happens in the case where the symbols can't be
 > >matched (which is the case in my example above, although it wasn't
 > >meant to be). So, the end result is that for symbols which get name
 > >mangled like this, the error messages from ld are rubbish. Is there
 > >any way of getting ld to give the real error message, instead of the
 > >message after the name mangling?
 > No, I'm afraid ld always demangles symbol names in error messages.
 > The place to fix this is the function demangle in ld/ldmisc.c.

Well, the obvious fix is:-

  res = cplus_demangle (string, DMGL_ANSI | DMGL_PARAMS);
  return res ? res : xstrdup (string);


  return xstrdup (string);

This means that all link failures will report the actual symbol name,
which may not be so good for C++ but will work better for all other
users of ld. If ld is invoked standalone, this is definitely the way
it should behave (I also object to it stripping a leading _ from the
names it reports, this is making an assumption that the object files
I've linked have come from a C compiler which is untrue in my case).
If ld wishes to be more sophisticated in the cases where it is invoked
from gcc or g++, then it should be given additional command line
information requesting this behaviour, rather than doing this by
For help on using this list (especially unsubscribing), send a message to
"" with one line of text: "help".

More information about the Cygwin mailing list