From 71a75f6f15bcaf99d98bb50ddd57ec8e8d1bbc9d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 18 Oct 2006 23:58:52 +0000 Subject: [PATCH] 2006-10-18 Roy Marples * bfd/elf64-sparc.c: Add FreeBSD support. (elf64_sparc_fbsd_post_process_headers): New function. * bfd/targets.c (_bfd_target_vector): Add bfd_elf64_sparc_freebsd_vec. * bfd/config.bfd (sparc64-*-freebsd*): Set targ_defvec to bfd_elf64_sparc_freebsd_vec. * bfd/configure.in: Add entry for bfd_elf64_sparc_freebsd_vec. * bfd/configure: Regenerate. * gas/config/tc-sparc.c (md_parse_option): Treat any target starting with elf32-sparc as a viable target for the -32 switch and any target starting with elf64-sparc as a viable target for the -64 switch. (sparc_target_format): For 64-bit ELF flavoured output use ELF_TARGET_FORMAT64 while for 32-bit ELF flavoured output use ELF_TARGET_FORMAT. * gas/config/tc-sparc.h (ELF_TARGET_FORMAT, ELF_TARGET_FORMAT64): Define. * ld/emulparams/elf64_sparc_fbsd.sh (OUTPUT_FORMAT): Define as elf64-sparc-freebsd. --- bfd/ChangeLog | 9 +++++++++ bfd/config.bfd | 6 +++++- bfd/configure | 1 + bfd/configure.in | 1 + bfd/elf64-sparc.c | 30 ++++++++++++++++++++++++++++++ bfd/targets.c | 2 ++ gas/ChangeLog | 9 +++++++++ gas/config/tc-sparc.c | 6 +++--- gas/config/tc-sparc.h | 13 +++++++++++++ ld/ChangeLog | 4 ++++ ld/emulparams/elf64_sparc_fbsd.sh | 2 ++ 11 files changed, 79 insertions(+), 4 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 961e65e04c9..c558facd7a8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,12 @@ +2006-10-18 Roy Marples + + * elf64-sparc.c: Add FreeBSD support. + (elf64_sparc_fbsd_post_process_headers): New function. + * targets.c (_bfd_target_vector): Add bfd_elf64_sparc_freebsd_vec. + * config.bfd (sparc64-*-freebsd*): Set targ_defvec to bfd_elf64_sparc_freebsd_vec. + * configure.in: Add entry for bfd_elf64_sparc_freebsd_vec. + * configure: Regenerate. + 2006-10-17 Mark Shinwell * elf32-arm.c (elf32_arm_final_link_relocate): Add support for diff --git a/bfd/config.bfd b/bfd/config.bfd index 6f6a7b9168c..31dbf0e9fae 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -182,7 +182,11 @@ case "${targ}" in targ_selvecs="bfd_elf64_ia64_hpux_big_vec" want64=true ;; - sparc64-*-freebsd* | sparc64-*-netbsd* | sparc64-*-openbsd* | sparc64-*-kfreebsd*-gnu) + sparc64-*-freebsd* | sparc64-*-kfreebsd*-gnu) + targ_defvec=bfd_elf64_sparc_freebsd_vec + targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec" + ;; + sparc64-*-netbsd* | sparc64-*-openbsd*) targ_defvec=bfd_elf64_sparc_vec targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec" want64=true diff --git a/bfd/configure b/bfd/configure index 0f878f04d9f..fa61beedffd 100755 --- a/bfd/configure +++ b/bfd/configure @@ -10926,6 +10926,7 @@ do bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_sparc_freebsd_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 ;; diff --git a/bfd/configure.in b/bfd/configure.in index 339af936af3..05324348335 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -716,6 +716,7 @@ do bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf-vxworks.lo elf64.lo $elf"; target_size=64 ;; + bfd_elf64_sparc_freebsd_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 ;; diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 11855537054..0eefc95c125 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -904,3 +904,33 @@ const struct elf_size_info elf64_sparc_size_info = #define elf_backend_plt_alignment 8 #include "elf64-target.h" + +/* FreeBSD support */ +#undef TARGET_BIG_SYM +#define TARGET_BIG_SYM bfd_elf64_sparc_freebsd_vec +#undef TARGET_BIG_NAME +#define TARGET_BIG_NAME "elf64-sparc-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_sparc_fbsd_post_process_headers (bfd *abfd, + struct bfd_link_info *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_sparc_fbsd_post_process_headers +#undef elf64_bed +#define elf64_bed elf64_sparc_fbsd_bed + +#include "elf64-target.h" + diff --git a/bfd/targets.c b/bfd/targets.c index 117e7c6e33d..96fab096f9d 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -674,6 +674,7 @@ extern const bfd_target bfd_elf64_sh64blin_vec; extern const bfd_target bfd_elf64_sh64lnbsd_vec; extern const bfd_target bfd_elf64_sh64nbsd_vec; extern const bfd_target bfd_elf64_sparc_vec; +extern const bfd_target bfd_elf64_sparc_freebsd_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; @@ -1002,6 +1003,7 @@ static const bfd_target * const _bfd_target_vector[] = &bfd_elf64_sh64lin_vec, &bfd_elf64_sh64blin_vec, &bfd_elf64_sparc_vec, + &bfd_elf64_sparc_freebsd_vec, &bfd_elf64_tradbigmips_vec, &bfd_elf64_tradlittlemips_vec, &bfd_elf64_x86_64_freebsd_vec, diff --git a/gas/ChangeLog b/gas/ChangeLog index 38b93fbb6c0..22262e37918 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2006-10-18 Roy Marples + + * config/tc-sparc.c (md_parse_option): Treat any target starting with + elf32-sparc as a viable target for the -32 switch and any target starting with + elf64-sparc as a viable target for the -64 switch. + (sparc_target_format): For 64-bit ELF flavoured output use ELF_TARGET_FORMAT64 + while for 32-bit ELF flavoured output use ELF_TARGET_FORMAT. + * config/tc-sparc.h (ELF_TARGET_FORMAT, ELF_TARGET_FORMAT64): Define. + 2006-10-17 H.J. Lu * configure: Regenerated. diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index d84c2733678..d6a1a15e731 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -337,7 +337,7 @@ sparc_target_format () #endif #ifdef OBJ_ELF - return sparc_arch_size == 64 ? "elf64-sparc" : "elf32-sparc"; + return sparc_arch_size == 64 ? ELF64_TARGET_FORMAT : ELF_TARGET_FORMAT; #endif abort (); @@ -545,12 +545,12 @@ md_parse_option (c, arg) { if (sparc_arch_size == 32) { - if (strcmp (*l, "elf32-sparc") == 0) + if (CONST_STRNEQ (*l, "elf32-sparc")) break; } else { - if (strcmp (*l, "elf64-sparc") == 0) + if (CONST_STRNEQ (*l, "elf64-sparc")) break; } } diff --git a/gas/config/tc-sparc.h b/gas/config/tc-sparc.h index 3feac4f3620..3318dddd74b 100644 --- a/gas/config/tc-sparc.h +++ b/gas/config/tc-sparc.h @@ -31,6 +31,19 @@ struct frag; #define TARGET_ARCH bfd_arch_sparc +#ifdef TE_FreeBSD +#define ELF_TARGET_FORMAT "elf32-sparc-freebsd" +#define ELF64_TARGET_FORMAT "elf64-sparc-freebsd" +#endif + +#ifndef ELF_TARGET_FORMAT +#define ELF_TARGET_FORMAT "elf32-sparc" +#endif + +#ifndef ELF64_TARGET_FORMAT +#define ELF64_TARGET_FORMAT "elf64-sparc" +#endif + extern const char *sparc_target_format PARAMS ((void)); #define TARGET_FORMAT sparc_target_format () diff --git a/ld/ChangeLog b/ld/ChangeLog index 674051eaa12..33bbe3d8d0a 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,7 @@ +2006-10-18 Roy Marples + + * emulparams/elf64_sparc_fbsd.sh (OUTPUT_FORMAT): Define as elf64-sparc-freebsd. + 2006-10-18 Joseph Myers * configure.tgt (i[3-7]86-*-linux-*): Also define diff --git a/ld/emulparams/elf64_sparc_fbsd.sh b/ld/emulparams/elf64_sparc_fbsd.sh index 232a32143b0..21d13ab4985 100644 --- a/ld/emulparams/elf64_sparc_fbsd.sh +++ b/ld/emulparams/elf64_sparc_fbsd.sh @@ -1,2 +1,4 @@ . ${srcdir}/emulparams/elf64_sparc.sh . ${srcdir}/emulparams/elf_fbsd.sh + +OUTPUT_FORMAT="elf64-sparc-freebsd" -- 2.30.2