bug-hurd
[Top][All Lists]
Advanced

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

Re: [PATCH,HURD] Recognize GNU/Hurd-specific binaries


From: Thomas Schwinge
Subject: Re: [PATCH,HURD] Recognize GNU/Hurd-specific binaries
Date: Sun, 26 May 2013 23:53:41 +0200
User-agent: Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu)

Hi!

On Sun, 3 Jul 2011 16:19:39 +0200, Samuel Thibault <samuel.thibault@gnu.org> 
wrote:
> Roland McGrath, le Sun 19 Jun 2011 11:46:20 -0700, a écrit :
> > > Ok, so I guess we should request binutils to rename the LINUX one into
> > > ELFOSABI_GNU and drop the HURD one?
> > 
> > That seems appropriate to me.

..., and happened back then for the ELF ABI document, sourceware src tree
(binutils, GDB), and in glibc's elf.h (commit
0a2349f929e937fb335ba53e217c05f5aa5d66d5), but one thing is still missing
today: support in GNU/Hurd configurations.

OK to commit the following two patches?


First, my "usual" cleanup patch:

        * sysdeps/unix/sysv/linux/ldsodefs.h (VALID_ELF_OSABI)
        (VALID_ELF_ABIVERSION, MORE_ELF_HEADER_DATA): Use ELFOSABI_GNU
        instead of ELFOSABI_LINUX.

ports/ChangeLog.arm
        * sysdeps/unix/sysv/linux/arm/ldsodefs.h (VALID_ELF_OSABI)
        (MORE_ELF_HEADER_DATA): Use ELFOSABI_GNU instead of ELFOSABI_LINUX.

ports/ChangeLog.mips
        * sysdeps/unix/sysv/linux/mips/ldsodefs.h (VALID_ELF_ABIVERSION):
        Use ELFOSABI_GNU instead of ELFOSABI_LINUX.
---
 ports/sysdeps/unix/sysv/linux/arm/ldsodefs.h  |    6 +++---
 ports/sysdeps/unix/sysv/linux/mips/ldsodefs.h |    4 ++--
 sysdeps/unix/sysv/linux/ldsodefs.h            |    8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git ports/sysdeps/unix/sysv/linux/arm/ldsodefs.h 
ports/sysdeps/unix/sysv/linux/arm/ldsodefs.h
index 50a8bb7..3821bf3 100644
--- ports/sysdeps/unix/sysv/linux/arm/ldsodefs.h
+++ ports/sysdeps/unix/sysv/linux/arm/ldsodefs.h
@@ -44,8 +44,8 @@
     || memcmp (hdr, expected3, size) == 0)     \
    && VALID_FLOAT_ABI (ehdr->e_flags))
 #define VALID_ELF_OSABI(osabi)         (osabi == ELFOSABI_SYSV         \
-                                        || osabi == EXTRA_OSABI        \
-                                        || osabi == ELFOSABI_LINUX)
+                                        || osabi == ELFOSABI_GNU       \
+                                        || osabi == EXTRA_OSABI)
 #define MORE_ELF_HEADER_DATA                           \
   static const unsigned char expected2[EI_PAD] =       \
   {                                                    \
@@ -56,7 +56,7 @@
     [EI_CLASS] = ELFW(CLASS),                          \
     [EI_DATA] = byteorder,                             \
     [EI_VERSION] = EV_CURRENT,                         \
-    [EI_OSABI] = ELFOSABI_LINUX                                \
+    [EI_OSABI] = ELFOSABI_GNU                          \
   };                                                   \
   static const unsigned char expected3[EI_PAD] =       \
   {                                                    \
diff --git ports/sysdeps/unix/sysv/linux/mips/ldsodefs.h 
ports/sysdeps/unix/sysv/linux/mips/ldsodefs.h
index eb45f72..76c38c8 100644
--- ports/sysdeps/unix/sysv/linux/mips/ldsodefs.h
+++ ports/sysdeps/unix/sysv/linux/mips/ldsodefs.h
@@ -30,11 +30,11 @@ extern void _dl_static_init (struct link_map *map);
 #define DL_STATIC_INIT(map) _dl_static_init (map)
 
 /* Allow ABIVERSION == 1, meaning PLTs and copy relocations are
-   required, with ELFOSABI_SYSV.  */
+   required, with ELFOSABI_SYSV, and ELFOSABI_GNU.  */
 #undef VALID_ELF_ABIVERSION
 #define VALID_ELF_ABIVERSION(osabi,ver)                        \
   (ver == 0                                            \
    || (osabi == ELFOSABI_SYSV && ver < 2)              \
-   || (osabi == ELFOSABI_LINUX && ver < LIBC_ABI_MAX))
+   || (osabi == ELFOSABI_GNU && ver < LIBC_ABI_MAX))
 
 #endif /* ldsodefs.h */
