From 9d7cbccda0d0b223261e33efb609a7a43401ec5e Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 2 Aug 2006 16:25:14 +0000 Subject: [PATCH] PR binutils/2983 * bfd/elf64-x86-64.c: Add FreeBSD support. (elf64_x86_64_fbsd_post_process_headers): New function. * bfd/targets.c (_bfd_target_vector): Add bfd_elf64_x86_64_freebsd_vec. * bfd/config.bfd (x64_64-*-freebsd*): Add bfd_elf64_x86_64_freebsd_vec to the targ_selvecs. * bfd/configure.in: Add entry for bfd_elf64_x86_64_freebsd_vec. * bfd/configure: Regenerate. * gas/config/tc-i386.c (md_parse_option): Treat any target starting with elf64_x86_64 as a viable target for the -64 switch. (i386_target_format): For 64-bit ELF flavoured output use ELF_TARGET_FORMAT64. * gas/config/tc-i386.h (ELF_TARGET_FORMAT64): Define. * ld/emulparams/elf_x86_64_fbsd.sh (OUTPUT_FORMAT): Define as elf64-x86-64-freebsd. --- bfd/ChangeLog | 11 +++++++++++ bfd/config.bfd | 4 ++-- bfd/configure | 6 ++++-- bfd/configure.in | 1 + bfd/elf64-x86-64.c | 31 +++++++++++++++++++++++++++++++ bfd/targets.c | 2 ++ gas/ChangeLog | 9 +++++++++ gas/config/tc-i386.c | 4 ++-- gas/config/tc-i386.h | 7 ++++++- ld/ChangeLog | 6 ++++++ ld/emulparams/elf_x86_64_fbsd.sh | 1 + 11 files changed, 75 insertions(+), 7 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 0b9613de143..b1537bd85c3 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,14 @@ +2006-08-02 Petr Salinger + + PR binutils/2983 + * elf64-x86-64.c: Add FreeBSD support. + (elf64_x86_64_fbsd_post_process_headers): New function. + * targets.c (_bfd_target_vector): Add bfd_elf64_x86_64_freebsd_vec. + * config.bfd (x64_64-*-freebsd*): Add bfd_elf64_x86_64_freebsd_vec + to the targ_selvecs. + * configure.in: Add entry for bfd_elf64_x86_64_freebsd_vec. + * configure: Regenerate. + 2006-07-26 Andreas Schwab * elfxx-ia64.c (elfNN_ia64_choose_gp): Use rawsize if set. diff --git a/bfd/config.bfd b/bfd/config.bfd index 0a8ed0f6a31..dfe631e0821 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -564,8 +564,8 @@ case "${targ}" in want64=true ;; 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 bfd_elf32_i386_vec bfd_elf64_x86_64_vec" want64=true ;; x86_64-*-netbsd* | x86_64-*-openbsd*) diff --git a/bfd/configure b/bfd/configure index fa9307d4a47..86b94922f13 100755 --- a/bfd/configure +++ b/bfd/configure @@ -5282,8 +5282,9 @@ INCINTL= XGETTEXT= GMSGFMT= POSUB= -if test -f ../intl/config.intl; then - . ../intl/config.intl + +if test -f ../intl/config.intl; then + . ../intl/config.intl fi echo "$as_me:$LINENO: checking whether NLS is requested" >&5 echo $ECHO_N "checking whether NLS is requested... $ECHO_C" >&6 @@ -10917,6 +10918,7 @@ do bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;; 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_freebsd_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_x86_64_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" ;; diff --git a/bfd/configure.in b/bfd/configure.in index 41d55f66e9e..e2061602492 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -708,6 +708,7 @@ do bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;; 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_freebsd_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_x86_64_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" ;; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 6ca622a0d23..34fde961e36 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -3710,3 +3710,34 @@ static const struct bfd_elf_special_section elf64_x86_64_hash_symbol #include "elf64-target.h" + +/* 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 +elf64_x86_64_fbsd_post_process_headers (bfd * abfd, + struct bfd_link_info * link_info ATTRIBUTE_UNUSED) +{ + Elf_Internal_Ehdr * i_ehdrp; /* ELF file header, internal form. */ + + 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 elf64_x86_64_fbsd_post_process_headers + +#undef elf64_bed +#define elf64_bed elf64_x86_64_fbsd_bed + +#include "elf64-target.h" diff --git a/bfd/targets.c b/bfd/targets.c index 180ecd2bf57..ce3e4870951 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -668,6 +668,7 @@ extern const bfd_target bfd_elf64_sh64nbsd_vec; extern const bfd_target bfd_elf64_sparc_vec; extern const bfd_target bfd_elf64_tradbigmips_vec; extern const bfd_target bfd_elf64_tradlittlemips_vec; +extern const bfd_target bfd_elf64_x86_64_freebsd_vec; extern const bfd_target bfd_elf64_x86_64_vec; extern const bfd_target bfd_mmo_vec; extern const bfd_target bfd_powerpc_pe_vec; @@ -984,6 +985,7 @@ static const bfd_target * const _bfd_target_vector[] = { &bfd_elf64_sparc_vec, &bfd_elf64_tradbigmips_vec, &bfd_elf64_tradlittlemips_vec, + &bfd_elf64_x86_64_freebsd_vec, &bfd_elf64_x86_64_vec, &bfd_mmo_vec, #endif diff --git a/gas/ChangeLog b/gas/ChangeLog index 937a60f072b..593d5f82694 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2006-08-02 Petr Salinger + + PR binutils/2983 + * config/tc-i386.c (md_parse_option): Treat any target starting + with elf64_x86_64 as a viable target for the -64 switch. + (i386_target_format): For 64-bit ELF flavoured output use + ELF_TARGET_FORMAT64. + * config/tc-i386.h (ELF_TARGET_FORMAT64): Define. + 2006-08-02 Nick Clifton PR gas/2991 diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 10605109c77..f85aed3b8fd 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -5819,7 +5819,7 @@ md_parse_option (int c, char *arg) list = bfd_target_list (); for (l = list; *l != NULL; l++) - if (strcmp (*l, "elf64-x86-64") == 0) + if (strncmp (*l, "elf64-x86-64", 12) == 0) { default_arch = "x86_64"; break; @@ -5975,7 +5975,7 @@ i386_target_format () object_64bit = 1; use_rela_relocations = 1; } - return flag_code == CODE_64BIT ? "elf64-x86-64" : ELF_TARGET_FORMAT; + return flag_code == CODE_64BIT ? ELF_TARGET_FORMAT64 : ELF_TARGET_FORMAT; } #endif default: diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 4519132abed..43d6df9143d 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -1,6 +1,6 @@ /* tc-i386.h -- Header file for tc-i386.c Copyright 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005 + 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -55,6 +55,7 @@ extern unsigned long i386_mach (void); #ifdef TE_FreeBSD #define ELF_TARGET_FORMAT "elf32-i386-freebsd" +#define ELF_TARGET_FORMAT64 "elf64-x86-64-freebsd" #elif defined (TE_VXWORKS) #define ELF_TARGET_FORMAT "elf32-i386-vxworks" #endif @@ -63,6 +64,10 @@ extern unsigned long i386_mach (void); #define ELF_TARGET_FORMAT "elf32-i386" #endif +#ifndef ELF_TARGET_FORMAT64 +#define ELF_TARGET_FORMAT64 "elf64-x86-64" +#endif + #if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \ || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)) extern const char *i386_target_format PARAMS ((void)); diff --git a/ld/ChangeLog b/ld/ChangeLog index f874f5dbfb3..e3e78d4bf23 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,9 @@ +2006-08-02 Petr Salinger + + PR binutils/2983 + * emulparams/elf_x86_64_fbsd.sh (OUTPUT_FORMAT): Define as + elf64-x86-64-freebsd. + 2006-08-01 H.J. Lu * ldlang.c (init_os): Add flags. Replace bfd_make_section with diff --git a/ld/emulparams/elf_x86_64_fbsd.sh b/ld/emulparams/elf_x86_64_fbsd.sh index 34258cb9289..35b6a626cd3 100644 --- a/ld/emulparams/elf_x86_64_fbsd.sh +++ b/ld/emulparams/elf_x86_64_fbsd.sh @@ -1,2 +1,3 @@ . ${srcdir}/emulparams/elf_x86_64.sh . ${srcdir}/emulparams/elf_fbsd.sh +OUTPUT_FORMAT="elf64-x86-64-freebsd" -- 2.30.2