[Gllug] pimping my elf

Alex Sayle alexs at alphacomplex.info
Wed Jun 14 14:02:00 UTC 2006


On 14 Jun 2006, at 15:06BDT, Daniel P. Berrange wrote:

> On Wed, Jun 14, 2006 at 02:37:31PM +0100, Alex Sayle wrote:
>> Firstly I must explain how our environment works, we use a lot of  
>> FOSS
>> libraries and for the sake of backwards compatibility we keep them in
>> their own little sub namespace and link or install them into a  
>> central
>> location for the ease of our use.
>>
>> it looks a bit like <somepath>/bar/<version>/{lib,include,share} so
>> we can have multiple libbar's co-existing.
>>
>> For simplicity we then take bar/<version>/lib/libbar.so.<version> and
>> install into a central LIB directory. For some historic reason when
>> we do this the libraries are renamed to libbar-<version>.so.
>>
>> this name change can be an issue and rather than going against the  
>> grain
>> I'd like to get it working as is. So, here's the question, does  
>> anyone
>> know a non hexedit or binary sed hackery way to change link targets
>> in a an elf binary.
>>
>> In essence I want to change
>>
>> $readelf -d foo.so  | head -n 3
>> Dynamic segment at offset 0x36c0 contains 37 entries:
>>   Tag        Type                         Name/Value
>> 0x00000001 (NEEDED)                     Shared library: [libbar.so. 
>> 4.2]
>>
>> to
>>
>> 0x00000001 (NEEDED)                     Shared library:  
>> [libbar-4.2.so]
>>
>> with out re-linking the whole thing.
>
> I assumed you've already tried the simple symlink  "libbar-4.2.so" =>
> "libbar.so.4.2", or vica-versa ?   Since everything is versioned you
> shouldn't get any file name clashes by having both filename schemes
> present in your central LIB dir ?

This work for the simple case when the libbar has full version  
numbers on it,
but there's cases where libbar.so.4.2.1 comes out and then the plot  
fails
as only one can be symlinked libbar-4.2.so.

So, yes, it works for the simple case but there's still a need to change
the link targets in an arbitrary manner. One evil plot that I had
was to create my own .dynamic section, appending it to he elf binary
and we-writing the elf header entry... rather hacky so I's hoping it
might be a solved problem.

--alex

--
[----------------------------------------------------------------------]
  Alex Sayle                                     alexs at alphacomplex.info


-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list