diff --git sysdeps/unix/sysv/linux/ldsodefs.h sysdeps/unix/sysv/linux/ldsodefs.h
index 18ff852..c1b1543 100644
--- sysdeps/unix/sysv/linux/ldsodefs.h
+++ sysdeps/unix/sysv/linux/ldsodefs.h
@@ -41,13 +41,13 @@
    up the page size information.  */
 #define HAVE_AUX_PAGESIZE
 
-/* Accept binaries which identify the binary as using Linux extensions.  */
+/* Accept binaries which identify the binary as using GNU extensions.  */
 #define VALID_ELF_HEADER(hdr,exp,size) (memcmp (hdr, exp, size) == 0   \
                                         || memcmp (hdr, expected2, size) == 0)
 #define VALID_ELF_OSABI(osabi)         (osabi == ELFOSABI_SYSV \
-                                        || osabi == ELFOSABI_LINUX)
+                                        || osabi == ELFOSABI_GNU)
 #define VALID_ELF_ABIVERSION(osabi,ver) \
-  (ver == 0 || (osabi == ELFOSABI_LINUX && ver < LIBC_ABI_MAX))
+  (ver == 0 || (osabi == ELFOSABI_GNU && ver < LIBC_ABI_MAX))
 #define MORE_ELF_HEADER_DATA \
   static const unsigned char expected2[EI_PAD] =       \
   {                                                    \
@@ -58,7 +58,7 @@
     [EI_CLASS] = ELFW(CLASS),                          \
     [EI_DATA] = byteorder,                             \
     [EI_VERSION] = EV_CURRENT,                         \
-    [EI_OSABI] = ELFOSABI_LINUX                                \
+    [EI_OSABI] = ELFOSABI_GNU                          \
   }
 
 #endif /* ldsodefs.h */


> Ok, here is an updated patch for the libc part.

> binutils started emitting ELF files with ELFOSABI_GNU due to GNU-specific
> ELF extensions. We need to accept loading such binaries on hurd-i386 too.
> 
> 2011-06-19  Samuel Thibault  <samuel.thibault@ens-lyon.org>

>         * sysdeps/mach/hurd/ldsodefs.h: New file, defines VALID_ELF_HEADER,
>         VALID_ELF_OSABI, VALID_ELF_ABIVERSION, MORE_ELF_HEADER_DATA, declares
>         _dl_non_dynamic_init.

I suggest we instead implement this in sysdeps/gnu/ldsodefs.h, as this is
a common GNU thing.

Tested on x86 and x86_64 GNU/Linux, and x86 GNU/Hurd; glibc testsuite as
well as manually as follows:

    $ cp /bin/true true-ELFOSABI_GNU
    $ readelf -h true-ELFOSABI_GNU | grep OS/ABI
      OS/ABI:                            UNIX - System V
    $ elfedit --output-osabi GNU true-ELFOSABI_GNU
    $ readelf -h true-ELFOSABI_GNU | grep OS/ABI
      OS/ABI:                            UNIX - GNU
    $ ./testrun.sh ./true-ELFOSABI_GNU --version
    true (GNU coreutils) 8.13
    [...]

        * sysdeps/unix/sysv/linux/ldsodefs.h (VALID_ELF_HEADER)
        (VALID_ELF_OSABI, VALID_ELF_ABIVERSION, MORE_ELF_HEADER_DATA):
        Move macros to...
        * sysdeps/gnu/ldsodefs.h: ... this new file.
