我正在从程序集构建这个二进制文件,并尝试将它(可能很糟糕)与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.

最佳答案

如何调试?
有关man execve中的异常错误,请参阅错误部分:

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解释器不存在”。使用此命令查看二进制文件中ELF解释器的当前路径:
readelf -l ctime | grep "Requesting program interpreter"

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

关于linux - 我如何调试exec * = -1 ENOENT?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48989339/

10-11 16:34