This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: support for FreeBSD and GNU/FreeBSD
David O'Brien wrote:
> 6.0 will not support it [the old-style branding], and 5.0 might not.
So here is an updated patch which uses the new-style branding by
default for kernels >= 4.1.
bfd/ChangeLog:
2002-07-04 Bruno Haible <bruno@clisp.org>
* elf32-i386.c: Don't defined ELF_ARCH etc. if this file is included
by a target variant implementation.
* elf64-alpha.c: Likewise.
* elf32-i386-fbsd.c: New file.
* elf64-alpha-fbsd.c: New file.
* targets.c: Support bfd_elf32_i386_freebsd_vec and
bfd_elf64_alpha_freebsd_vec.
* configure.in: Accept the vectors bfd_elf32_i386_freebsd_vec,
bfd_elf64_alpha_freebsd_vec.
* Makefile.am (BFD32_BACKENDS): Add elf32-i386-fbsd.lo.
(BFD32_BACKENDS_CFILES): Add elf32-i386-fbsd.c.
(BFD64_BACKENDS): Add elf64-alpha-fbsd.lo.
(BFD64_BACKENDS_CFILES): Add elf64-alpha-fbsd.c.
(elf32-i386-fbsd.lo, elf64-alpha-fbsd.lo): Add dependencies.
* config.bfd: For FreeBSD targets, set targ_defvec to a FreeBSD
specific targets. Define OLD_FREEBSD_ABI_LABEL if appropriate.
gas/ChangeLog:
2002-07-04 Bruno Haible <bruno@clisp.org>
* config/tc-i386.h (ELF_TARGET_FORMAT): New macro.
(TARGET_FORMAT): Use ELF_TARGET_FORMAT instead of "elf32-i386".
* config/tc-i386.c (i386_target_format): Likewise.
* config/tc-alpha.h (ELF_TARGET_FORMAT): New macro.
(TARGET_FORMAT): Use ELF_TARGET_FORMAT instead of "elf64-alpha".
ld/ChangeLog:
2002-07-04 Bruno Haible <bruno@clisp.org>
* emulparams/elf_i386_fbsd.sh: Set OUTPUT_FORMAT to
elf32-i386-freebsd.
* emulparams/elf64alpha_fbsd.sh: Set OUTPUT_FORMAT to
elf64-alpha-freebsd.
*** binutils-2.12.90.0.14/bfd/elf32-i386.c.bak Wed Jun 26 18:24:56 2002
--- binutils-2.12.90.0.14/bfd/elf32-i386.c Wed Jul 3 00:21:07 2002
***************
*** 3107,3117 ****
--- 3107,3119 ----
return true;
}
+ #ifndef ELF_ARCH
#define TARGET_LITTLE_SYM bfd_elf32_i386_vec
#define TARGET_LITTLE_NAME "elf32-i386"
#define ELF_ARCH bfd_arch_i386
#define ELF_MACHINE_CODE EM_386
#define ELF_MAXPAGESIZE 0x1000
+ #endif /* ELF_ARCH */
#define elf_backend_can_gc_sections 1
#define elf_backend_can_refcount 1
*** binutils-2.12.90.0.14/bfd/elf64-alpha.c.bak Wed Jun 26 18:24:56 2002
--- binutils-2.12.90.0.14/bfd/elf64-alpha.c Wed Jul 3 00:21:08 2002
***************
*** 5539,5549 ****
--- 5539,5551 ----
NULL
};
+ #ifndef ELF_ARCH
#define TARGET_LITTLE_SYM bfd_elf64_alpha_vec
#define TARGET_LITTLE_NAME "elf64-alpha"
#define ELF_ARCH bfd_arch_alpha
#define ELF_MACHINE_CODE EM_ALPHA
#define ELF_MAXPAGESIZE 0x10000
+ #endif /* ELF_ARCH */
#define bfd_elf64_bfd_link_hash_table_create \
elf64_alpha_bfd_link_hash_table_create
*** binutils-2.12.90.0.14/bfd/elf32-i386-fbsd.c.bak Wed Jul 3 00:21:07 2002
--- binutils-2.12.90.0.14/bfd/elf32-i386-fbsd.c Mon Jul 8 23:24:47 2002
***************
*** 0 ****
--- 1,57 ----
+ /* Intel IA-32 specific support for 32-bit ELF on FreeBSD.
+ Copyright 2002 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+ #define TARGET_LITTLE_SYM bfd_elf32_i386_freebsd_vec
+ #define TARGET_LITTLE_NAME "elf32-i386-freebsd"
+ #define ELF_ARCH bfd_arch_i386
+ #define ELF_MACHINE_CODE EM_386
+ #define ELF_MAXPAGESIZE 0x1000
+
+ #include "bfd.h"
+ #include "sysdep.h"
+ #include "elf-bfd.h"
+
+ /* 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_i386_post_process_headers
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+ static void
+ elf_i386_post_process_headers (abfd, link_info)
+ 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);
+
+ #ifdef OLD_FREEBSD_ABI_LABEL
+ /* The ABI label supported by FreeBSD <= 4.0 is quite nonstandard. */
+ memcpy (&i_ehdrp->e_ident[EI_ABIVERSION], "FreeBSD", 8);
+ #else
+ /* Put an ABI label supported by FreeBSD >= 4.1. */
+ i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
+ #endif
+ }
+
+ #define elf_backend_post_process_headers elf_i386_post_process_headers
+
+ #include "elf32-i386.c"
*** binutils-2.12.90.0.14/bfd/elf64-alpha-fbsd.c.bak Wed Jul 3 00:21:08 2002
--- binutils-2.12.90.0.14/bfd/elf64-alpha-fbsd.c Mon Jul 8 23:24:47 2002
***************
*** 0 ****
--- 1,57 ----
+ /* Alpha specific support for 64-bit ELF on FreeBSD.
+ Copyright 2002 Free Software Foundation, Inc.
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+ #define TARGET_LITTLE_SYM bfd_elf64_alpha_freebsd_vec
+ #define TARGET_LITTLE_NAME "elf64-alpha-freebsd"
+ #define ELF_ARCH bfd_arch_alpha
+ #define ELF_MACHINE_CODE EM_ALPHA
+ #define ELF_MAXPAGESIZE 0x10000
+
+ #include "bfd.h"
+ #include "sysdep.h"
+ #include "elf-bfd.h"
+
+ /* 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_alpha_post_process_headers
+ PARAMS ((bfd *, struct bfd_link_info *));
+
+ static void
+ elf_alpha_post_process_headers (abfd, link_info)
+ 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);
+
+ #ifdef OLD_FREEBSD_ABI_LABEL
+ /* The ABI label supported by FreeBSD <= 4.0 is quite nonstandard. */
+ memcpy (&i_ehdrp->e_ident[EI_ABIVERSION], "FreeBSD", 8);
+ #else
+ /* Put an ABI label supported by FreeBSD >= 4.1. */
+ i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
+ #endif
+ }
+
+ #define elf_backend_post_process_headers elf_alpha_post_process_headers
+
+ #include "elf64-alpha.c"
*** binutils-2.12.90.0.14/bfd/targets.c.bak Wed Jun 26 18:24:56 2002
--- binutils-2.12.90.0.14/bfd/targets.c Wed Jul 3 00:21:07 2002
***************
*** 519,524 ****
--- 519,525 ----
extern const bfd_target bfd_elf32_hppa_linux_vec;
extern const bfd_target bfd_elf32_hppa_vec;
extern const bfd_target bfd_elf32_i370_vec;
+ extern const bfd_target bfd_elf32_i386_freebsd_vec;
extern const bfd_target bfd_elf32_i386_vec;
extern const bfd_target bfd_elf32_i386qnx_vec;
extern const bfd_target bfd_elf32_i860_little_vec;
***************
*** 564,569 ****
--- 565,571 ----
extern const bfd_target bfd_elf32_v850_vec;
extern const bfd_target bfd_elf32_vax_vec;
extern const bfd_target bfd_elf32_xstormy16_vec;
+ extern const bfd_target bfd_elf64_alpha_freebsd_vec;
extern const bfd_target bfd_elf64_alpha_vec;
extern const bfd_target bfd_elf64_big_generic_vec;
extern const bfd_target bfd_elf64_bigmips_vec;
***************
*** 780,785 ****
--- 782,788 ----
&bfd_elf32_hppa_linux_vec,
&bfd_elf32_hppa_vec,
&bfd_elf32_i370_vec,
+ &bfd_elf32_i386_freebsd_vec,
&bfd_elf32_i386_vec,
&bfd_elf32_i386qnx_vec,
&bfd_elf32_i860_little_vec,
***************
*** 830,835 ****
--- 833,839 ----
&bfd_elf32_vax_vec,
&bfd_elf32_xstormy16_vec,
#ifdef BFD64
+ &bfd_elf64_alpha_freebsd_vec,
&bfd_elf64_alpha_vec,
&bfd_elf64_big_generic_vec,
&bfd_elf64_bigmips_vec,
*** binutils-2.12.90.0.14/bfd/configure.in.bak Thu Jun 27 17:54:09 2002
--- binutils-2.12.90.0.14/bfd/configure.in Wed Jul 3 00:21:07 2002
***************
*** 575,580 ****
--- 575,581 ----
bfd_elf32_hppa_linux_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
bfd_elf32_hppa_vec) tb="$tb elf32-hppa.lo elf32.lo $elf" ;;
bfd_elf32_i370_vec) tb="$tb elf32-i370.lo elf32.lo $elf" ;;
+ bfd_elf32_i386_freebsd_vec) tb="$tb elf32-i386-fbsd.lo elf32.lo $elf" ;;
bfd_elf32_i386_vec) tb="$tb elf32-i386.lo elf32.lo $elf" ;;
bfd_elf32_i386qnx_vec) tb="$tb elf32-i386qnx.lo elf32.lo $elf" ;;
bfd_elf32_i860_little_vec) tb="$tb elf32-i860.lo elf32.lo $elf" ;;
***************
*** 623,628 ****
--- 624,630 ----
bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;;
bfd_elf32_vax_vec) tb="$tb elf32-vax.lo elf32.lo $elf" ;;
bfd_elf32_xstormy16_vec) tb="$tb elf32-xstormy16.lo elf32.lo $elf" ;;
+ bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha-fbsd.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;;
bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;;
*** binutils-2.12.90.0.14/bfd/Makefile.am.bak Wed Jun 19 06:41:58 2002
--- binutils-2.12.90.0.14/bfd/Makefile.am Wed Jul 3 00:25:50 2002
***************
*** 210,215 ****
--- 210,216 ----
elf32-hppa.lo \
elf32-i370.lo \
elf32-i386.lo \
+ elf32-i386-fbsd.lo \
elf32-i386qnx.lo \
elf32-i860.lo \
elf32-i960.lo \
***************
*** 366,371 ****
--- 367,373 ----
elf32-hppa.c \
elf32-i370.c \
elf32-i386.c \
+ elf32-i386-fbsd.c \
elf32-i386qnx.c \
elf32-i860.c \
elf32-i960.c \
***************
*** 471,476 ****
--- 473,479 ----
efi-app-ia64.lo \
elf64-x86-64.lo \
elf64-alpha.lo \
+ elf64-alpha-fbsd.lo \
elf64-hppa.lo \
elf64-ia64.lo \
elf64-gen.lo \
***************
*** 496,501 ****
--- 499,505 ----
efi-app-ia64.c \
elf64-x86-64.c \
elf64-alpha.c \
+ elf64-alpha-fbsd.c \
elf64-hppa.c \
elf64-gen.c \
elf64-mips.c \
***************
*** 1135,1140 ****
--- 1139,1148 ----
elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/i386.h $(INCDIR)/elf/reloc-macros.h \
elf32-target.h
+ elf32-i386-fbsd.lo: elf32-i386-fbsd.c elf32-i386.c $(INCDIR)/filenames.h \
+ $(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/i386.h \
+ $(INCDIR)/elf/reloc-macros.h elf32-target.h
elf32-i386qnx.lo: elf32-i386qnx.c elf32-i386.c $(INCDIR)/filenames.h \
$(INCDIR)/bfdlink.h elf-bfd.h $(INCDIR)/elf/common.h \
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/i386.h \
***************
*** 1480,1485 ****
--- 1488,1500 ----
$(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
$(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \
libecoff.h ecoffswap.h elf64-target.h
+ elf64-alpha-fbsd.lo: elf64-alpha-fbsd.c elf64-alpha.c $(INCDIR)/filenames.h \
+ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/alpha.h \
+ $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/internal.h \
+ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \
+ $(INCDIR)/coff/alpha.h $(INCDIR)/aout/ar.h libcoff.h \
+ libecoff.h ecoffswap.h elf64-target.h
elf64-hppa.lo: elf64-hppa.c $(INCDIR)/alloca-conf.h \
$(INCDIR)/filenames.h elf-bfd.h $(INCDIR)/elf/common.h \
$(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
*** binutils-2.12.90.0.14/bfd/config.bfd.bak Wed Jun 26 18:24:56 2002
--- binutils-2.12.90.0.14/bfd/config.bfd Mon Jul 8 23:27:35 2002
***************
*** 70,76 ****
case "${targ}" in
# START OF targmatch.h
#ifdef BFD64
! alpha*-*-netbsd* | alpha*-*-freebsd* | alpha*-*-openbsd*)
targ_defvec=bfd_elf64_alpha_vec
targ_selvecs=ecoffalpha_little_vec
;;
--- 70,85 ----
case "${targ}" in
# START OF targmatch.h
#ifdef BFD64
! alpha*-*-freebsd*)
! targ_defvec=bfd_elf64_alpha_freebsd_vec
! targ_selvecs=ecoffalpha_little_vec
! # FreeBSD <= 4.0 supports only the old nonstandard way of ABI labelling.
! case "${targ}" in
! alpha*-*-freebsd3* | alpha*-*-freebsd4 | alpha*-*-freebsd4.0*)
! targ_cflags=-DOLD_FREEBSD_ABI_LABEL ;;
! esac
! ;;
! alpha*-*-netbsd* | alpha*-*-openbsd*)
targ_defvec=bfd_elf64_alpha_vec
targ_selvecs=ecoffalpha_little_vec
;;
***************
*** 388,395 ****
targ_underscore=yes
;;
i[3456]86-*-freebsd*)
! targ_defvec=bfd_elf32_i386_vec
targ_selvecs=i386coff_vec
;;
i[3456]86-*-netbsdelf*)
targ_defvec=bfd_elf32_i386_vec
--- 397,409 ----
targ_underscore=yes
;;
i[3456]86-*-freebsd*)
! targ_defvec=bfd_elf32_i386_freebsd_vec
targ_selvecs=i386coff_vec
+ # FreeBSD <= 4.0 supports only the old nonstandard way of ABI labelling.
+ case "${targ}" in
+ i[3456]86-*-freebsd3* | i[3456]86-*-freebsd4 | i[3456]86-*-freebsd4.0*)
+ targ_cflags=-DOLD_FREEBSD_ABI_LABEL ;;
+ esac
;;
i[3456]86-*-netbsdelf*)
targ_defvec=bfd_elf32_i386_vec
*** binutils-2.12.90.0.14/gas/config/tc-i386.h.bak Fri May 24 00:10:10 2002
--- binutils-2.12.90.0.14/gas/config/tc-i386.h Wed Jul 3 00:21:08 2002
***************
*** 98,110 ****
#define AOUT_TARGET_FORMAT "a.out-i386"
#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));
#define TARGET_FORMAT i386_target_format ()
#else
#ifdef OBJ_ELF
! #define TARGET_FORMAT "elf32-i386"
#endif
#ifdef OBJ_AOUT
#define TARGET_FORMAT AOUT_TARGET_FORMAT
--- 98,117 ----
#define AOUT_TARGET_FORMAT "a.out-i386"
#endif
+ #ifdef TE_FreeBSD
+ #define ELF_TARGET_FORMAT "elf32-i386-freebsd"
+ #endif
+ #ifndef ELF_TARGET_FORMAT
+ #define ELF_TARGET_FORMAT "elf32-i386"
+ #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));
#define TARGET_FORMAT i386_target_format ()
#else
#ifdef OBJ_ELF
! #define TARGET_FORMAT ELF_TARGET_FORMAT
#endif
#ifdef OBJ_AOUT
#define TARGET_FORMAT AOUT_TARGET_FORMAT
*** binutils-2.12.90.0.14/gas/config/tc-i386.c.bak Fri May 24 00:10:10 2002
--- binutils-2.12.90.0.14/gas/config/tc-i386.c Wed Jul 3 00:21:08 2002
***************
*** 4899,4905 ****
{
if (flag_code == CODE_64BIT)
use_rela_relocations = 1;
! return flag_code == CODE_64BIT ? "elf64-x86-64" : "elf32-i386";
}
#endif
default:
--- 4899,4905 ----
{
if (flag_code == CODE_64BIT)
use_rela_relocations = 1;
! return flag_code == CODE_64BIT ? "elf64-x86-64" : ELF_TARGET_FORMAT;
}
#endif
default:
*** binutils-2.12.90.0.14/gas/config/tc-alpha.h.bak Thu Mar 7 20:52:37 2002
--- binutils-2.12.90.0.14/gas/config/tc-alpha.h Wed Jul 3 00:21:08 2002
***************
*** 28,37 ****
#define TARGET_ARCH bfd_arch_alpha
#define TARGET_FORMAT (OUTPUT_FLAVOR == bfd_target_ecoff_flavour \
? "ecoff-littlealpha" \
: OUTPUT_FLAVOR == bfd_target_elf_flavour \
! ? "elf64-alpha" \
: OUTPUT_FLAVOR == bfd_target_evax_flavour \
? "vms-alpha" \
: "unknown-format")
--- 28,44 ----
#define TARGET_ARCH bfd_arch_alpha
+ #ifdef TE_FreeBSD
+ #define ELF_TARGET_FORMAT "elf64-alpha-freebsd"
+ #endif
+ #ifndef ELF_TARGET_FORMAT
+ #define ELF_TARGET_FORMAT "elf64-alpha"
+ #endif
+
#define TARGET_FORMAT (OUTPUT_FLAVOR == bfd_target_ecoff_flavour \
? "ecoff-littlealpha" \
: OUTPUT_FLAVOR == bfd_target_elf_flavour \
! ? ELF_TARGET_FORMAT \
: OUTPUT_FLAVOR == bfd_target_evax_flavour \
? "vms-alpha" \
: "unknown-format")
*** binutils-2.12.90.0.14/ld/emulparams/elf_i386_fbsd.sh.bak Thu Mar 7 20:52:39 2002
--- binutils-2.12.90.0.14/ld/emulparams/elf_i386_fbsd.sh Wed Jul 3 00:21:08 2002
***************
*** 1,2 ****
--- 1,3 ----
. ${srcdir}/emulparams/elf_i386.sh
. ${srcdir}/emulparams/elf_fbsd.sh
+ OUTPUT_FORMAT="elf32-i386-freebsd"
*** binutils-2.12.90.0.14/ld/emulparams/elf64alpha_fbsd.sh.bak Thu Mar 7 20:52:39 2002
--- binutils-2.12.90.0.14/ld/emulparams/elf64alpha_fbsd.sh Wed Jul 3 00:21:08 2002
***************
*** 1,2 ****
--- 1,3 ----
. ${srcdir}/emulparams/elf64alpha.sh
. ${srcdir}/emulparams/elf_fbsd.sh
+ OUTPUT_FORMAT="elf64-alpha-freebsd"