I\'ve got caught in the not-so-sunny world of cross-compilation.
I\'m trying to compile a simple hello world application for my BeagleBone Black (which runs a TI Cortex-
Since nobody from the comments posted the answer, I guess I get the pleasure ;)
No such file or directory
comes from when the kernel tries to invoke the dynamic linker specified by the ELF executable's .interp
field, but no such file exists.
The .interp
field can be found with the following command:
objdump -j .interp -s ./hello_world
In the case of this example, the executable's .interp
field was /lib/ld-linux.so.3
, but the name of the dynamic linker on the BeagleBone Black is /lib/ld-linux-armhf.so.3
.
This happened because the program was compiled with a slightly different toolchain to the one required for the platform. It should be arm-linux-gnueabihf-*
rather than arm-linux-gnueabi-*
.
The difference between the two is that the Cortex-A8 uses specific floating point registers with the hard-float version (armhf
) of the EABI, but the original EABI (armel
) uses integer registers for passing around floating point numbers. As a result, armel
programs will run on armhf
(provided the dynamic linker is set to the correct path!), but not vice versa.
Simply adding a symbolic link ln -s /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3
is enough to resolve this issue, but the correct fix is to use the right toolchain when compiling the program in the first place.