[GTALUG] How much do you know about how linux executes binaries?

Sergio Durigan Junior sergiodj at sergiodj.net
Thu Dec 12 13:23:35 EST 2019


On Wednesday, December 11 2019, Lennart Sorensen wrote:

> On Wed, Dec 11, 2019 at 03:28:30PM -0500, Sergio Durigan Junior via talk wrote:
>> Everything that could be moved was moved under /var, because it's the
>> last directory (alphabetically) on /.
>> 
>> You will have to invoke the dynamic loader by hand in this case, because
>> it has been moved as well.  On Debian GNU/Linux 64-bit, you can find it
>> at /var/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2.  You will also have
>> to set LD_LIBRARY_PATH accordingly, otherwise the binary to be executed
>> will not be able to find its required libraries (mainly libc.so, in this
>> case):
>> 
>> # export LD_LIBRARY_PATH=/var/lib/x86_64-linux-gnu
>> # /var/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /var/bin/ls
>> 
>> You can now invoke 'mv' and move the contents back to /.
>
> Congratulations.  You know your dynamic loader. :)
>
> This particular system is yocto multilib based, so it was /var/lib64 that
> had the needed files, and mv happens to be in busybox with a symlink
> pointing the wrong way so it needed busybox called explicitly with mv
> as an argument, but that wasn't the important part.

Cool.

BTW, Debian offers busybox-static to help with this kind of scenario.

Cheers,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/


More information about the talk mailing list