Should rename ELFOSABI_LINUX into ELFOSABI_GNU, and drop ELFOSABI_HURD

Samuel Thibault samuel.thibault@ens-lyon.org
Sun Jun 19 20:32:00 GMT 2011


Forwarded from http://sourceware.org/bugzilla/show_bug.cgi?id=12913

Hello,

H.J. Lu added separate ELFOSABI_LINUX and _HURD definitions, but these
are actually meant to be the same: the dynamic linker is the same in
both cases, from glibc, with the same "GNU" extensions.

A recent change (http://sourceware.org/bugzilla/show_bug.cgi?id=10549)
made this issue apparent eventually.  Roland says we should simply
rename the existing ELFOSABI_LINUX into ELFOSABI_GNU, and remove
ELFOSABI_HURD.  The attached patch does this (but keeps ELFOSABI_LINUX
as an alias for software which may already be using it).

Samuel
-------------- next part --------------
2011-06-19  Samuel Thibault  <samuel.thibault@gnu.org>

	* elf.c (_bfd_elf_set_osabi): Use ELFOSABI_GNU name instead
	of ELFOSABI_LINUX alias.
	* elf32-hppa.c (elf32_hppa_object_p): Likewise.
	* elf64-hppa.c (elf32_hppa_object_p): Likewise.

Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.541
diff -u -p -r1.541 elf.c
--- bfd/elf.c	16 Jun 2011 12:34:19 -0000	1.541
+++ bfd/elf.c	19 Jun 2011 19:31:13 -0000
@@ -9608,11 +9608,11 @@ _bfd_elf_set_osabi (bfd * abfd,
   i_ehdrp->e_ident[EI_OSABI] = get_elf_backend_data (abfd)->elf_osabi;
 
   /* To make things simpler for the loader on Linux systems we set the
-     osabi field to ELFOSABI_LINUX if the binary contains symbols of
+     osabi field to ELFOSABI_GNU if the binary contains symbols of
      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_GNU;
 }
 
 
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.178
diff -u -p -r1.178 elf32-hppa.c
--- bfd/elf32-hppa.c	13 Jun 2011 00:59:10 -0000	1.178
+++ bfd/elf32-hppa.c	19 Jun 2011 19:31:13 -0000
@@ -950,9 +950,9 @@ elf32_hppa_object_p (bfd *abfd)
   i_ehdrp = elf_elfheader (abfd);
   if (strcmp (bfd_get_target (abfd), "elf32-hppa-linux") == 0)
     {
-      /* GCC on hppa-linux produces binaries with OSABI=Linux,
+      /* GCC on hppa-linux produces binaries with OSABI=GNU,
 	 but the kernel produces corefiles with OSABI=SysV.  */
-      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX &&
+      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_GNU &&
 	  i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */
 	return FALSE;
     }
Index: bfd/elf64-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-hppa.c,v
retrieving revision 1.103
diff -u -p -r1.103 elf64-hppa.c
--- bfd/elf64-hppa.c	13 Jun 2011 00:59:12 -0000	1.103
+++ bfd/elf64-hppa.c	19 Jun 2011 19:31:14 -0000
@@ -329,9 +329,9 @@ elf64_hppa_object_p (bfd *abfd)
   i_ehdrp = elf_elfheader (abfd);
   if (strcmp (bfd_get_target (abfd), "elf64-hppa-linux") == 0)
     {
-      /* GCC on hppa-linux produces binaries with OSABI=Linux,
+      /* GCC on hppa-linux produces binaries with OSABI=GNU,
 	 but the kernel produces corefiles with OSABI=SysV.  */
-      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_LINUX
+      if (i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_GNU
 	  && i_ehdrp->e_ident[EI_OSABI] != ELFOSABI_NONE) /* aka SYSV */
 	return FALSE;
     }

2011-06-19  Samuel Thibault  <samuel.thibault@gnu.org>

	* elfedit.c (osabis): Use ELFOSABI_GNU name instead
	of ELFOSABI_LINUX alias and ELFOSABI_HURD. Add GNU alias.
	* readelf.c (get_osabi_name): Likewise.
	(get_symbol_binding): Likewise.
	(get_symbol_type): Likewise.

Index: binutils/elfedit.c
===================================================================
RCS file: /cvs/src/src/binutils/elfedit.c,v
retrieving revision 1.7
diff -u -p -r1.7 elfedit.c
--- binutils/elfedit.c	21 Nov 2010 21:27:15 -0000	1.7
+++ binutils/elfedit.c	19 Jun 2011 20:24:23 -0000
@@ -518,8 +518,9 @@ osabis[] =
   { ELFOSABI_NONE, "none" },
   { ELFOSABI_HPUX, "HPUX" },
   { ELFOSABI_NETBSD, "NetBSD" },
-  { ELFOSABI_LINUX, "Linux" },
-  { ELFOSABI_HURD, "Hurd" },
+  { ELFOSABI_GNU, "Linux" },
+  { ELFOSABI_GNU, "GNU" },
+  { ELFOSABI_GNU, "Hurd" },
   { ELFOSABI_SOLARIS, "Solaris" },
   { ELFOSABI_AIX, "AIX" },
   { ELFOSABI_IRIX, "Irix" },
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.548
diff -u -p -r1.548 readelf.c
--- binutils/readelf.c	15 Jun 2011 16:36:57 -0000	1.548
+++ binutils/readelf.c	19 Jun 2011 19:31:14 -0000
@@ -2612,8 +2612,7 @@ get_osabi_name (unsigned int osabi)
     case ELFOSABI_NONE:		return "UNIX - System V";
     case ELFOSABI_HPUX:		return "UNIX - HP-UX";
     case ELFOSABI_NETBSD:	return "UNIX - NetBSD";
-    case ELFOSABI_LINUX:	return "UNIX - Linux";
-    case ELFOSABI_HURD:		return "GNU/Hurd";
+    case ELFOSABI_GNU:		return "UNIX - GNU";
     case ELFOSABI_SOLARIS:	return "UNIX - Solaris";
     case ELFOSABI_AIX:		return "UNIX - AIX";
     case ELFOSABI_IRIX:		return "UNIX - IRIX";
@@ -8585,8 +8584,8 @@ get_symbol_binding (unsigned int binding
       else if (binding >= STB_LOOS && binding <= STB_HIOS)
 	{
 	  if (binding == STB_GNU_UNIQUE
-	      && (elf_header.e_ident[EI_OSABI] == ELFOSABI_LINUX
-		  /* GNU/Linux is still using the default value 0.  */
+	      && (elf_header.e_ident[EI_OSABI] == ELFOSABI_GNU
+		  /* GNU is still using the default value 0.  */
 		  || elf_header.e_ident[EI_OSABI] == ELFOSABI_NONE))
 	    return "UNIQUE";
 	  snprintf (buff, sizeof (buff), _("<OS specific>: %d"), binding);
@@ -8638,8 +8637,8 @@ get_symbol_type (unsigned int type)
 	    }
 
 	  if (type == STT_GNU_IFUNC
-	      && (elf_header.e_ident[EI_OSABI] == ELFOSABI_LINUX
-		  /* GNU/Linux is still using the default value 0.  */
+	      && (elf_header.e_ident[EI_OSABI] == ELFOSABI_GNU
+		  /* GNU is still using the default value 0.  */
 		  || elf_header.e_ident[EI_OSABI] == ELFOSABI_NONE))
 	    return "IFUNC";
 

2011-06-19  Samuel Thibault  <samuel.thibault@gnu.org>

	* elfcpp.h (ELFOSABI): Add ELFOSABI_GNU with value of ELFOSABI_LINUX,
	keep ELFOSABI_LINUX as an alias. Remove ELFOSABI_HURD.

Index: elfcpp/elfcpp.h
===================================================================
RCS file: /cvs/src/src/elfcpp/elfcpp.h,v
retrieving revision 1.32
diff -u -p -r1.32 elfcpp.h
--- elfcpp/elfcpp.h	12 Aug 2010 22:18:14 -0000	1.32
+++ elfcpp/elfcpp.h	19 Jun 2011 19:31:14 -0000
@@ -129,10 +129,10 @@ enum ELFOSABI
   ELFOSABI_NONE = 0,
   ELFOSABI_HPUX = 1,
   ELFOSABI_NETBSD = 2,
-  // ELFOSABI_LINUX is not listed in the ELF standard.
+  // ELFOSABI_GNU is not listed in the ELF standard.
+  ELFOSABI_GNU = 3,
+  // ELFOSABI_LINUX is not listed in the ELF standard, and is an alias for ELFOSABI_GNU
   ELFOSABI_LINUX = 3,
-  // ELFOSABI_HURD is not listed in the ELF standard.
-  ELFOSABI_HURD = 4,
   ELFOSABI_SOLARIS = 6,
   ELFOSABI_AIX = 7,
   ELFOSABI_IRIX = 8,

2011-06-19  Samuel Thibault  <samuel.thibault@gnu.org>

	* config/obj-elf.c (obj_elf_type): Use ELFOSABI_GNU name instead
	of ELFOSABI_LINUX alias.

Index: gas/config/obj-elf.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-elf.c,v
retrieving revision 1.141
diff -u -p -r1.141 obj-elf.c
--- gas/config/obj-elf.c	30 Mar 2011 15:06:51 -0000	1.141
+++ gas/config/obj-elf.c	19 Jun 2011 19:41:02 -0000
@@ -1704,8 +1704,8 @@ obj_elf_type (int ignore ATTRIBUTE_UNUSE
       const struct elf_backend_data *bed;
 
       bed = get_elf_backend_data (stdoutput);
-      if (!(bed->elf_osabi == ELFOSABI_LINUX
-	    /* GNU/Linux is still using the default value 0.  */
+      if (!(bed->elf_osabi == ELFOSABI_GNU
+	    /* GNU 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);
@@ -1716,14 +1716,14 @@ obj_elf_type (int ignore ATTRIBUTE_UNUSE
       struct elf_backend_data *bed;
 
       bed = (struct elf_backend_data *) get_elf_backend_data (stdoutput);
-      if (!(bed->elf_osabi == ELFOSABI_LINUX
-	    /* GNU/Linux is still using the default value 0.  */
+      if (!(bed->elf_osabi == ELFOSABI_GNU
+	    /* GNU 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;
+      /* PR 10549: Always set OSABI field to GNU for objects containing unique symbols.  */
+      bed->elf_osabi = ELFOSABI_GNU;
     }
 #ifdef md_elf_symbol_type
   else if ((type = md_elf_symbol_type (type_name, sym, elfsym)) != -1)

2011-06-19  Samuel Thibault  <samuel.thibault@gnu.org>

	* common.h (ELFOSABI_GNU): Define, replaces...
	(ELFOSABI_LINUX): ... this, kept as an alias.
	(ELFOSABI_HURD): Remove.

Index: include/elf/common.h
===================================================================
RCS file: /cvs/src/src/include/elf/common.h,v
retrieving revision 1.130
diff -u -p -r1.130 common.h
--- include/elf/common.h	15 Jun 2011 16:36:58 -0000	1.130
+++ include/elf/common.h	19 Jun 2011 19:31:15 -0000
@@ -62,8 +62,8 @@
 #define ELFOSABI_NONE	      0	/* UNIX System V ABI */
 #define ELFOSABI_HPUX	      1	/* HP-UX operating system */
 #define ELFOSABI_NETBSD	      2	/* NetBSD */
-#define ELFOSABI_LINUX	      3	/* GNU/Linux */
-#define ELFOSABI_HURD	      4	/* GNU/Hurd */
+#define ELFOSABI_GNU	      3	/* GNU */
+#define ELFOSABI_LINUX	      3	/* Alias for ELFOSABI_GNU */
 #define ELFOSABI_SOLARIS      6	/* Solaris */
 #define ELFOSABI_AIX	      7	/* AIX */
 #define ELFOSABI_IRIX	      8	/* IRIX */


More information about the Binutils mailing list