bug-hurd
[Top][All Lists]
Advanced

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

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


From: Samuel Thibault
Subject: [PATCH,HURD] Recognize GNU/Hurd-specific binaries
Date: Sun, 3 Jul 2011 16:19:39 +0200
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)

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.

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

Samuel


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>

        * elf/elf.h (ELFOSABI_GNU): Define macro.
        (ELFOSABI_LINUX): Comment that it is just an alias for ELFOSABI_GNU.
        * 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.
        * sysdeps/unix/sysv/linux/ldsodefs.h (VALID_ELF_OSABI,
        VALID_ELF_ABIVERSION, MORE_ELF_HEADER_DATA): Use ELFOSABI_GNU instead of
        ELFOSABI_LINUX.
        * sysdeps/mach/hurd/powerpc/init-first.c (_dl_non_dynamic_init): Remove
        declaration.
        * sysdeps/mach/hurd/i386/init-first.c (_dl_non_dynamic_init): Likewise.

diff --git a/elf/elf.h b/elf/elf.h
index acb7762..cad15cd 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -142,7 +142,8 @@ typedef struct
 #define ELFOSABI_SYSV          0       /* Alias.  */
 #define ELFOSABI_HPUX          1       /* HP-UX */
 #define ELFOSABI_NETBSD                2       /* NetBSD.  */
-#define ELFOSABI_LINUX         3       /* Linux.  */
+#define ELFOSABI_GNU           3       /* GNU.  */
+#define ELFOSABI_LINUX         3       /* Alias for ELFOSABI_GNU.  */
 #define ELFOSABI_SOLARIS       6       /* Sun Solaris.  */
 #define ELFOSABI_AIX           7       /* IBM AIX.  */
 #define ELFOSABI_IRIX          8       /* SGI Irix.  */
diff --git a/sysdeps/mach/hurd/ldsodefs.h b/sysdeps/mach/hurd/ldsodefs.h
index e69de29..56e4b03 100644
--- a/sysdeps/mach/hurd/ldsodefs.h
+++ b/sysdeps/mach/hurd/ldsodefs.h
@@ -0,0 +1,52 @@
+/* Run-time dynamic linker data structures for loaded ELF shared objects.
+   Copyright (C) 2001, 2002, 2003, 2006, 2009, 2010, 2011 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, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef        _LDSODEFS_H
+
+#include <libc-abis.h>
+
+/* Get the real definitions.  */
+#include_next <ldsodefs.h>
+
+/* Now define our stuff.  */
+
+/* Initialization which is normally done by the dynamic linker.  */
+extern void _dl_non_dynamic_init (void) internal_function;
+
+/* Accept binaries which identify the binary as using Linux 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 */
diff --git a/sysdeps/unix/sysv/linux/ldsodefs.h 
b/sysdeps/unix/sysv/linux/ldsodefs.h
index 5d5b1b4..cf20217 100644
--- a/sysdeps/unix/sysv/linux/ldsodefs.h
+++ b/sysdeps/unix/sysv/linux/ldsodefs.h
@@ -58,9 +58,9 @@ extern void _dl_non_dynamic_init (void) internal_function;
 #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] =       \
   {                                                    \
@@ -71,7 +71,7 @@ extern void _dl_non_dynamic_init (void) internal_function;
     [EI_CLASS] = ELFW(CLASS),                          \
     [EI_DATA] = byteorder,                             \
     [EI_VERSION] = EV_CURRENT,                         \
-    [EI_OSABI] = ELFOSABI_LINUX                                \
+    [EI_OSABI] = ELFOSABI_GNU                          \
   }
 
 #endif /* ldsodefs.h */
diff --git a/sysdeps/mach/hurd/powerpc/init-first.c 
b/sysdeps/mach/hurd/powerpc/init-first.c
index 21b5054..2047cac 100644
--- a/sysdeps/mach/hurd/powerpc/init-first.c
+++ b/sysdeps/mach/hurd/powerpc/init-first.c
@@ -32,9 +32,6 @@ extern void __init_misc (int, char **, char **);
 #ifdef USE_NONOPTION_FLAGS
 extern void __getopt_clean_environment (char **);
 #endif
-#ifndef SHARED
-extern void _dl_non_dynamic_init (void) internal_function;
-#endif
 extern void __libc_global_ctors (void);
 
 unsigned int __hurd_threadvar_max;
diff --git a/sysdeps/mach/hurd/i386/init-first.c 
b/sysdeps/mach/hurd/i386/init-first.c
index e79af1d..7c86609 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -37,9 +37,6 @@ extern void __init_misc (int, char **, char **);
 #ifdef USE_NONOPTION_FLAGS
 extern void __getopt_clean_environment (char **);
 #endif
-#ifndef SHARED
-extern void _dl_non_dynamic_init (void) internal_function;
-#endif
 extern void __libc_global_ctors (void);
 
 unsigned int __hurd_threadvar_max;



reply via email to

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