O que é /lib64/ld-linux-x86-64.so.2 e por que pode ser usado para executar o arquivo?

6

Recentemente, aprendi um truque que, se um arquivo não tiver permissões executáveis, podemos executar esse arquivo usando /lib64/ld-linux-x86-64.so.2 .

Por exemplo, para restaurar a permissão x para

-rw-r--r-- 1 root root 59K Mar  1  2017 /bin/chmod

podemos correr

/lib64/ld-linux-x86-64.so.2 /bin/chmod +x /bin/chmod

Eu realmente não sei como isso pode ser feito, não é uma coisa normal, um tipo de mistério.

    
por Federal Reserve 26.10.2017 / 16:05

1 resposta

6

Esse é o vinculador dinâmico; se você o executar sozinho, ele informará o que ele faz:

Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]

You have invoked ‘ld.so’, the helper program for shared library executables. This program usually lives in the file /lib/ld.so, and special directives in executable files using ELF shared libraries tell the system's program loader to load the helper program from this file. This helper program loads the shared libraries needed by the program executable, prepares the program to run, and runs it. You may invoke this helper program directly from the command line to load and run an ELF executable file; this is like executing that file itself, but always uses this helper program from the file you specified, instead of the helper program file specified in the executable file you run. This is mostly of use for maintainers to test new versions of this helper program; chances are you did not intend to run this program.

O vinculador é usado para executar programas vinculados dinamicamente. Quando você executa chmod , o kernel executa efetivamente lib64/ld-linux-x86-64.so.2 chmod , como você fez manualmente; o último funciona mesmo se o binário chmod não for executável.

Você encontrará muito mais detalhes sobre isso no excelente artigo Como os programas são executados: binários ELF .

    
por 26.10.2017 / 16:15