Hi,

On Thu, 5 Apr 2007, Dirk Mueller wrote:

> for a few weeks now openSUSE Factory has a binutils which supports 
> -Bsymbolic-functions. This option causes global symbol references inside 
> a shared object to be resolved locally if that is possible,

And it should be noted, that unlike the frowned upon -Bsymbolic (now 
forget that you read that flag name!) it doesn't inherently break 
exception handling for C++, as it only applies to STT_FUNC symbols 
(associated with, you guessed it, functions, i.e. symbols for code), not 
to data symbols.

> This does break if an application is interposing a symbol, e.g. tries to 
> replace one of the libraries public functions by one it defines by its 
> own and expects the library to call the one the application provides.
> 
> This is however rare and usually even is an unintended symbol clash.

That is true.  There are some cases though, where interposition is 
consciously used.  For instance by libpthread.  It's also explicitely 
allowed to override the global operator new and delete (in C++).  Both 
cases matter only when building glibc or libstdc++, so you don't need to 
care.

Interposition is sometimes also used for quick hacks or work-arounds (e.g. 
catching open/close by some LD_PRELOAD module).  That breaks for all 
symbols exported by libraries compiled with that option (only for 
references to them from that library internally to itself).  Catching 
open/close and other glibc functions will continue to work.

And ltrace won't work anymore as expected: all such internal calls won't 
be noticed (cross module calls, e.g. from application to library will 
continue to be intercepted).

> So, in short: if you know what you're doing, then use
> 
>  $LDFLAGS=-Wl,-Bsymbolic-functions

Yes.  But please: it does interfere with a very low level concept of how 
our shared libraries work.  It should be treated accordingly, i.e. please 
test extensively before using that option.  One can't test the effect of 
this option by 100% (as you can't know all users of your shared library).

A last point: this option only matters for shared libraries, so don't 
bother with it when you don't have any.

Apart from these concerns it can bring some nice speedups in relocation 
time without too much hassle.


Ciao,
Michael.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to