Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jun 2003 09:13:04 -0700
From:      Joe Kelsey <joek@mail.flyingcroc.net>
To:        Marcel Moolenaar <marcel@xcllnt.net>
Cc:        questions@freebsd.org
Subject:   Re: Tools to modify shared libraries
Message-ID:  <3EEF3E10.8030205@mail.flyingcroc.net>
In-Reply-To: <20030617160141.GB584@dhcp01.pn.xcllnt.net>
References:  <3EEE4717.2090409@mail.flyingcroc.net> <1055804020.79093.2.camel@rushlight.kf8nh.apk.net> <3EEF19D5.9040706@mail.flyingcroc.net> <20030617154208.GA584@dhcp01.pn.xcllnt.net> <3EEF3883.1080500@mail.flyingcroc.net> <20030617160141.GB584@dhcp01.pn.xcllnt.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Marcel Moolenaar wrote:
> On Tue, Jun 17, 2003 at 08:49:23AM -0700, Joe Kelsey wrote:
> 
>>Marcel Moolenaar wrote:
>>
>>>On Tue, Jun 17, 2003 at 06:38:29AM -0700, Joe Kelsey wrote:
>>>
>>>
>>>>Basically, what I want to do is remove several entries from the *front* 
>>>>of the dynamic section.  Actually, I would settle for just removing all 
>>>>of a certain tag (such as DT_NEEDED) from the dynamic section.
>>>
>>>
>>>It's more constructive to fix the linker than it is to patch the
>>>ELF files created by it. The linker knows which libraries are
>>>really needed and should be able to create the minimal list of
>>>(true) dependencies.
>>
>>This cannot be accomplished by fixing the linker.  The issue is one of 
>>attempting to use a *linux* shared library in a native application. 
> 
> 
> Linux uses the same linker (GNU ld). Fixing the linker will have the
> same effect on Linux as it will have on FreeBSD and hence will prevent
> unnecessary dependencies in Linux libraries to Linux libraries and
> thus remove the need to patch ELF files in the long run.
> 

The problem cannot be resolved by "fixing" ld.  The problem arises from 
people who specify unnecessary libraries on their ld command lines.  ld 
cannot tell the difference between a required library and an unnecessary 
library at link time.  Only the runtime loader can do this, and the 
FreeBSD runtime loader has numerous problems in this area.

Sometimes a shared library has to include a required library reference 
since the shared library author knows in advance that the programs using 
the library do not have the same requirements.  Most often, clueless 
programmers reference every single library ever known to them on their 
linker command lines in the off-chance that it *might* make a difference 
at load time.  However, this leads to shared libraries containing 
references to explicitlyly versioned libraries, thus leading to the 
proliferation of unnecessarily versioned shared libraries, etc., etc.

I can think of many reasons for post-linker tools to modify shared 
libraries.  Most of them involve fixing the egregious mistakes 
perpetrated by users who have not thought out what requirements a shared 
library outgt to carry with it.  Others involve patching and other kinds 
of code modification.

/Joe




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3EEF3E10.8030205>