gdb During startup program exited with code 127
/bin/bash: /usr/local/sbin/test: No such file or directory
There are two common causes of this:
- the file
/usr/local/sbin/test
doesn't exist - the file does exist, is a dynamically linked executable, and the ELF interpreter that it specifies does not exist.
For #1, the answer is obvious: you need a file to debug.
For #2, you can find out which ELF interpreter the file requires like so:
readelf -l /usr/local/sbin/test | grep interpreter
You likely have a 32-bit binary pointing to /lib/ld-linux.so.2
on a 64-bit system without 32-bit runtime support installed. Depending on the distribution you are using, something like sudo apt-get install libc6:i386
should do the trick.
Recent versions of the file
command also print the interpreter:
file ./a.out
./a.out: ELF 32-bit LSB executable, ... interpreter /lib/ld-linux.so.2, ...
Related videos on Youtube
humme1
Updated on September 15, 2022Comments
-
humme1 over 1 year
Wanted to use gdb as a debugger in Linux Debian. Trying to run a binary I get this:
(gdb) r Starting program: /usr/local/sbin/test /bin/bash: /usr/local/sbin/test: No such file or directory During startup program exited with code 127. (gdb)
I guess it's supposed to be elementary. But I googled a lot and most common answer is
$ export SHELL=/bin/bash
This doesn't help. I also tried to change PATH for binaries execution, tried to run from different directory... Still the same.
Could you please help me with that?
-
humme1 almost 8 yearsThanks a lot! That was really the case.64-bit system without 32-bit runtime support. Works fine now.
-
PMat over 6 years@humme1 I have the same problem, but mine is 64bit binary so the output of above command is
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
. Any idea? -
Employed Russian over 6 years@PMat Are you running this binary on a 64-bit Linux system? Approximately nothing should work on it if
ld-linux-x86-64.so.2
is missing. -
PMat over 6 years@EmployedRussian. Yes i am on a 64-bit linux and /lib64/ld-linux-x86-64.so.2 exists on my machine.
-
PMat over 6 years@EmployedRussian that was confusing, I installed the above package anyways, now gdb loads the binary but it says can't find the so files even though there are in the solib-search-path
-
Employed Russian over 6 years@PMat You should probably ask a separate question, with details of what is installed on your system, what exactly you observe, whether the program runs outside of GDB, etc. etc.
-
PMat over 6 years@EmployedRussian sure stackoverflow.com/questions/46437172/…
-
Lokesh Sanapalli over 6 years@EmployedRussian Hi, struggling with same problem, libc6:i386 is already installed, set SHELL env,
build-essential
is already the latest version. Tried everything, but nothing worked out. Please help -
Lokesh Sanapalli over 6 years@PMat Hi, struggling with same problem, libc6:i386 is already installed, set SHELL env,
build-essential
is already the latest version. Tried everything, but nothing worked out. Please help