Weak symbols and inline

Paul Smith paul@mad-scientist.net
Fri Feb 28 21:53:00 GMT 2014


On Fri, 2014-02-28 at 22:15 +0100, Marc Glisse wrote:
> > So then I tried to use inline versions of global new/delete.  If I
> > further add __attribute__((force_inline)) then it APPEARS to do what I'd
> > like: none of my objects are exporting global new/delete.
> 
> Header <new> contains:
> #pragma GCC visibility push(default)
>    __attribute__((__externally_visible__));
> 
> It seems hard to counter those effects.

Ah.  Hrm...

> > Is there a better supported, more "approved" way to handle this
> > requirement?
> 
> I haven't looked at it closely, but maybe asking the linker directly 
> (instead of telling gcc to tell the linker), for instance through a
> map file, could help?

That's possible.  I'll give it a try to see...

Yes, that works: I can convert those symbols from "T" to "t" with a
version-script.

Hmm...
> 
> The simplest is probably to use asm("other_name_for_new") on a
> declaration of new, so it is still visible but with a different
> name...

But isn't this subject to the same caveats that using force_inline is?
If I don't include the header file, then the code silently falls back to
the system new/delete.



More information about the Gcc-help mailing list