diff -ru binutils-2.17/bfd/config.bfd binutils-2.17-patched/bfd/config.bfd --- binutils-2.17/bfd/config.bfd 2007-04-17 21:10:35 +0200 +++ binutils-2.17-patched/bfd/config.bfd 2007-04-17 21:02:31 +0200 @@ -555,8 +555,8 @@ targ_selvecs="bfd_elf32_i386_vec i386coff_vec" ;; x86_64-*-freebsd* | x86_64-*-kfreebsd*-gnu) - targ_defvec=bfd_elf64_x86_64_vec - targ_selvecs="bfd_elf32_i386_vec i386coff_vec bfd_efi_app_ia32_vec" + targ_defvec=bfd_elf64_x86_64_freebsd_vec + targ_selvecs="bfd_elf32_i386_freebsd_vec i386coff_vec bfd_efi_app_ia32_vec" ;; x86_64-*-netbsd* | x86_64-*-openbsd*) targ_defvec=bfd_elf64_x86_64_vec diff -ru binutils-2.17/bfd/configure binutils-2.17-patched/bfd/configure --- binutils-2.17/bfd/configure 2007-04-17 21:10:35 +0200 +++ binutils-2.17-patched/bfd/configure 2007-04-17 21:02:54 +0200 @@ -13196,6 +13196,7 @@ bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; bfd_mmo_vec) tb="$tb mmo.lo" target_size=64 ;; bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;; diff -ru binutils-2.17/bfd/configure.in binutils-2.17-patched/bfd/configure.in --- binutils-2.17/bfd/configure.in 2007-04-17 21:10:35 +0200 +++ binutils-2.17-patched/bfd/configure.in 2007-04-17 21:03:12 +0200 @@ -709,6 +709,7 @@ bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_x86_64_freebsd_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; bfd_mmo_vec) tb="$tb mmo.lo" target_size=64 ;; bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; bfd_powerpc_pei_vec) tb="$tb pei-ppc.lo peigen.lo cofflink.lo" ;; diff -ru binutils-2.17/bfd/elf64-x86-64.c binutils-2.17-patched/bfd/elf64-x86-64.c --- binutils-2.17/bfd/elf64-x86-64.c 2006-03-23 09:23:09 +0100 +++ binutils-2.17-patched/bfd/elf64-x86-64.c 2007-04-17 21:06:03 +0200 @@ -3686,4 +3686,32 @@ #define elf_backend_additional_program_headers \ elf64_x86_64_additional_program_headers +/* FreeBSD support. */ + +#undef TARGET_LITTLE_SYM +#define TARGET_LITTLE_SYM bfd_elf64_x86_64_freebsd_vec +#undef TARGET_LITTLE_NAME +#define TARGET_LITTLE_NAME "elf64-x86-64-freebsd" + +/* The kernel recognizes executables as valid only if they carry a + "FreeBSD" label in the ELF header. So we put this label on all + executables and (for simplicity) also all other object files. */ + +static void +elf_x86_64_post_process_headers (bfd *abfd, + struct bfd_link_info *info ATTRIBUTE_UNUSED) +{ + Elf_Internal_Ehdr *i_ehdrp; + + i_ehdrp = elf_elfheader (abfd); + + /* Put an ABI label supported by FreeBSD >= 4.1. */ + i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD; +} + +#undef elf_backend_post_process_headers +#define elf_backend_post_process_headers elf_x86_64_post_process_headers +#undef elf64_bed +#define elf64_bed elf64_x86_64_fbsd_bed + #include "elf64-target.h" diff -ru binutils-2.17/bfd/targets.c binutils-2.17-patched/bfd/targets.c --- binutils-2.17/bfd/targets.c 2007-04-17 21:10:35 +0200 +++ binutils-2.17-patched/bfd/targets.c 2007-04-17 21:07:04 +0200 @@ -670,6 +670,7 @@ extern const bfd_target bfd_elf64_tradbigmips_vec; extern const bfd_target bfd_elf64_tradlittlemips_vec; extern const bfd_target bfd_elf64_x86_64_vec; +extern const bfd_target bfd_elf64_x86_64_freebsd_vec; extern const bfd_target bfd_mmo_vec; extern const bfd_target bfd_powerpc_pe_vec; extern const bfd_target bfd_powerpc_pei_vec; @@ -987,6 +988,7 @@ &bfd_elf64_tradbigmips_vec, &bfd_elf64_tradlittlemips_vec, &bfd_elf64_x86_64_vec, + &bfd_elf64_x86_64_freebsd_vec, &bfd_mmo_vec, #endif &bfd_powerpc_pe_vec, diff -ru binutils-2.17/gas/config/tc-i386.c binutils-2.17-patched/gas/config/tc-i386.c --- binutils-2.17/gas/config/tc-i386.c 2006-04-07 08:40:57 +0200 +++ binutils-2.17-patched/gas/config/tc-i386.c 2007-04-17 21:08:15 +0200 @@ -5469,7 +5469,7 @@ list = bfd_target_list (); for (l = list; *l != NULL; l++) - if (strcmp (*l, "elf64-x86-64") == 0) + if (strcmp (*l, ELF64_TARGET_FORMAT) == 0) { default_arch = "x86_64"; break; @@ -5566,7 +5566,7 @@ object_64bit = 1; use_rela_relocations = 1; } - return flag_code == CODE_64BIT ? "elf64-x86-64" : ELF_TARGET_FORMAT; + return flag_code == CODE_64BIT ? ELF64_TARGET_FORMAT : ELF_TARGET_FORMAT; } #endif default: diff -ru binutils-2.17/gas/config/tc-i386.h binutils-2.17-patched/gas/config/tc-i386.h --- binutils-2.17/gas/config/tc-i386.h 2006-02-27 16:35:37 +0100 +++ binutils-2.17-patched/gas/config/tc-i386.h 2007-04-17 21:09:27 +0200 @@ -55,6 +55,7 @@ #ifdef TE_FreeBSD #define ELF_TARGET_FORMAT "elf32-i386-freebsd" +#define ELF64_TARGET_FORMAT "elf64-x86-64-freebsd" #elif defined (TE_VXWORKS) #define ELF_TARGET_FORMAT "elf32-i386-vxworks" #endif @@ -62,6 +63,10 @@ #ifndef ELF_TARGET_FORMAT #define ELF_TARGET_FORMAT "elf32-i386" #endif +#ifndef ELF64_TARGET_FORMAT +#define ELF64_TARGET_FORMAT "elf64-x86-64" +#endif + #if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \ || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) diff -ru binutils-2.17/ld/emulparams/elf_x86_64_fbsd.sh binutils-2.17-patched/ld/emulparams/elf_x86_64_fbsd.sh --- binutils-2.17/ld/emulparams/elf_x86_64_fbsd.sh 2002-02-18 10:38:01 +0100 +++ binutils-2.17-patched/ld/emulparams/elf_x86_64_fbsd.sh 2007-04-17 21:01:58 +0200 @@ -1,2 +1,4 @@ . ${srcdir}/emulparams/elf_x86_64.sh . ${srcdir}/emulparams/elf_fbsd.sh + +OUTPUT_FORMAT="elf64-x86-64-freebsd"