Package: binutils
Severity: wishlist
Version: 2.17-2
Tags: patch

Hi,

please, could you include kfreebsd-amd64 related changes
for binutils in Debian package.

The enclosed patch consists of

- 128_kfreebsd-amd64.dpatch
  It adds proper support for elfosabi marking for kfreebsd-amd64
  ("i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_FREEBSD").
  Upstream have this marking only for alpha and i386, this patch extends
  this also for x86-64.

- changes to debian/rules
        * biarch enabled binutils for kfreebsd-amd64 and kfreebsd-i386
        * kfreebsd-amd64 and kfreebsd-i386 support for cross-build
        * kfreebsd-amd64 enabled in multiarch


Thanks for considering this

                        Petr
- biarch enabled binutils for kfreebsd-amd64 and kfreebsd-i386
- properly supported elfosabi for kfreebsd-amd64
- kfreebsd-amd64 enabled in multiarch 
- kfreebsd-amd64 and kfreebsd-i386 supported in cross-build

diff -u binutils-2.17/debian/patches/00list binutils-2.17/debian/patches/00list
--- binutils-2.17/debian/patches/00list
+++ binutils-2.17/debian/patches/00list
@@ -8,0 +9 @@
+128_kfreebsd-amd64
diff -u binutils-2.17/debian/rules binutils-2.17/debian/rules
--- binutils-2.17/debian/rules
+++ binutils-2.17/debian/rules
@@ -69,6 +69,9 @@
 ifeq ($(DEB_HOST_ARCH),i386)
        CONFARGS += --enable-targets=x86_64-linux-gnu
 endif
+ifeq ($(DEB_HOST_ARCH),kfreebsd-i386)
+       CONFARGS += --enable-targets=x86_64-kfreebsd-gnu
+endif
 ifeq ($(DEB_HOST_ARCH),mips)
        CONFARGS += --enable-targets=mips64-linux-gnu
 endif
@@ -138,7 +141,7 @@
        mkdir builddir-multi
        cd builddir-multi \
            && env CC="$(CC)" ../configure $(CONFARGS) \
-               
--enable-targets=alpha-linux-gnu,arm-linux-gnu,hppa-linux-gnu,i486-kfreebsd-gnu,i486-linux-gnu,ia64-linux-gnu,m68k-linux-gnu,m68k-rtems,mips-linux-gnu,mipsel-linux-gnu,mips64-linux-gnu,mips64el-linux-gnu,powerpc-linux-gnu,powerpc64-linux-gnu,s390-linux-gnu,s390x-linux-gnu,sh-linux-gnu,sparc-linux-gnu,sparc64-linux-gnu,x86_64-linux,m32r-linux-gnu
+               
--enable-targets=alpha-linux-gnu,arm-linux-gnu,hppa-linux-gnu,i486-kfreebsd-gnu,i486-linux-gnu,ia64-linux-gnu,m68k-linux-gnu,m68k-rtems,mips-linux-gnu,mipsel-linux-gnu,mips64-linux-gnu,mips64el-linux-gnu,powerpc-linux-gnu,powerpc64-linux-gnu,s390-linux-gnu,s390x-linux-gnu,sh-linux-gnu,sparc-linux-gnu,sparc64-linux-gnu,x86_64-linux,x86_64-kfreebsd-gnu,m32r-linux-gnu
        $(MAKE) -C builddir-multi configure-host
        touch configure-multi-stamp
 
@@ -474,12 +477,18 @@
 ifneq ($(filter sparc-linux-gnu powerpc-linux-gnu mips-linux-gnu, $(TARGET)),)
 ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux-gnu=%64-linux-gnu)
 endif
-ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu x86-linux-gnu, 
$(TARGET)),)
+ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu i686-linux-gnu 
x86-linux-gnu, $(TARGET)),)
 ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu
 endif
