I set up a 32 bits Debian VM on my host 64 bits OS. I shared the source code directory using NFS.
When I compile inside that shared folder, I am unable to run the executable:
nicolas@vdeb32:~/Shared$ cc hello.c -o hello
nicolas@vdeb32:~/Shared$ ./hello
-bash: ./hello: cannot execute binary file: Exec format error
nicolas@vdeb32:~/Shared$ file hello
hello: data
But when the output is out of that shared folder, everything works fine:
nicolas@vdeb32:~/Shared$ cc hello.c -o /tmp/hello
nicolas@vdeb32:~/Shared$ /tmp/hello
hello
nicolas@vdeb32:~/Shared$ file /tmp/hello
/tmp/hello: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32
What is the cause of that behavior? I found that askubuntu reply but there is no explanation and anyway my host is not running windows neither my executable is a link.
Thanks.
[EDIT] I found the reason why the file cannot be executed. Editing hello.c, I noticed that the file, once saved, was only contaning zeros:
nicolas@vdeb32 ~/Shared $ xxd hello.c
00000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000030: 0000 0000 0000 0000 ........
After some retries: when creating a file, everything works fine. But when I edit a file (in the shared directory), it is overwritten with zeros (same number of bytes as the original file). When compiling, the executable produced contains also only zeros. I am left with a different problem but the same question: what is the cause of that behavior?
[EDIT2] No trouble with the same architecture when the guest is running Mint 64 bits.