---
 sysdeps/gnu/ldsodefs.h             |   48 ++++++++++++++++++++++++++++++++++++
 sysdeps/unix/sysv/linux/ldsodefs.h |   23 -----------------
 2 files changed, 48 insertions(+), 23 deletions(-)
 create mode 100644 sysdeps/gnu/ldsodefs.h

diff --git sysdeps/gnu/ldsodefs.h sysdeps/gnu/ldsodefs.h
new file mode 100644
index 0000000..5a5fff2
--- /dev/null
+++ sysdeps/gnu/ldsodefs.h
@@ -0,0 +1,48 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
+   Copyright (C) 2001-2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _GNU_LDSODEFS_H
+#define _GNU_LDSODEFS_H 1
+
+#include <elf.h>
+#include <libc-abis.h>
+#include <string.h>
+
+/* Accept binaries which identify the binary as using GNU extensions.  */
+#define VALID_ELF_HEADER(hdr,exp,size) (memcmp (hdr, exp, size) == 0   \
+                                        || memcmp (hdr, expected2, size) == 0)
+#define VALID_ELF_OSABI(osabi)         (osabi == ELFOSABI_SYSV \
+                                        || osabi == ELFOSABI_GNU)
+#define VALID_ELF_ABIVERSION(osabi,ver) \
+  (ver == 0 || (osabi == ELFOSABI_GNU && ver < LIBC_ABI_MAX))
+#define MORE_ELF_HEADER_DATA \
+  static const unsigned char expected2[EI_PAD] =       \
+  {                                                    \
+    [EI_MAG0] = ELFMAG0,                               \
+    [EI_MAG1] = ELFMAG1,                               \
+    [EI_MAG2] = ELFMAG2,                               \
+    [EI_MAG3] = ELFMAG3,                               \
+    [EI_CLASS] = ELFW(CLASS),                          \
+    [EI_DATA] = byteorder,                             \
+    [EI_VERSION] = EV_CURRENT,                         \
+    [EI_OSABI] = ELFOSABI_GNU                          \
+  }
+
+#include_next <ldsodefs.h>
+
+#endif /* _GNU_LDSODEFS_H */
diff --git sysdeps/unix/sysv/linux/ldsodefs.h sysdeps/unix/sysv/linux/ldsodefs.h
index c1b1543..ef48667 100644
--- sysdeps/unix/sysv/linux/ldsodefs.h
+++ sysdeps/unix/sysv/linux/ldsodefs.h
@@ -18,14 +18,11 @@
 
 #ifndef        _LDSODEFS_H
 
-#include <libc-abis.h>
 #include <kernel-features.h>
 
 /* Get the real definitions.  */
 #include_next <ldsodefs.h>
 
-/* Now define our stuff.  */
-
 /* We have the auxiliary vector.  */
 #define HAVE_AUX_VECTOR
 
@@ -41,24 +38,4 @@
    up the page size information.  */
 #define HAVE_AUX_PAGESIZE
 
-/* Accept binaries which identify the binary as using GNU extensions.  */
-#define VALID_ELF_HEADER(hdr,exp,size) (memcmp (hdr, exp, size) == 0   \
-                                        || memcmp (hdr, expected2, size) == 0)
-#define VALID_ELF_OSABI(osabi)         (osabi == ELFOSABI_SYSV \
-                                        || osabi == ELFOSABI_GNU)
-#define VALID_ELF_ABIVERSION(osabi,ver) \
-  (ver == 0 || (osabi == ELFOSABI_GNU && ver < LIBC_ABI_MAX))
-#define MORE_ELF_HEADER_DATA \
-  static const unsigned char expected2[EI_PAD] =       \
-  {                                                    \
-    [EI_MAG0] = ELFMAG0,                               \
-    [EI_MAG1] = ELFMAG1,                               \
-    [EI_MAG2] = ELFMAG2,                               \
-    [EI_MAG3] = ELFMAG3,                               \
-    [EI_CLASS] = ELFW(CLASS),                          \
-    [EI_DATA] = byteorder,                             \
-    [EI_VERSION] = EV_CURRENT,                         \
-    [EI_OSABI] = ELFOSABI_GNU                          \
-  }
-
 #endif /* ldsodefs.h */


Grüße,
 Thomas

Attachment: pgpLHfIligy6C.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]