Re: On the cost of libraries



Alex Larsson wrote:
> On Sat, 1 Sep 2001, Drazen Kacar wrote:

> >   a) outlaw run-time symbol interposition in the dependencies which were
> >      not marked as interposers.
> 
> What is a "run-time symbol interposition", and how would i mark it as an 
> interposer? (And what is an interposer?)

Run-time symbol interposition (or conflict) is a condition when several
shared objects contain definition for the same symbol. Object which was
mapped first wins. This situation is bad for several reasons:

  1. It prevents some optimization tricks.

  2. It has a different effect with static and dynamic linking. Let's suppose
     you have libA, libB and libC and your link line says: "-lA -lB -lC".
     In case libB needs symbol foo which can be found in both libA and
     libC, static linking would take it from libC. In case of dynamic
     linking it would be taken from libA.

Interposition usually happens when user specifies something in LD_PRELOAD
(or equivalent). The objects which interpose their symbols are called
interposers. If you have linker system which can be told to record where
each symbol lives, it might have a way to mark certain shared object as an
interposer, so run-time linker would search there first, regardless of
what ld(1) recorded at link time.

> >   b) then ld(1) can record in which library every simbol lives.
> 
> Do i have to tell ld to do this?

If it implements that capability (GNU ld doesn't, AFAIK), yes. I doubt that
any Unix linker would have such an option as a default, because it conflicts
with the way symbol lookup was done previously (ie. search dependencies in
the mapping order). Since that behaviour is mandated by Unix 98, I suppose
Unix 98 has to be the default. At least for C compilers.

> >   d) while we're at it, the libraries which probably won't be used can
> >      be marked for lazy loading (or deferred loading, or however your
> >      system documentation calls it). If those libraries have good enough
> >      API, run-time linker won't load them until needed.
> 
> Is this possible with Linux + GNU ld? I've never seen anything about it.

No. I've been told that people are working on it. For the time being you
can use -O1 and get much better lookup time (although ELF sucks even with
that).

> > And all private symbols in the libraries should be marked as such.
> 
> Yes. Maybe we should sweep through all our libraries and see if we can fix 
> this for Gnome 2?

That would be nice. But if someone will make the effort, it would be nice
to provide version information, as well.

-- 
 .-.   .-.    Errors have been made. Others will be blamed.
(_  \ /  _)
     |
     |        dave arsdigita com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]