Linux 可执行文件在 运行ning strace 上 运行 出现错误“/usr/bin/strace: exec: No such file or directory”

Linux Executable fails to run with error “/usr/bin/strace: exec: No such file or directory” on running strace

我需要使用 strace 分析 linux 二进制可执行文件以捕获系统调用。

在 运行 命令上: /usr/bin/strace ./005f32fffe1da3bc100e7dcd8b2f8f2c

我收到这个错误:

execve("./005f32fffe1da3bc100e7dcd8b2f8f2c", ["./005f32fffe1da3bc100e7dcd8b2f8f"...], 0x7fffd9d0a120 /* 53 vars */) = -1 ENOENT (No such file or directory) fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 write(2, "/usr/bin/strace: exec: No such f"..., 49/usr/bin/strace: exec: No such file or directory ) = 49 getpid() = 3699 exit_group(1) = ? +++ exited with 1 +++

我的文件类型是 32 位 ELF 二进制。

file 005f32fffe1da3bc100e7dcd8b2f8f2c 005f32fffe1da3bc100e7dcd8b2f8f2c: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, stripped

我的机器是 64 位 运行 Ubuntu 并且我安装了 libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1。

这个二进制文件很奇怪:它被链接为使用 /lib/ld- 作为动态加载程序。

32 位 i386 动态加载器通常称为 /lib/ld-linux.so.2。我们可以假设您的二进制文件已以某种方式损坏。

在您的其他评论中,您说没有 strace 二进制文件将不会 运行(因为 /lib/ld- 不存在)。 运行 strace 下的二进制可以神奇地使二进制工作。

您应该能够 运行 它在 strace 下通过使用显式加载程序调用:

strace -ff /lib/ld-linux.so.2 ./005f32fffe1da3bc100e7dcd8b2f8f2c

更新:

I am getting some system calls like this :
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory) stat64("/lib/i686/sse2", 0xffe9b300) = -1 ENOENT (No such file or directory) +++ exited with 127 +++
I am not sure what kind of system calls are these ?

这是试图加载您的程序并使用 access and stat64 系统调用的动态链接器。

how to run the following file with strace? How do know which library to use in strace command with -ff option based on file command output ?
file mosquitto_pub mosquitto_pub: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/l, for GNU/Linux 2.6.32, BuildID[sha1]=7ced951dc3a859a6829feb46fd5cf757a6073361, not stripped

这是一个 64 位二进制文​​件,具有类似损坏的 /lib64/l 动态加载器。

x86-64 上 GLIBC 的标准 64 位加载程序是 /lib64/ld-linux-x86-64.so.2,因此您需要的命令是:

strace -ff /lib64/ld-linux-x86-64.so.2 ./mosquitto_pub