Static built binaries having unknown ELF binary types

Victor Roman Archidona daijo at unixevil.info
Sat Jul 8 04:08:16 UTC 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Hi all,

at first I should mention that this post is about Gentoo/FreeBSD for
amd64 port, using the Gentoo portage system with FreeBSD sources,
library and so on. If you're not interested in this you can stop
reading now :-).

I'm compiling "make" (usr.bin/make), but when I try to execute it I
got the following results:

root at localhost ~ # /usr/bin/make
ELF binary type "0" not known.
- -su: /usr/bin/make: cannot execute binary file
root at localhost ~ #

I must say that this *only* happends when "make" is built statically
(if you want it compiled dynamically change the Makefile). This is the
file information about it:

root at localhost ~ # file /usr/bin/make
/usr/bin/make: ELF 64-bit LSB executable, AMD x86-64, version 1
(SYSV), for FreeBSD 6.1, statically linked, for FreeBSD 6.1, stripped
root at localhost ~ #

Doing some research I found that every static binary has the same
issue, so consider the following example as trust of this:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
        printf("it works!\n");
        exit(EXIT_SUCCESS);
}

Compile it statically:
root at localhost ~ # gcc -static test.c -o test
root at localhost ~ # file test
test: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for
FreeBSD 6.1, statically linked, for FreeBSD 6.1, not stripped
root at localhost ~ #

Then run it:
root at localhost ~ # ./test
ELF binary type "0" not known.
- -su: ./test: cannot execute binary file
root at localhost ~ #


Now it's time to do the same as dinamically:
root at localhost ~ # gcc test.c -o test
root at localhost ~ # file test
test: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for
FreeBSD 6.1, dynamically linked (uses shared libs), for FreeBSD 6.1,
not stripped
root at localhost ~ # ./test
it works!
root at localhost ~ #

Can anyone point me a possible solution to fix this? I tried doing:
"sysctl kern.default_elf_branding=9" but it's a hack and I think it
should have a more elegant solution.

For some system information, I have the following:

binutils (version 2.17), available BFDs: elf64-x86-64 elf32-i386
elf32-i386-freebsd coff-i386 efi-app-ia32 elf64-little elf64-big
elf32-little elf32-big srec symbolsrec tekhex binary ihex
binutils (version 2.16), available emulations: elf_x86_64_fbsd
elf_i386_fbsd elf_x86_64 elf_i386
gcc: gcc (GCC) 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)
system: athlon64 3500+
freebsd sources used: 6.1-RELEASE

Thanks for any input in advance,
- --
Victor Roman Archidona
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32)
 
iD8DBQFEry+sQ/ddYKMfqaARAqUeAJ9TTWBLAJCLxQ7pkNOZHWoc0qFkpQCfY9WT
HO1N6kfSIgmROAFT1fxMp9o=
=4vZz
-----END PGP SIGNATURE-----



More information about the freebsd-hackers mailing list