[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#630180: binutils: Emits GNU/Linux objects on hurd-i386



Package: binutils
Version: 2.21.51.20110421-3
Severity: important
Tags: upstream
User: debian-hurd@lists.debian.org
Usertags: hurd

Hello,

g++-4.5 and g++-4.6 have started emitting GNU/Linux objects on
hurd-i386, resulting with the following error: “ELF file OS ABI
invalid”

This is due to binutils now setting the osabi to Linux when there is a
STB_GNU_UNIQUE symbol, see upstream bug
http://sourceware.org/bugzilla/show_bug.cgi?id=10549
and the related changes similar to this:

diff -urN binutils-2.21.0.20110327/bfd/elfcode.h binutils-2.21.52.20110606/bfd/e
--- binutils-2.21.0.20110327/bfd/elfcode.h      2010-10-04 16:13:09.000000000 +0
+++ binutils-2.21.52.20110606/bfd/elfcode.h     2011-06-06 17:06:54.000000000 +0
@@ -9480,9 +9577,9 @@

   /* To make things simpler for the loader on Linux systems we set the
      osabi field to ELFOSABI_LINUX if the binary contains symbols of
-     the STT_GNU_IFUNC type.  */
+     the STT_GNU_IFUNC type or STB_GNU_UNIQUE binding.  */
   if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE
-      && elf_tdata (abfd)->has_ifunc_symbols)
+      && elf_tdata (abfd)->has_gnu_symbols)
     i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_LINUX;
 }

It is wrong to assume Linux here: GNU/Hurd also uses the GNU dynamic
linker and thus supports them too.

The attached patch fixes the issue for hurd-i386. It's not to be applied
as is, since it'd start emitting GNU/Hurd objects on Linux instead. I
don't know binutils' internals enough to know where to get the OS target
information.

Samuel

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: hurd-i386 (i686-AT386)

Kernel: GNU-Mach 1.3.99/Hurd-0.3
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages binutils depends on:
ii  libc0.3                 2.13-5           Embedded GNU C Library: Shared lib
ii  zlib1g                  1:1.2.3.4.dfsg-3 compression library - runtime

binutils recommends no packages.

Versions of packages binutils suggests:
pn  binutils-doc                  <none>     (no description available)

-- no debconf information
--- ./gas/config/obj-elf.c.original	2011-06-11 17:01:18.000000000 +0200
+++ ./gas/config/obj-elf.c	2011-06-11 17:02:09.000000000 +0200
@@ -1705,6 +1705,7 @@
 
       bed = get_elf_backend_data (stdoutput);
       if (!(bed->elf_osabi == ELFOSABI_LINUX
+	    || bed->elf_osabi == ELFOSABI_HURD
 	    /* GNU/Linux is still using the default value 0.  */
 	    || bed->elf_osabi == ELFOSABI_NONE))
 	as_bad (_("symbol type \"%s\" is supported only by GNU targets"),
@@ -1717,13 +1718,14 @@
 
       bed = (struct elf_backend_data *) get_elf_backend_data (stdoutput);
       if (!(bed->elf_osabi == ELFOSABI_LINUX
+	    || bed->elf_osabi == ELFOSABI_HURD
 	    /* GNU/Linux is still using the default value 0.  */
 	    || bed->elf_osabi == ELFOSABI_NONE))
 	as_bad (_("symbol type \"%s\" is supported only by GNU targets"),
 		type_name);
       type = BSF_OBJECT | BSF_GNU_UNIQUE;
       /* PR 10549: Always set OSABI field to LINUX for objects containing unique symbols.  */
-      bed->elf_osabi = ELFOSABI_LINUX;
+      bed->elf_osabi = ELFOSABI_HURD;
     }
 #ifdef md_elf_symbol_type
   else if ((type = md_elf_symbol_type (type_name, sym, elfsym)) != -1)
--- ./bfd/elf.c.original	2011-06-11 17:02:19.000000000 +0200
+++ ./bfd/elf.c	2011-06-11 17:02:22.000000000 +0200
@@ -9580,7 +9580,7 @@
      the STT_GNU_IFUNC type or STB_GNU_UNIQUE binding.  */
   if (i_ehdrp->e_ident[EI_OSABI] == ELFOSABI_NONE
       && elf_tdata (abfd)->has_gnu_symbols)
-    i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_LINUX;
+    i_ehdrp->e_ident[EI_OSABI] = ELFOSABI_HURD;
 }
 
 
--- ./binutils/readelf.c.original	2011-06-11 17:03:19.000000000 +0200
+++ ./binutils/readelf.c	2011-06-11 17:03:23.000000000 +0200
@@ -8549,6 +8549,7 @@
 	{
 	  if (binding == STB_GNU_UNIQUE
 	      && (elf_header.e_ident[EI_OSABI] == ELFOSABI_LINUX
+		  || elf_header.e_ident[EI_OSABI] == ELFOSABI_HURD
 		  /* GNU/Linux is still using the default value 0.  */
 		  || elf_header.e_ident[EI_OSABI] == ELFOSABI_NONE))
 	    return "UNIQUE";
@@ -8602,6 +8603,7 @@
 
 	  if (type == STT_GNU_IFUNC
 	      && (elf_header.e_ident[EI_OSABI] == ELFOSABI_LINUX
+		  || elf_header.e_ident[EI_OSABI] == ELFOSABI_HURD
 		  /* GNU/Linux is still using the default value 0.  */
 		  || elf_header.e_ident[EI_OSABI] == ELFOSABI_NONE))
 	    return "IFUNC";

Reply to: