Reputation: 3543
I'm building this binary from assembly and trying to link it (probably badly) with libc. But my program won't start, execve
likely fails to finding something. How can I debug it ?
$ 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.
Upvotes: 2
Views: 1304
Reputation: 35825
How can I debug it ?
See ERRORS section for ENOENT error in 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.
One of the most likely reasons of this error is: "ELF interpreter does not exist". Use this command to see the current path to ELF interpreter in your binary:
readelf -l ctime | grep "Requesting program interpreter"
It is likely what your program fails to find when starting.
Upvotes: 2