Tools to modify shared libraries

Joe Kelsey joek at mail.flyingcroc.net
Tue Jun 17 06:38:46 PDT 2003


Brandon S. Allbery KF8NH wrote:
> On Mon, 2003-06-16 at 18:39, Joe Kelsey wrote:
> 
>>Has anyone ever come across general-purpose tools for modifying shared 
>>libraries?  What I want to do is to edit the list of "needed" shared 
>>libraries to correct the common mistakes that developers make in 
>>creating shared objects with large lists of shared libraries.
> GNU objcopy --- but it's a bit *too* general; you'd need to extract the
> .dynamic section, edit it using some binary editing tool, and re-add it.

I have tried and failed... I even looked at the code.  objcopy is
horrible as far as it goes.  Maybe if I could learn more about bfd in
general, there might be something I could do with objcopy, but it does 
not look promising.

> I doubt there are any tools of the kind you're looking for because the
> details are too different between different systypes; even if someone
> had developed one, it's just as likely to be for Linux or Solaris as for
> *BSD, and as a result wouldn't be particularly useful.

All 32-bit Elf libraries look the same as far as the DT_NEEDED entries
in the DYNAMIC section.  In fact, *all* ELF libraries look the same
relative to the size of the string table offset used for entries.  The
DYNAMIC section is the simplest of all sections, generally consisting of
a tag and a value, both in the native word size (e.g., 32 or 64).  I am
surprised that no one has done this yet.

I tried elfsh, but the version in ports is too old.  I got the most 
recent version from the website, but it has a lot of linuxisms in it.

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.

/Joe








More information about the freebsd-questions mailing list