'file'이 보고하는 인터프리터는 무엇을 참조합니까?

'file'이 보고하는 인터프리터는 무엇을 참조합니까?

Ubuntu 16.04에서 디버그 라이브러리가 제공하는 실행 파일을 실행 하려고 하는데 perl어떤 이유로 파일이 내 아키텍처와 일치하는 것처럼 보이지만 "실행할 수 없습니다".

perlUbuntu 16.04가 제거된 상태로 제공된 실행 파일

$ nm /usr/bin/perl
nm: /usr/bin/perl: no symbols

포장은 perl-debug벗겨지지 않은 바닥을 제공합니다 perl./usr/lib/debug

$ nm /usr/lib/debug/usr/bin/perl | head
                 U abort@@GLIBC_2.2.5
0000000000589020 r AboveLatin1_invlist
                 U accept@@GLIBC_2.2.5
                 U access@@GLIBC_2.2.5
000000000058e002 r a_hash.16944
                 U alarm@@GLIBC_2.2.5
000000000058e010 r an_array.16943
00000000005795c0 r ASCII_invlist
0000000000543430 T ASCII_TO_NEED
                 U atan2@@GLIBC_2.2.5

그러나 실행하려고 하면 다음과 같은 멋진 메시지 exec*와 함께 실패합니다 .bash

$ /usr/lib/debug/usr/bin/perl
bash: /usr/lib/debug/usr/bin/perl: cannot execute binary file: Exec format error

두 Perl에서 실행 하면 file일반 Perl에 일부 ld 공유 객체가 있는 디버그 Perl이 "빈 인터프리터가 있음"으로 표시되는 것을 볼 수 있습니다. 링커와 관련이 있을 수 있지만 ld그것이 무엇인지는 모르겠습니다.

$ file /usr/bin/perl
/usr/bin/perl: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=e6106890a64a3316b2adfc04bbf202f13f82b5bb, stripped
$ file /usr/lib/debug/usr/bin/perl
/usr/lib/debug/usr/bin/perl: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter *empty*, for GNU/Linux 2.6.32, BuildID[sha1]=e6106890a64a3316b2adfc04bbf202f13f82b5bb, not stripped

file인터프리터가 비어 있다고 보고하면 정확히 무엇을 알려주나요?

답변1

perl-debug는 perl실행 중인 프로세스를 이해하는 것을 포함하여 GDB와 함께 사용됩니다 . 예를 들어 perl실행 중인 프로세스의 perl script.plpid가 주어지면 $PID다음을 사용할 수 있습니다.

$ gdb /usr/lib/debug/usr/bin/perl $PID

여기에 연결하고 모든 일반적인 GDB 작업을 수행합니다.. 자체적으로는 실행 가능한 실행 파일이 아니며 실행하는 데 필요한 요소가 부족합니다.

이러한 기호는 기본 실행 파일 크기의 두 배 이상이고 거의 필요하지 않기 때문에 별도로 저장됩니다. 이 경우 이러한 기호는 디버깅에 유용합니다.perl, Perl 스크립트를 디버깅하는 대신 링크할 확장을 개발하는 경우에만 유용할 수 있습니다.

실행 가능 비트를 설정하는 것이 실제로 필요하다고 생각하지 않지만 데비안은 내가 본 디버깅 기호 파일에서 이를 제거하지 않으므로 어떤 경우에는 필요할 수 있습니다. file디버깅 정보와 관련 없는 파일이 모두 누락되어 인터프리터가 비어 있기 때문에 비어 있음을 알려줍니다.

답변2

fileELF 도구를 호출하면 파일이 ELF 형식이라는 점을 알 수 있습니다. 인터프리터가 잘 문서화되어 있지 않습니다.elf(5)

PT_INTERP   The array element specifies the location and size of a
            null-terminated pathname to invoke as an  interpreter. 
            This segment type is meaningful only for executable files
...
.interp   This section holds the pathname of a program interpreter.

통역사가 있는 파일 의 경우 interpreter /lib64/ld-linux-x86-64.so.2문서를 찾아볼 수 있습니다...

$ man -k ld-linux
ld.so (8)            - enlazador/cargador dinámico
ld-linux (8)         - dynamic linker/loader
ld-linux.so (8)      - dynamic linker/loader

정보 ld.so(8)페이지는 다음을 알려줍니다.

   The  programs ld.so and ld-linux.so* find and load the shared libraries
   needed by a program, prepare the program to run, and then run it.

.interp또한 다음을 실행할 수 있으므로 해당 부분이 반드시 필요하지는 않습니다 .

/lib/ld-linux.so.*  [OPTIONS] [PROGRAM [ARGUMENTS]]

관련 정보