我如何调试 exec* = -1 ENOENT?

How do i a debug exec* = -1 ENOENT?

我正在从程序集构建这个二进制文件并尝试 link 它(可能很糟糕)与 libc。但是我的程序无法启动,execve 可能无法找到某些东西。我该如何调试它?

$ file ctime
ctime: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 3.2.0, not stripped

$ strace -f ./ctime
execve("./ctime", ["./ctime"], [/* 19 vars */]) = -1 ENOENT (No such file or directory)
fstat64(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
getpid()                                = 13784
exit_group(1)                           = ?
+++ exited with 1 +++

$ gdb ./ctime
GNU gdb (Raspbian 7.12-6) 7.12.0.20161007-git
Reading symbols from ./ctime...done.
(gdb) r
Starting program: ./ctime
/bin/bash: ./ctime: No such file or directory
During startup program exited with code 127.

How can I debug it ?

请参阅 man execve 中的 ENOENT 错误的错误部分:

ENOENT The file filename or a script or ELF interpreter does not
      exist, or a shared library needed for the file or interpreter
      cannot be found.

此错误最可能的原因之一是:"ELF interpreter does not exist"。使用此命令查看二进制文件中 ELF 解释器的当前路径:

readelf -l ctime | grep "Requesting program interpreter"

可能是你的程序在启动时找不到。