1

I'm trying to run a cross compiler on my 64 bit Ubuntu. and it results in a following error:

$ ./arm-none-eabi-gcc
bash: ./arm-none-eabi-gcc: No such file or directory

The file is here and contains some data:

$ ls -la arm-none-eabi-gcc
-rwxr-xr-x 2 alan alan 776368 Sep 26 19:36 arm-none-eabi-gcc
$ head -n 1 arm-none-eabi-gcc
ELFا4�
         4  (44�4�  TT�T���|�

ldd shows there are no dependencies required:

$ ldd arm-none-eabi-gcc
not a dynamic executable

strace also provides no additional info:

$ strace ./arm-none-eabi-gcc
execve("./arm-none-eabi-gcc", ["./arm-none-eabi-gcc"], [/* 80 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
exit_group(1)                           = ?
+++ exited with 1 +++

Finally I figure out that it's for a 32 bit system:

$ file arm-none-eabi-gcc
arm-none-eabi-gcc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.8, stripped

Question

If the architecture of the binary is wrong why is the error so ambiguous?

I would expect analogous to the below situation where I'm trying to execute a .JPG, where the binary execution makes no sense:

$ ./DSC_0140.JPG 
bash: ./DSC_0140.JPG: cannot execute binary file: Exec format error

1 Answers1

5

The error comes from the fact that you're missing the loader for the binary, /lib/ld-linux.so.2 (as indicated by file). Once you have that installed you'll be able to run ldd arm-none-eabi-gcc to see what's required in addition.

The executable is in a valid format, which the kernel understands, so you don't get an "Exec format error", but when the kernel tries to run it, it can't find a required file — the loader —, hence "No such file or directory".

As you figured out, a quick solution to get it running on the 64 bit machine is to run:

sudo apt-get install lib32z1 lib32ncurses5

although a better solution in the long run is to use appropriate :i386 multiarch packages (which should be what gets pulled in by lib32 packages).

Stephen Kitt
  • 434,908