What’s the purpose put a .so file before execution file?

I saw a execution method today.

/lib/ld-linux-x86-64.so ./foo

I know when putting a bash variable before execution command means to set that environment variable before execute command.

But now, it is a share lib, what’s the purpose and function to put there?

1 answer

  • answered 2020-03-25 13:44 chepner

    The dynamic linker /lib/ld-linux-x86-64.so is special in that it can be run as an executable or linked to another executable to use as a library itself. This isn't something you can do with an arbitrary .so file, though.

    Either way, its purpose is to allow ./foo to load other shared libraries at run time. For more information, see its manpage.