public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ld -shared -Bsymbolic and C++ shared library
@ 2006-07-16 17:26 H. J. Lu
  2006-07-27 22:37 ` Geoffrey Keating
  0 siblings, 1 reply; 3+ messages in thread
From: H. J. Lu @ 2006-07-16 17:26 UTC (permalink / raw)
  To: gcc; +Cc: binutils

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.


H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ld -shared -Bsymbolic and C++ shared library
  2006-07-16 17:26 ld -shared -Bsymbolic and C++ shared library H. J. Lu
@ 2006-07-27 22:37 ` Geoffrey Keating
  2006-07-28  1:21   ` H. J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Geoffrey Keating @ 2006-07-27 22:37 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils, gcc

"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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ld -shared -Bsymbolic and C++ shared library
  2006-07-27 22:37 ` Geoffrey Keating
@ 2006-07-28  1:21   ` H. J. Lu
  0 siblings, 0 replies; 3+ messages in thread
From: H. J. Lu @ 2006-07-28  1:21 UTC (permalink / raw)
  To: Geoffrey Keating; +Cc: binutils, gcc

On Thu, Jul 27, 2006 at 03:37:33PM -0700, Geoffrey Keating wrote:
> "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.

It doesn't work since

1. There are weak function symbols, which we do want to bind locally.
2. Weak symbols aren't required for comdat group.

BTW, -Wl,-Bsymbolic can't be used since it will add DF_SYMBOLIC to
shared library, which will cause dynamic linker to resolve symbols
locally.


H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-07-28  1:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-16 17:26 ld -shared -Bsymbolic and C++ shared library H. J. Lu
2006-07-27 22:37 ` Geoffrey Keating
2006-07-28  1:21   ` H. J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).