This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ld -shared -Bsymbolic and C++ shared library
- From: Geoffrey Keating <geoffk at apple dot com>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: binutils at sources dot redhat dot com, gcc at gcc dot gnu dot org
- Date: 27 Jul 2006 15:37:33 -0700
- Subject: Re: ld -shared -Bsymbolic and C++ shared library
- References: <20060716172604.GB29871@lucon.org>
"H. J. Lu" <hjl@lucon.org> writes:
> ld -shared -Bsymbolic will reduce number of dynamic relocations in
> a shared library. Unfortunately, it won't work correctly with C++
> exception and maybe other language features.
>
> However, I think it is possible to make -shared -Bsymbolic to work
> for C++ by providing a way to specify a list of symbols which must
> be dynamic. We then can do
>
> # g++ -Wl,-Bsymbolic -shared -xxx "list of dynamic symbols" -o libfoo.so ...
>
> and libfoo.so written in C++ will work correctly with much fewer dynamic
> relocations.
You may find this would be easier to use if you just had a flag which
made -Bsymbolic apply only to non-weak symbols.