ld --wrap and c++

Ian Lance Taylor ian@wasabisystems.com
Thu Aug 26 15:41:00 GMT 2004


"H. J. Lu" <hjl@lucon.org> writes:

> On Thu, Aug 26, 2004 at 11:06:44AM -0400, Ian Lance Taylor wrote:
> > Jeff Baker <jbaker@qnx.com> writes:
> > 
> > > We have a customer complaining that the --wrap option to ld (again,
> > > 2.12.1) doesn't work with C++.  Would I be correct in assuming that
> > > this is because of the C++ name mangling?  If so, is there anything
> > > (other than extern "C") that they can do to make it work?
> > 
> > --wrap should work fine with C++.  However, you do have to mangle the
> > names yourself, and use --wrap with the mangled name.
> > 
> > There is no real alternative.  It is not practical for the linker to
> > incorporate a C++ mangler, particularly as different compilers, even
> > different versions of g++, use different mangling schemes.
> 
> Linker does support C++ prototype in version script.

Whoops, you're right, we could do it that way.  We could demangle
every symbol and compare it to the --wrap option.  We could just
rewrite bfd_wrapped_link_hash_lookup() to use a callback function.  It
would be slower, but --wrap is not routinely used to speed is probably
not critical.

Ian



More information about the Binutils mailing list