From owner-freebsd-current@FreeBSD.ORG Fri Dec 3 23:52:54 2010 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71180106564A; Fri, 3 Dec 2010 23:52:54 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net [IPv6:2001:7b8:2ff:146::2]) by mx1.freebsd.org (Postfix) with ESMTP id E47738FC08; Fri, 3 Dec 2010 23:52:53 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7:0:a843:62a5:7ce2:96d7] (unknown [IPv6:2001:7b8:3a7:0:a843:62a5:7ce2:96d7]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 3BAC85C5A; Sat, 4 Dec 2010 00:52:52 +0100 (CET) Message-ID: <4CF982D9.7070602@FreeBSD.org> Date: Sat, 04 Dec 2010 00:52:57 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.2.14pre) Gecko/20101201 Lanikai/3.1.8pre MIME-Version: 1.0 To: freebsd-current@freebsd.org, Marcel Moolenaar References: <20101203095831.GA5468@mech-cluster241.men.bris.ac.uk> In-Reply-To: <20101203095831.GA5468@mech-cluster241.men.bris.ac.uk> Content-Type: multipart/mixed; boundary="------------070300000904050308030702" Cc: Subject: Re: binutils problem? WAS [Re: static linking error: ELF binary type "0" not known. Exec format error. Binary file not executable.] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Dec 2010 23:52:54 -0000 This is a multi-part message in MIME format. --------------070300000904050308030702 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 2010-12-03 10:58, Anton Shterenlikht wrote: >>> a.out: ELF 64-bit LSB executable, IA-64, version 1 (SYSV), statically linked, not stripped ... >> The branding on ia64 is wrong. The executable is not marked as being >> a FreeBSD executable. It's declared as SYSV, whereas on amd64 it's >> properly declared as FreeBSD. >> >> This is a binutils problem. ... > Anybody here can explain better what Marcel means > by "binutils problem", and how to fix it? > > I've binutils-2.20.1_3 installed from devel/binutils. The problem is that our base binutils's BFD library has a custom hack to 'brand' the produced executables, e.g. set the ELF_OSABI field in the ELF header to ELFOSABI_FREEBSD. Other arches such as i386, amd64 (x86_64 in binutils land), sparc and even alpha (!) have had patches sent upstream to do the right thing for FreeBSD, but not ia64. If you can, please try the attached patch, which resolves the problem on the ia64 machine I have tried it on. It should really be sent upstream to the binutils people, if there is some interest. Alternatively, we can shove a similar patch into the binutils port, but I'm not sure how much the ports people will like that. :) I think I will apply the same approach to my projects/binutils-2.17 branch (aimed at importing the last GPLv2 binutils version into head). Having target names clearly defined as elfXX-archname-freebsd is much easier to deal with. --------------070300000904050308030702 Content-Type: text/plain; name="binutils-ia64-freebsd.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="binutils-ia64-freebsd.diff" diff --git a/bfd/config.bfd b/bfd/config.bfd index 9b719d8..d2fe23e 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -182,7 +182,12 @@ case "${targ}" in targ_defvec=ecoffalpha_little_vec want64=true ;; - ia64*-*-freebsd* | ia64*-*-netbsd* | ia64*-*-linux-* | ia64*-*-elf* | ia64*-*-kfreebsd*-gnu) + ia64*-*-freebsd* | ia64*-*-kfreebsd*-gnu) + targ_defvec=bfd_elf64_ia64_freebsd_vec + targ_selvecs="bfd_elf64_ia64_little_vec bfd_elf64_ia64_big_vec bfd_pei_ia64_vec" + want64=true + ;; + ia64*-*-netbsd* | ia64*-*-linux-* | ia64*-*-elf*) targ_defvec=bfd_elf64_ia64_little_vec targ_selvecs="bfd_elf64_ia64_big_vec bfd_pei_ia64_vec" want64=true diff --git a/bfd/configure b/bfd/configure index 278cc1d..ad9dcc9 100755 --- a/bfd/configure +++ b/bfd/configure @@ -15169,6 +15169,7 @@ do bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_hppa_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_ia64_freebsd_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_vms_vec) tb="$tb elf64-ia64.lo elf64.lo vms-lib.lo vms-misc.lo $elf"; target_size=64 ;; diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index d42ad89..5625c44 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -6077,6 +6077,26 @@ elfNN_vms_close_and_cleanup (bfd *abfd) #include "elfNN-target.h" +/* FreeBSD support. */ + +#undef TARGET_LITTLE_SYM +#define TARGET_LITTLE_SYM bfd_elfNN_ia64_freebsd_vec +#undef TARGET_LITTLE_NAME +#define TARGET_LITTLE_NAME "elfNN-ia64-freebsd" +#undef TARGET_BIG_SYM +#undef TARGET_BIG_NAME + +#undef ELF_OSABI +#define ELF_OSABI ELFOSABI_FREEBSD + +#undef elf_backend_post_process_headers +#define elf_backend_post_process_headers _bfd_elf_set_osabi + +#undef elfNN_bed +#define elfNN_bed elfNN_ia64_fbsd_bed + +#include "elfNN-target.h" + /* HPUX-specific vectors. */ #undef TARGET_LITTLE_SYM diff --git a/bfd/targets.c b/bfd/targets.c index 3e99754..a642a8d 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -697,6 +697,7 @@ extern const bfd_target bfd_elf64_bigmips_vec; extern const bfd_target bfd_elf64_hppa_linux_vec; extern const bfd_target bfd_elf64_hppa_vec; extern const bfd_target bfd_elf64_ia64_big_vec; +extern const bfd_target bfd_elf64_ia64_freebsd_vec; extern const bfd_target bfd_elf64_ia64_hpux_big_vec; extern const bfd_target bfd_elf64_ia64_little_vec; extern const bfd_target bfd_elf64_ia64_vms_vec; diff --git a/ld/emulparams/elf64_ia64_fbsd.sh b/ld/emulparams/elf64_ia64_fbsd.sh index ab7e78f..a7e2675 100644 --- a/ld/emulparams/elf64_ia64_fbsd.sh +++ b/ld/emulparams/elf64_ia64_fbsd.sh @@ -4,3 +4,4 @@ unset DATA_ADDR unset SMALL_DATA_CTOR unset SMALL_DATA_DTOR . ${srcdir}/emulparams/elf_fbsd.sh +OUTPUT_FORMAT="elf64-ia64-freebsd" --------------070300000904050308030702--