On Thu, Jun 15, 2006 at 01:07:02AM +1000, Benno wrote: > On Wed Jun 14, 2006 at 15:56:10 +0100, Alex Sayle wrote: > > > >Evening sluggers, > >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.1.so] > > > >with out re-linking the whole thing. > > > >I have a need to include the minor version into the library name so > >simply symlinking it out of the question. > > > >Given that this information is stored in .dynamic section in the elf > >my cunning plan was to create my own .dynamic section based on the > >current one and append it to the binary and rewrite the elf header > >and simply ignore the existing .dynamic. > > Mmm, I think this would be reasonably easy to do by adding > libbar-4.2.1.so to the necessary string table, and then change the > string index appropriately. > > I'm not sure if objcopy provides a way to do this. It is coincidental, > that I'm in the middle of putting some release notes to a python > library for screwing around with elf files, which might make it kind > of easy to do. Mail me off-list and I can probably give you a copy of > the code.
I'm not sure whether it's helpful, but was reading about LD_LIBRARY_PATH and RPATH hackery just yesterday and came across these useful links. In particular setrpath.c mentioned in the first link may give you some ideas. http://daemons.net/~matty/articles/linkers.badldlibrary.html One of the following article's comments talk about mucking around with the string tables. http://blogs.sun.com/roller/page/rie?entry=tt_ld_library_path_tt (also $ORIGIN is cool, but I don't think it helps you in this case) The above is Solaris-y, but it's all applicable to Linux ELF afaik. Definitely $ORIGIN is. Regards, Matt -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html