tag:blogger.com,1999:blog-9726833.post3161265458754913310..comments2023-11-11T19:20:51.515+00:00Comments on The Trouble with Tribbles...: Tweaking binaries with elfeditPeter Tribblehttp://www.blogger.com/profile/09363446984245451854noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-9726833.post-85116301224605843532017-06-19T16:27:37.001+01:002017-06-19T16:27:37.001+01:00Hi Peter.
Thanks for this nice article about elfe...Hi Peter.<br /><br />Thanks for this nice article about elfedit.<br /><br />One nice thing to note about the libtool example that you used is that the desired string libfoo.so.1 is at the tail of the existing value. Therefore, this edit doesn't consume any of the reserved space that the Solaris ld creates for such edits. As such, you will see that the value of SUNWSTRPAD doesn't change. This edit comes at no cost.<br /><br />If you execute the command 'set d 1' before that command, or run elfedit with the -d option, elfedit will show you how it satisfied the request. That's not really necessary, but interesting to the curious with some ELF background.<br /><br />Identifying the specific NEEDED entry to modify has always been the weak part of this story. -dynndx does indeed work, but doing that in an automated way requires some sort of wrapper script to run elfdump or elfedit to get that index, and then create the necessary elfedit with the actual index value. With Solaris 11.3, I introduced a plethora of -with- selection options, intended to make it easier to do things like that in a single step. Your example would be:<br /><br />% elfedit -e 'dyn:value -with-valstr /home/ptribble/build/bar/.libs/libfoo.so.1 -s libfoo.so.1'<br /><br />The next release of Solaris will have a dyn:needed command intended to simplify NEEDED manipulations further and handle some of the tricker corner cases (not relevant to the simple example here).<br /><br />Happy Editing!<br /><br />- Ali Bahrami<br />Anonymousnoreply@blogger.com