From owner-freebsd-hackers@FreeBSD.ORG Sat Jul 8 04:08:16 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6719716A4DA for ; Sat, 8 Jul 2006 04:08:16 +0000 (UTC) (envelope-from daijo@unixevil.info) Received: from zeus.daijo.org (zeus.daijo.org [85.17.16.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id A3C5A43D45 for ; Sat, 8 Jul 2006 04:08:15 +0000 (GMT) (envelope-from daijo@unixevil.info) Received: (qmail 21353 invoked by uid 210); 8 Jul 2006 06:12:17 +0200 Received: from 84.123.228.149 by zeus (envelope-from , uid 201) with qmail-scanner-2.01st (clamdscan: 0.88.2/1589. spamassassin: 3.1.3. perlscan: 2.01st. Clear:RC:1(84.123.228.149):. Processed in 0.027317 secs); 08 Jul 2006 04:12:17 -0000 Received: from unknown (HELO ?192.168.1.5?) (84.123.228.149) by 0 with (DHE-RSA-AES256-SHA encrypted) SMTP; 8 Jul 2006 06:12:16 +0200 Message-ID: <44AF2FAD.5020205@unixevil.info> Date: Sat, 08 Jul 2006 06:08:13 +0200 From: Victor Roman Archidona User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org, flameeyes@gentoo.org, spb@gentoo.org X-Enigmail-Version: 0.94.0.0 OpenPGP: id=A31FA9A0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Subject: Static built binaries having unknown ELF binary types X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jul 2006 04:08:16 -0000 -----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@localhost ~ # /usr/bin/make ELF binary type "0" not known. - -su: /usr/bin/make: cannot execute binary file root@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@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@localhost ~ # Doing some research I found that every static binary has the same issue, so consider the following example as trust of this: #include #include int main(int argc, char *argv[]) { printf("it works!\n"); exit(EXIT_SUCCESS); } Compile it statically: root@localhost ~ # gcc -static test.c -o test root@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@localhost ~ # Then run it: root@localhost ~ # ./test ELF binary type "0" not known. - -su: ./test: cannot execute binary file root@localhost ~ # Now it's time to do the same as dinamically: root@localhost ~ # gcc test.c -o test root@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@localhost ~ # ./test it works! root@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-----