+ifneq ($(filter i386-kfreebsd-gnu i486-kfreebsd-gnu i586-kfreebsd-gnu 
i686-kfreebsd-gnu x86-kfreebsd-gnu, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=x86_64-kfreebsd-gnu
+endif
 ifeq ($(TARGET), x86_64-linux-gnu)
 ADDITIONAL_TARGETS = --enable-targets=i486-linux-gnu
 endif
+ifeq ($(TARGET), x86_64-kfreebsd-gnu)
+ADDITIONAL_TARGETS = --enable-targets=i486-kfreebsd-gnu
+endif
 ifeq ($(TARGET), mipsel-linux-gnu)
 ADDITIONAL_TARGETS = --enable-targets=mips64el-linux-gnu
 endif
only in patch2:
unchanged:
--- binutils-2.17.orig/debian/patches/128_kfreebsd-amd64.dpatch
+++ binutils-2.17/debian/patches/128_kfreebsd-amd64.dpatch
@@ -0,0 +1,173 @@
+#!/bin/sh -e
+## 128_kfreebsd-amd64.dpatch
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Description: properly support kfreebsd-amd64
+## DP: Author: 
+## DP: Upstream status: 
+## DP: Date: 
+
+if [ $# -ne 1 ]; then
+    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
+
+case "$1" in
+       -patch) patch $patch_opts -p1 < $0;;
+       -unpatch) patch $patch_opts -p1 -R < $0;;
+        *)
+                echo >&2 "`basename $0`: script expects -patch|-unpatch as 
argument"
+                exit 1;;
+esac
+
+exit 0
+
[EMAIL PROTECTED]@
+diff -urN binutils-2.17/bfd/elf64-x86-64.c binutils-2.17/bfd/elf64-x86-64.c
+--- binutils-2.17/bfd/elf64-x86-64.c   2006-03-23 09:23:09.000000000 +0100
++++ binutils-2.17/bfd/elf64-x86-64.c   2006-07-29 12:29:37.000000000 +0200
+@@ -3687,3 +3687,36 @@
+   elf64_x86_64_additional_program_headers
+ 
+ #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 -urN binutils-2.17/bfd/targets.c binutils-2.17/bfd/targets.c
+--- binutils-2.17/bfd/targets.c        2006-04-05 14:41:57.000000000 +0200
++++ binutils-2.17/bfd/targets.c        2006-07-29 13:51:56.000000000 +0200
+@@ -668,6 +668,7 @@
+ 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 @@
+       &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 -urN binutils-2.17/gas/config/tc-i386.c binutils-2.17/gas/config/tc-i386.c
+--- binutils-2.17/gas/config/tc-i386.c 2006-04-07 08:40:57.000000000 +0200
++++ binutils-2.17/gas/config/tc-i386.c 2006-07-29 12:18:19.000000000 +0200
+@@ -5469,7 +5469,7 @@
+ 
+       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;
+@@ -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 ? ELF_TARGET_FORMAT64 : 
ELF_TARGET_FORMAT;
+       }
+ #endif
+     default:
+diff -urN binutils-2.17/gas/config/tc-i386.h binutils-2.17/gas/config/tc-i386.h
+--- binutils-2.17/gas/config/tc-i386.h 2006-02-27 16:35:37.000000000 +0100
++++ binutils-2.17/gas/config/tc-i386.h 2006-07-29 13:53:14.000000000 +0200
+@@ -55,6 +55,7 @@
+ 
+ #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 @@
+ #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 -urN binutils-2.17/ld/emulparams/elf_x86_64_fbsd.sh 
binutils-2.17/ld/emulparams/elf_x86_64_fbsd.sh
+--- binutils-2.17/ld/emulparams/elf_x86_64_fbsd.sh     2002-02-18 
10:38:01.000000000 +0100
++++ binutils-2.17/ld/emulparams/elf_x86_64_fbsd.sh     2006-07-29 
12:03:54.000000000 +0200
+@@ -1,2 +1,3 @@
+ . ${srcdir}/emulparams/elf_x86_64.sh
+ . ${srcdir}/emulparams/elf_fbsd.sh
++OUTPUT_FORMAT="elf64-x86-64-freebsd"
+diff -urN binutils-2.17/bfd/config.bfd binutils-2.17/bfd/config.bfd
+--- binutils-2.17/bfd/config.bfd       2006-04-05 14:41:57.000000000 +0200
++++ binutils-2.17/bfd/config.bfd       2006-07-29 14:14:03.000000000 +0200
+@@ -551,8 +551,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 bfd_elf32_i386_vec bfd_elf64_x86_64_vec"
+     ;;
+   x86_64-*-netbsd* | x86_64-*-openbsd*)
+     targ_defvec=bfd_elf64_x86_64_vec
+diff -urN binutils-2.17/bfd/configure.in binutils-2.17/bfd/configure.in
+--- binutils-2.17/bfd/configure.in     2006-06-23 20:17:07.000000000 +0200
++++ binutils-2.17/bfd/configure.in     2006-07-29 14:08:19.000000000 +0200
+@@ -707,6 +707,7 @@
+     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 -urN binutils-2.17/bfd/configure binutils-2.17/bfd/configure
+--- binutils-2.17/bfd/configure        2006-06-23 20:17:03.000000000 +0200
++++ binutils-2.17/bfd/configure        2006-07-29 14:08:54.000000000 +0200
+@@ -13194,6 +13194,7 @@
+     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" ;;

Reply via email to