ld-linux.so를 사용하여 프로그램을 실행하는 방법은 무엇입니까?

ld-linux.so를 사용하여 프로그램을 실행하는 방법은 무엇입니까?

동적 링커가 실행될 수 있습니다.일부 동적 링커 또는 공유 객체를 실행하여 간접적으로(이 경우 명령줄 옵션이 동적 링커에 전달될 수 없으며 ELF의 경우 프로그램의 .interp 섹션에 저장된 동적 링크가 장치에서 수행됨) 또는직접 실행:

/lib/ld-linux.so.* [옵션] [프로그램 [매개변수]]

https://jlk.fjfi.cvut.cz/arch/manpages/man/core/man-pages/ld.so.8.en

유사한 정보는 다음에서 찾을 수 있습니다.도서관 안내.

그런데 막상 해보니,

$ LD_DEBUG=libs /usr/lib/ld-linux.so.2 ls
     23325: find library=ls [0]; searching
     23325:  search cache=/etc/ld.so.cache
     23325: 
ls: error while loading shared libraries: ls: cannot open shared object file

$ LD_DEBUG=libs ls
     23503: find library=libcap.so.2 [0]; searching
     23503:  search cache=/etc/ld.so.cache
     23503:   trying file=/usr/lib/libcap.so.2
...

내가 뭘 잘못했나요? ld-linux.so프로그램을 직접 실행하는 방법이 있나요 ?

답변1

전체 경로를 사용해 보세요 ls.

[ctor@dom0 tst]$ /lib64/ld-linux-x86-64.so.2 /usr/bin/ls
afile

[ctor@dom0 tst]$ /lib64/ld-linux-x86-64.so.2 ls
ls: error while loading shared libraries: ls: cannot open shared object file

[ctor@dom0 tst]$ /lib64/ld-linux-x86-64.so.2 anyinexistentcommandhere
anyinexistentcommandhere: error while loading shared libraries: anyinexistentcommandhere: cannot open shared object file

[ctor@dom0 tst]$ ldd ls
ldd: ./ls: No such file or directory

[ctor@dom0 tst]$ ldd `type -P ls`
    linux-vdso.so.1 (0x00007fffd636c000)
    libselinux.so.1 => /lib64/libselinux.so.1 (0x000074b858cc3000)
    libcap.so.2 => /lib64/libcap.so.2 (0x000074b858abe000)
    libc.so.6 => /lib64/libc.so.6 (0x000074b8586f8000)
    libpcre.so.1 => /lib64/libpcre.so.1 (0x000074b858486000)
    libdl.so.2 => /lib64/libdl.so.2 (0x000074b858282000)
    /lib64/ld-linux-x86-64.so.2 (0x000074b85910a000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x000074b858064000)

[ctor@dom0 tst]$ LD_DEBUG=libs /lib64/ld-linux-x86-64.so.2 ls
      6380: find library=ls [0]; searching
      6380:  search cache=/etc/ld.so.cache
      6380: 
ls: error while loading shared libraries: ls: cannot open shared object file

[ctor@dom0 tst]$ LD_DEBUG=libs /lib64/ld-linux-x86-64.so.2 inexistentcommand
      6415: find library=inexistentcommand [0]; searching
      6415:  search cache=/etc/ld.so.cache
      6415: 
inexistentcommand: error while loading shared libraries: inexistentcommand: cannot open shared object file

[ctor@dom0 tst]$ LD_DEBUG=libs /lib64/ld-linux-x86-64.so.2 /usr/bin/ls
      6342: find library=libselinux.so.1 [0]; searching
      6342:  search cache=/etc/ld.so.cache
      6342:   trying file=/lib64/libselinux.so.1
      6342: 
      6342: find library=libcap.so.2 [0]; searching
      6342:  search cache=/etc/ld.so.cache
      6342:   trying file=/lib64/libcap.so.2
      6342: 
      6342: find library=libc.so.6 [0]; searching
      6342:  search cache=/etc/ld.so.cache
      6342:   trying file=/lib64/libc.so.6
      6342: 
      6342: find library=libpcre.so.1 [0]; searching
      6342:  search cache=/etc/ld.so.cache
      6342:   trying file=/lib64/libpcre.so.1
      6342: 
      6342: find library=libdl.so.2 [0]; searching
      6342:  search cache=/etc/ld.so.cache
      6342:   trying file=/lib64/libdl.so.2
      6342: 
      6342: find library=libpthread.so.0 [0]; searching
      6342:  search cache=/etc/ld.so.cache
      6342:   trying file=/lib64/libpthread.so.0
      6342: 
      6342: 
      6342: calling init: /lib64/libpthread.so.0
      6342: 
      6342: 
      6342: calling init: /lib64/libc.so.6
      6342: 
      6342: 
      6342: calling init: /lib64/libdl.so.2
      6342: 
      6342: 
      6342: calling init: /lib64/libpcre.so.1
      6342: 
      6342: 
      6342: calling init: /lib64/libcap.so.2
      6342: 
      6342: 
      6342: calling init: /lib64/libselinux.so.1
      6342: 
      6342: 
      6342: initialize program: /usr/bin/ls
      6342: 
      6342: 
      6342: transferring control: /usr/bin/ls
      6342: 
afile

관련 정보