anonymous namespaces and local versus global symbol

Nick Clifton nickc@redhat.com
Tue Nov 24 17:18:23 GMT 2020


Hi Tom,

> I have a C++ method wrapped in a namespace.  What I have noticed is if
> there is an anonymous namespace wrapped around the function, the mangled
> name of the function
> show as a local symbol when running nm on the shared library I produced.
> If I get rid of
> the anonymous namespace, the function shows as global.  I did try a
> --verion-script to
> make the symbol global, as well as use __attribute__((visibility("default")))
> around the
> function, but again the symbol showed as local, not global.
> 
> I can provide sample code if necessary.
> 
> Is this a binutils thing or a GCC thing?

It is *probably* a gcc thing.  (Or g++ really).

My suggestion would be to file a gcc bug report, including a simple
reproducer if it all possible.  If the gcc community decide that it
it is really a binutils problem then I am sure that they will let
you know. :-)

Cheers
   Nick




More information about the Binutils mailing list