public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Remove kernel version and distinguish library check
@ 2022-03-04 13:37 Adhemerval Zanella
  2022-03-04 13:37 ` [PATCH v2 1/3] Remove kernel version check Adhemerval Zanella
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-03-04 13:37 UTC (permalink / raw)
  To: libc-alpha, Florian Weimer

First patch removes the kernel version check on Linux, which
is a feature that from times to times cases some issues (such
as [1]).

Second patch removes the same check on ldconfig.

Third removes the distinguish library check used to handle ancient
libc5 and aout files.

[1] https://github.com/microsoft/WSL/issues/3023

Adhemerval Zanella (3):
  Remove kernel version check
  elf: Remove ldconfig kernel version check
  Remove dl-librecon.h header.

 NEWS                                         |  7 ++
 config.h.in                                  |  3 +
 csu/libc-start.c                             |  8 --
 csu/version.c                                |  3 +
 elf/cache.c                                  | 55 ++----------
 elf/dl-cache.c                               |  3 -
 elf/dl-diagnostics.c                         |  5 --
 elf/dl-load.c                                | 95 ++++----------------
 elf/dl-support.c                             | 12 ---
 elf/ldconfig.c                               | 22 ++---
 elf/readelflib.c                             | 51 +----------
 elf/readlib.c                                |  9 +-
 elf/rtld.c                                   | 40 +--------
 sysdeps/generic/dl-cache.h                   |  1 -
 sysdeps/generic/dl-librecon.h                | 24 -----
 sysdeps/generic/ldconfig.h                   | 14 +--
 sysdeps/generic/ldsodefs.h                   |  9 --
 sysdeps/unix/sysv/linux/arm/readelflib.c     | 18 ++--
 sysdeps/unix/sysv/linux/configure            |  5 ++
 sysdeps/unix/sysv/linux/configure.ac         |  2 +
 sysdeps/unix/sysv/linux/dl-librecon.h        | 59 ------------
 sysdeps/unix/sysv/linux/dl-osinfo.h          | 25 ------
 sysdeps/unix/sysv/linux/dl-sysdep.c          | 93 -------------------
 sysdeps/unix/sysv/linux/dl-sysdep.h          |  7 --
 sysdeps/unix/sysv/linux/i386/dl-librecon.h   | 61 -------------
 sysdeps/unix/sysv/linux/ia64/readelflib.c    | 18 ++--
 sysdeps/unix/sysv/linux/m68k/dl-librecon.h   |  1 -
 sysdeps/unix/sysv/linux/mips/readelflib.c    | 18 ++--
 sysdeps/unix/sysv/linux/powerpc/readelflib.c | 18 ++--
 sysdeps/unix/sysv/linux/riscv/readelflib.c   | 18 ++--
 sysdeps/unix/sysv/linux/s390/readelflib.c    | 18 ++--
 sysdeps/unix/sysv/linux/sparc/readelflib.c   | 18 ++--
 sysdeps/unix/sysv/linux/x86/readelflib.c     | 18 ++--
 33 files changed, 126 insertions(+), 632 deletions(-)
 delete mode 100644 sysdeps/generic/dl-librecon.h
 delete mode 100644 sysdeps/unix/sysv/linux/dl-librecon.h
 delete mode 100644 sysdeps/unix/sysv/linux/i386/dl-librecon.h
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/dl-librecon.h

-- 
2.32.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] Remove kernel version check
  2022-03-04 13:37 [PATCH v2 0/3] Remove kernel version and distinguish library check Adhemerval Zanella
@ 2022-03-04 13:37 ` Adhemerval Zanella
  2022-03-09 10:39   ` Florian Weimer
  2022-03-04 13:38 ` [PATCH v2 2/3] elf: Remove ldconfig " Adhemerval Zanella
  2022-03-04 13:38 ` [PATCH v2 3/3] Remove dl-librecon.h header Adhemerval Zanella
  2 siblings, 1 reply; 8+ messages in thread
From: Adhemerval Zanella @ 2022-03-04 13:37 UTC (permalink / raw)
  To: libc-alpha, Florian Weimer

The kernel version check is used to avoid glibc to run on older
kernels where some syscall are not available and fallback code are
not enabled to handle graciously fail.  However, it does not prevent
if the kernel does not correctly advertise its version through
vDSO note, uname or procfs.

Also kernel version checks are sometime not desirable by users,
where they want to deploy on different system with different kernel
version knowing the minimum set of syscall is always presented on
such systems.

The kernel version check has been removed along with the
LD_ASSUME_KERNEL environment variable.  The minimum kernel used to
built glibc is still provided through NT_GNU_ABI_TAG ELF note and
also printed when libc.so is issued.

Checked on x86_64-linux-gnu.
---
v2: Remove ABI note loop on elf/dl-load.c, remove missing _dl_osversion
    on elf/dl-support.c.
---
 NEWS                                       |  5 ++
 config.h.in                                |  3 +
 csu/libc-start.c                           |  8 --
 csu/version.c                              |  3 +
 elf/dl-cache.c                             |  3 -
 elf/dl-diagnostics.c                       |  5 --
 elf/dl-load.c                              | 95 ++++------------------
 elf/dl-support.c                           |  6 --
 elf/rtld.c                                 | 15 ----
 sysdeps/generic/ldsodefs.h                 |  6 --
 sysdeps/unix/sysv/linux/configure          |  5 ++
 sysdeps/unix/sysv/linux/configure.ac       |  2 +
 sysdeps/unix/sysv/linux/dl-librecon.h      | 59 --------------
 sysdeps/unix/sysv/linux/dl-osinfo.h        | 25 ------
 sysdeps/unix/sysv/linux/dl-sysdep.c        | 93 ---------------------
 sysdeps/unix/sysv/linux/dl-sysdep.h        |  7 --
 sysdeps/unix/sysv/linux/i386/dl-librecon.h |  2 -
 17 files changed, 33 insertions(+), 309 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/dl-librecon.h

diff --git a/NEWS b/NEWS
index 626eeabf5d..c348d948d2 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,11 @@ Deprecated and removed features, and other changes affecting compatibility:
   removal of the LD_TRACE_PRELINKING, and LD_USE_LOAD_BIAS, environment
   variables and their functionality in the dynamic loader.
 
+* The Linux kernel version check has been removed along with the
+  LD_ASSUME_KERNEL environment variable.  The minimum kernel used to built
+  glibc is still provided through NT_GNU_ABI_TAG ELF note and also printed
+  when libc.so is issued directly.
+
 Changes to build and runtime requirements:
 
   [Add changes to build and runtime requirements here]
diff --git a/config.h.in b/config.h.in
index ff8597413d..dd466e102a 100644
--- a/config.h.in
+++ b/config.h.in
@@ -138,6 +138,9 @@
 /* Linux specific: minimum supported kernel version.  */
 #undef	__LINUX_KERNEL_VERSION
 
+/* Linux specific: __LINUX_KERNEL_VERSION as a string.  */
+#undef  __LINUX_KERNEL_VERSION_STR
+
 /* Override abi-tags ABI version if necessary.  */
 #undef  __ABI_TAG_VERSION
 
diff --git a/csu/libc-start.c b/csu/libc-start.c
index e91f996426..6e22c1f19e 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -316,14 +316,6 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
   __stack_chk_guard = stack_chk_guard;
 # endif
 
-# ifdef DL_SYSDEP_OSCHECK
-  {
-    /* This needs to run to initiliaze _dl_osversion before TLS
-       setup might check it.  */
-    DL_SYSDEP_OSCHECK (__libc_fatal);
-  }
-# endif
-
   /* Initialize libpthread if linked in.  */
   if (__pthread_initialize_minimal != NULL)
     __pthread_initialize_minimal ();
diff --git a/csu/version.c b/csu/version.c
index 0de4df5b3f..8c0ed79c01 100644
--- a/csu/version.c
+++ b/csu/version.c
@@ -33,6 +33,9 @@ Compiled by GNU CC version "__VERSION__".\n"
 #ifdef LIBC_ABIS_STRING
 LIBC_ABIS_STRING
 #endif
+#ifdef __LINUX_KERNEL_VERSION_STR
+"Minimum supported kernel: " __LINUX_KERNEL_VERSION_STR "\n"
+#endif
 "For bug reporting instructions, please see:\n\
 "REPORT_BUGS_TO".\n";
 
diff --git a/elf/dl-cache.c b/elf/dl-cache.c
index 88bf78ad7c..8bbf110d02 100644
--- a/elf/dl-cache.c
+++ b/elf/dl-cache.c
@@ -297,9 +297,6 @@ search_cache (const char *string_table, uint32_t string_table_size,
 
 		      if ((libnew->hwcap & hwcap_exclude) && !named_hwcap)
 			continue;
-		      if (GLRO (dl_osversion)
-			  && libnew->osversion > GLRO (dl_osversion))
-			continue;
 		      if (_DL_PLATFORMS_COUNT
 			  && (libnew->hwcap & _DL_HWCAP_PLATFORM) != 0
 			  && ((libnew->hwcap & _DL_HWCAP_PLATFORM)
diff --git a/elf/dl-diagnostics.c b/elf/dl-diagnostics.c
index d29bdd6904..dd3871b1e0 100644
--- a/elf/dl-diagnostics.c
+++ b/elf/dl-diagnostics.c
@@ -231,10 +231,6 @@ print_version (void)
 void
 _dl_print_diagnostics (char **environ)
 {
-#ifdef HAVE_DL_DISCOVER_OSVERSION
-  _dl_diagnostics_print_labeled_value
-    ("dl_discover_osversion", _dl_discover_osversion ());
-#endif
   _dl_diagnostics_print_labeled_string ("dl_dst_lib", DL_DST_LIB);
   _dl_diagnostics_print_labeled_value ("dl_hwcap", GLRO (dl_hwcap));
   _dl_diagnostics_print_labeled_value ("dl_hwcap_important", HWCAP_IMPORTANT);
@@ -243,7 +239,6 @@ _dl_print_diagnostics (char **environ)
     ("dl_hwcaps_subdirs", _dl_hwcaps_subdirs);
   _dl_diagnostics_print_labeled_value
     ("dl_hwcaps_subdirs_active", _dl_hwcaps_subdirs_active ());
-  _dl_diagnostics_print_labeled_value ("dl_osversion", GLRO (dl_osversion));
   _dl_diagnostics_print_labeled_value ("dl_pagesize", GLRO (dl_pagesize));
   _dl_diagnostics_print_labeled_string ("dl_platform", GLRO (dl_platform));
   _dl_diagnostics_print_labeled_string
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 892e8ef2f6..eae56e7b16 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1591,13 +1591,6 @@ open_verify (const char *name, int fd,
     [EI_OSABI] = ELFOSABI_SYSV,
     [EI_ABIVERSION] = 0
   };
-  static const struct
-  {
-    ElfW(Word) vendorlen;
-    ElfW(Word) datalen;
-    ElfW(Word) type;
-    char vendor[4];
-  } expected_note = { 4, 16, 1, "GNU" };
   /* Initialize it to make the compiler happy.  */
   const char *errstring = NULL;
   int errval = 0;
@@ -1628,10 +1621,7 @@ open_verify (const char *name, int fd,
   if (fd != -1)
     {
       ElfW(Ehdr) *ehdr;
-      ElfW(Phdr) *phdr, *ph;
-      ElfW(Word) *abi_note;
-      ElfW(Word) *abi_note_malloced = NULL;
-      unsigned int osversion;
+      ElfW(Phdr) *phdr;
       size_t maplength;
 
       /* We successfully opened the file.  Now verify it is a file
@@ -1695,13 +1685,16 @@ open_verify (const char *name, int fd,
 #endif
 	      )
 	    errstring = N_("invalid ELF header");
+
 	  else if (ehdr->e_ident[EI_CLASS] != ELFW(CLASS))
 	    {
 	      /* This is not a fatal error.  On architectures where
 		 32-bit and 64-bit binaries can be run this might
 		 happen.  */
 	      *found_other_class = true;
-	      goto close_and_out;
+	      __close_nocancel (fd);
+	      __set_errno (ENOENT);
+	      return -1;
 	    }
 	  else if (ehdr->e_ident[EI_DATA] != byteorder)
 	    {
@@ -1736,7 +1729,11 @@ open_verify (const char *name, int fd,
 	  goto lose;
 	}
       if (! __glibc_likely (elf_machine_matches_host (ehdr)))
-	goto close_and_out;
+	{
+	  __close_nocancel (fd);
+	  __set_errno (ENOENT);
+	  return -1;
+	}
       else if (__glibc_unlikely (ehdr->e_type != ET_DYN
 				 && ehdr->e_type != ET_EXEC))
 	{
@@ -1758,7 +1755,6 @@ open_verify (const char *name, int fd,
 	  if ((size_t) __pread64_nocancel (fd, (void *) phdr, maplength,
 					   ehdr->e_phoff) != maplength)
 	    {
-	    read_error:
 	      errval = errno;
 	      errstring = N_("cannot read file data");
 	      goto lose;
@@ -1768,73 +1764,12 @@ open_verify (const char *name, int fd,
       if (__glibc_unlikely (elf_machine_reject_phdr_p
 			    (phdr, ehdr->e_phnum, fbp->buf, fbp->len,
 			     loader, fd)))
-	goto close_and_out;
-
-      /* Check .note.ABI-tag if present.  */
-      for (ph = phdr; ph < &phdr[ehdr->e_phnum]; ++ph)
-	if (ph->p_type == PT_NOTE && ph->p_filesz >= 32
-	    && (ph->p_align == 4 || ph->p_align == 8))
-	  {
-	    ElfW(Addr) size = ph->p_filesz;
-
-	    if (ph->p_offset + size <= (size_t) fbp->len)
-	      abi_note = (void *) (fbp->buf + ph->p_offset);
-	    else
-	      {
-		/* Note: __libc_use_alloca is not usable here, because
-		   thread info may not have been set up yet.  */
-		if (size < __MAX_ALLOCA_CUTOFF)
-		  abi_note = alloca (size);
-		else
-		  {
-		    /* There could be multiple PT_NOTEs.  */
-		    abi_note_malloced = realloc (abi_note_malloced, size);
-		    if (abi_note_malloced == NULL)
-		      goto read_error;
-
-		    abi_note = abi_note_malloced;
-		  }
-		if (__pread64_nocancel (fd, (void *) abi_note, size,
-					ph->p_offset) != size)
-		  {
-		    free (abi_note_malloced);
-		    goto read_error;
-		  }
-	      }
-
-	    while (memcmp (abi_note, &expected_note, sizeof (expected_note)))
-	      {
-		ElfW(Addr) note_size
-		  = ELF_NOTE_NEXT_OFFSET (abi_note[0], abi_note[1],
-					  ph->p_align);
-
-		if (size - 32 < note_size)
-		  {
-		    size = 0;
-		    break;
-		  }
-		size -= note_size;
-		abi_note = (void *) abi_note + note_size;
-	      }
-
-	    if (size == 0)
-	      continue;
-
-	    osversion = (abi_note[5] & 0xff) * 65536
-			+ (abi_note[6] & 0xff) * 256
-			+ (abi_note[7] & 0xff);
-	    if (abi_note[4] != __ABI_TAG_OS
-		|| (GLRO(dl_osversion) && GLRO(dl_osversion) < osversion))
-	      {
-	      close_and_out:
-		__close_nocancel (fd);
-		__set_errno (ENOENT);
-		fd = -1;
-	      }
+	{
+	  __close_nocancel (fd);
+	  __set_errno (ENOENT);
+	  return -1;
+	}
 
-	    break;
-	  }
-      free (abi_note_malloced);
     }
 
   return fd;
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 153dd57ad2..1e82e8c554 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -145,8 +145,6 @@ size_t _dl_minsigstacksize = CONSTANT_MINSIGSTKSZ;
 
 int _dl_inhibit_cache;
 
-unsigned int _dl_osversion;
-
 /* All known directories in sorted order.  */
 struct r_search_path_elem *_dl_all_dirs;
 
@@ -327,10 +325,6 @@ _dl_non_dynamic_init (void)
   DL_PLATFORM_INIT;
 #endif
 
-#ifdef DL_OSVERSION_INIT
-  DL_OSVERSION_INIT;
-#endif
-
   /* Now determine the length of the platform string.  */
   if (_dl_platform != NULL)
     _dl_platformlen = strlen (_dl_platform);
diff --git a/elf/rtld.c b/elf/rtld.c
index 19e328f89e..11110cb436 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -384,9 +384,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
     ._dl_error_free = _dl_error_free,
     ._dl_tls_get_addr_soft = _dl_tls_get_addr_soft,
     ._dl_libc_freeres = __rtld_libc_freeres,
-#ifdef HAVE_DL_DISCOVER_OSVERSION
-    ._dl_discover_osversion = _dl_discover_osversion
-#endif
   };
 /* If we would use strong_alias here the compiler would see a
    non-hidden definition.  This would undo the effect of the previous
@@ -1715,10 +1712,6 @@ dl_main (const ElfW(Phdr) *phdr,
   /* With vDSO setup we can initialize the function pointers.  */
   setup_vdso_pointers ();
 
-#ifdef DL_SYSDEP_OSCHECK
-  DL_SYSDEP_OSCHECK (_dl_fatal_printf);
-#endif
-
   /* Initialize the data structures for the search paths for shared
      objects.  */
   call_init_paths (&state);
@@ -2644,14 +2637,6 @@ process_envvars (struct dl_main_state *state)
 	    GLRO(dl_dynamic_weak) = 1;
 	  break;
 
-	case 13:
-	  /* We might have some extra environment variable with length 13
-	     to handle.  */
-#ifdef EXTRA_LD_ENVVARS_13
-	  EXTRA_LD_ENVVARS_13
-#endif
-	  break;
-
 	case 14:
 	  /* Where to place the profiling data file.  */
 	  if (!__libc_enable_secure
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 9878e7e87e..97cbe41171 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -563,8 +563,6 @@ struct rtld_global_ro
 /* These two are used only internally.  */
 #define DL_DEBUG_HELP       (1 << 10)
 
-  /* OS version.  */
-  EXTERN unsigned int _dl_osversion;
   /* Platform name.  */
   EXTERN const char *_dl_platform;
   EXTERN size_t _dl_platformlen;
@@ -712,10 +710,6 @@ struct rtld_global_ro
      dlopen.  */
   int (*_dl_find_object) (void *, struct dl_find_object *);
 
-#ifdef HAVE_DL_DISCOVER_OSVERSION
-  int (*_dl_discover_osversion) (void);
-#endif
-
   /* Dynamic linker operations used after static dlopen.  */
   const struct dlfcn_hook *_dl_dlfcn_hook;
 
diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
index 4ff02c9b6d..312055c469 100644
--- a/sysdeps/unix/sysv/linux/configure
+++ b/sysdeps/unix/sysv/linux/configure
@@ -70,6 +70,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel header at least $minimum_kernel" >&5
 $as_echo_n "checking for kernel header at least $minimum_kernel... " >&6; }
 decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
+abinumstr=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1.\2.\3/'`;
 abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -96,6 +97,10 @@ $as_echo "$libc_minimum_kernel" >&6; }
 if test "$libc_minimum_kernel" = ok; then
   cat >>confdefs.h <<_ACEOF
 #define __LINUX_KERNEL_VERSION $decnum
+_ACEOF
+
+  cat >>confdefs.h <<_ACEOF
+#define __LINUX_KERNEL_VERSION_STR "$abinumstr"
 _ACEOF
 
   cat >>confdefs.h <<_ACEOF
diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
index 197b7e66c8..5896d1135b 100644
--- a/sysdeps/unix/sysv/linux/configure.ac
+++ b/sysdeps/unix/sysv/linux/configure.ac
@@ -50,6 +50,7 @@ fi
 AC_MSG_CHECKING(for kernel header at least $minimum_kernel)
 changequote(,)dnl
 decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
+abinumstr=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1.\2.\3/'`;
 abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
 changequote([,])dnl
 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <linux/version.h>
@@ -59,6 +60,7 @@ AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[#include <linux/version.h>
 AC_MSG_RESULT($libc_minimum_kernel)
 if test "$libc_minimum_kernel" = ok; then
   AC_DEFINE_UNQUOTED(__LINUX_KERNEL_VERSION, $decnum)
+  AC_DEFINE_UNQUOTED(__LINUX_KERNEL_VERSION_STR, "$abinumstr")
   AC_DEFINE_UNQUOTED(__ABI_TAG_VERSION, $abinum)
 else
   AC_MSG_ERROR([*** The available kernel headers are older than the requested
diff --git a/sysdeps/unix/sysv/linux/dl-librecon.h b/sysdeps/unix/sysv/linux/dl-librecon.h
deleted file mode 100644
index dfebcea4d8..0000000000
--- a/sysdeps/unix/sysv/linux/dl-librecon.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Optional code to distinguish library flavours.
-   Copyright (C) 2001-2022 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
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef _DL_LIBRECON_H
-#define _DL_LIBRECON_H	1
-
-static inline void __attribute__ ((unused, always_inline))
-_dl_osversion_init (char *assume_kernel)
-{
-  unsigned long int i, j, osversion = 0;
-  char *p = assume_kernel, *q;
-
-  for (i = 0; i < 3; i++, p = q + 1)
-    {
-      j = _dl_strtoul (p, &q);
-      if (j >= 255 || p == q || (i < 2 && *q && *q != '.'))
-	{
-	  osversion = 0;
-	  break;
-	}
-      osversion |= j << (16 - 8 * i);
-      if (!*q)
-	break;
-    }
-  if (osversion)
-    GLRO(dl_osversion) = osversion;
-}
-
-/* Recognizing extra environment variables.  */
-#define EXTRA_LD_ENVVARS_13 \
-    if (memcmp (envline, "ASSUME_KERNEL", 13) == 0)			      \
-      {									      \
-	_dl_osversion_init (&envline[14]);				      \
-	break;								      \
-      }
-
-#define DL_OSVERSION_INIT \
-  do {									      \
-    char *assume_kernel = getenv ("LD_ASSUME_KERNEL");			      \
-    if (assume_kernel)							      \
-      _dl_osversion_init (assume_kernel);				      \
-  } while (0)
-
-#endif /* dl-librecon.h */
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index 349d93e8ed..7888915f12 100644
--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -22,31 +22,6 @@
 #include <stdint.h>
 #include <not-cancel.h>
 
-#ifndef MIN
-# define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
-#define DL_SYSDEP_OSCHECK(FATAL)					      \
-  do {									      \
-    /* Test whether the kernel is new enough.  This test is only performed    \
-       if the library is not compiled to run on all kernels.  */	      \
-									      \
-    int version = _dl_discover_osversion ();				      \
-    if (__glibc_likely (version >= 0))					      \
-      {									      \
-	if (__builtin_expect (GLRO(dl_osversion) == 0, 1)		      \
-	    || GLRO(dl_osversion) > version)				      \
-	  GLRO(dl_osversion) = version;					      \
-									      \
-	/* Now we can test with the required version.  */		      \
-	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION)   \
-	  /* Not sufficent.  */						      \
-	  FATAL ("FATAL: kernel too old\n");				      \
-      }									      \
-    else if (__LINUX_KERNEL_VERSION > 0)				      \
-      FATAL ("FATAL: cannot determine kernel version\n");		      \
-  } while (0)
-
 static inline uintptr_t __attribute__ ((always_inline))
 _dl_setup_stack_chk_guard (void *dl_random)
 {
diff --git a/sysdeps/unix/sysv/linux/dl-sysdep.c b/sysdeps/unix/sysv/linux/dl-sysdep.c
index c90f109b11..9e15c5bf69 100644
--- a/sysdeps/unix/sysv/linux/dl-sysdep.c
+++ b/sysdeps/unix/sysv/linux/dl-sysdep.c
@@ -250,96 +250,3 @@ _dl_show_auxv (void)
 }
 
 #endif /* SHARED */
-
-
-int
-attribute_hidden
-_dl_discover_osversion (void)
-{
-#ifdef SHARED
-  if (GLRO(dl_sysinfo_map) != NULL)
-    {
-      /* If the kernel-supplied DSO contains a note indicating the kernel's
-	 version, we don't need to call uname or parse any strings.  */
-
-      static const struct
-      {
-	ElfW(Nhdr) hdr;
-	char vendor[8];
-      } expected_note = { { sizeof "Linux", sizeof (ElfW(Word)), 0 }, "Linux" };
-      const ElfW(Phdr) *const phdr = GLRO(dl_sysinfo_map)->l_phdr;
-      const ElfW(Word) phnum = GLRO(dl_sysinfo_map)->l_phnum;
-      for (uint_fast16_t i = 0; i < phnum; ++i)
-	if (phdr[i].p_type == PT_NOTE)
-	  {
-	    const ElfW(Addr) start = (phdr[i].p_vaddr
-				      + GLRO(dl_sysinfo_map)->l_addr);
-	    const ElfW(Nhdr) *note = (const void *) start;
-	    while ((ElfW(Addr)) (note + 1) - start < phdr[i].p_memsz)
-	      {
-		if (!memcmp (note, &expected_note, sizeof expected_note))
-		  return *(const ElfW(Word) *) ((const void *) note
-						+ sizeof expected_note);
-#define ROUND(len) (((len) + sizeof note->n_type - 1) & -sizeof note->n_type)
-		note = ((const void *) (note + 1)
-			+ ROUND (note->n_namesz) + ROUND (note->n_descsz));
-#undef ROUND
-	      }
-	  }
-    }
-#endif /* SHARED */
-
-  char bufmem[64];
-  char *buf = bufmem;
-  unsigned int version;
-  int parts;
-  char *cp;
-  struct utsname uts;
-
-  /* Try the uname system call.  */
-  if (__uname (&uts))
-    {
-      /* This was not successful.  Now try reading the /proc filesystem.  */
-      int fd = __open64_nocancel ("/proc/sys/kernel/osrelease", O_RDONLY);
-      if (fd < 0)
-	return -1;
-      ssize_t reslen = __read_nocancel (fd, bufmem, sizeof (bufmem));
-      __close_nocancel (fd);
-      if (reslen <= 0)
-	/* This also didn't work.  We give up since we cannot
-	   make sure the library can actually work.  */
-	return -1;
-      buf[MIN (reslen, (ssize_t) sizeof (bufmem) - 1)] = '\0';
-    }
-  else
-    buf = uts.release;
-
-  /* Now convert it into a number.  The string consists of at most
-     three parts.  */
-  version = 0;
-  parts = 0;
-  cp = buf;
-  while ((*cp >= '0') && (*cp <= '9'))
-    {
-      unsigned int here = *cp++ - '0';
-
-      while ((*cp >= '0') && (*cp <= '9'))
-	{
-	  here *= 10;
-	  here += *cp++ - '0';
-	}
-
-      ++parts;
-      version <<= 8;
-      version |= here;
-
-      if (*cp++ != '.' || parts == 3)
-	/* Another part following?  */
-	break;
-    }
-
-  if (parts < 3)
-    version <<= 8 * (3 - parts);
-
-  return version;
-}
diff --git a/sysdeps/unix/sysv/linux/dl-sysdep.h b/sysdeps/unix/sysv/linux/dl-sysdep.h
index cb8bf7e6b1..b3ae5cb637 100644
--- a/sysdeps/unix/sysv/linux/dl-sysdep.h
+++ b/sysdeps/unix/sysv/linux/dl-sysdep.h
@@ -24,10 +24,3 @@
    we aren't making direct use of it.  So enable this across the board.  */
 
 #define NEED_DL_SYSINFO_DSO	1
-
-
-#ifndef __ASSEMBLER__
-/* Get version of the OS.  */
-extern int _dl_discover_osversion (void) attribute_hidden;
-# define HAVE_DL_DISCOVER_OSVERSION	1
-#endif
diff --git a/sysdeps/unix/sysv/linux/i386/dl-librecon.h b/sysdeps/unix/sysv/linux/i386/dl-librecon.h
index 7882679f20..78e3f0d02d 100644
--- a/sysdeps/unix/sysv/linux/i386/dl-librecon.h
+++ b/sysdeps/unix/sysv/linux/i386/dl-librecon.h
@@ -18,8 +18,6 @@
 
 #ifndef _DL_LIBRECON_H
 
-#include <sysdeps/unix/sysv/linux/dl-librecon.h>
-
 #define DISTINGUISH_LIB_VERSIONS \
   do									      \
     {									      \
-- 
2.32.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] elf: Remove ldconfig kernel version check
  2022-03-04 13:37 [PATCH v2 0/3] Remove kernel version and distinguish library check Adhemerval Zanella
  2022-03-04 13:37 ` [PATCH v2 1/3] Remove kernel version check Adhemerval Zanella
@ 2022-03-04 13:38 ` Adhemerval Zanella
  2022-05-16 12:46   ` Florian Weimer
  2022-03-04 13:38 ` [PATCH v2 3/3] Remove dl-librecon.h header Adhemerval Zanella
  2 siblings, 1 reply; 8+ messages in thread
From: Adhemerval Zanella @ 2022-03-04 13:38 UTC (permalink / raw)
  To: libc-alpha, Florian Weimer

Now that it was removed on libc.so.
---
 elf/cache.c                                  | 55 +++-----------------
 elf/ldconfig.c                               | 22 +++-----
 elf/readelflib.c                             | 51 +-----------------
 elf/readlib.c                                |  9 ++--
 sysdeps/generic/dl-cache.h                   |  1 -
 sysdeps/generic/ldconfig.h                   | 14 ++---
 sysdeps/unix/sysv/linux/arm/readelflib.c     | 18 +++----
 sysdeps/unix/sysv/linux/ia64/readelflib.c    | 18 +++----
 sysdeps/unix/sysv/linux/mips/readelflib.c    | 18 +++----
 sysdeps/unix/sysv/linux/powerpc/readelflib.c | 18 +++----
 sysdeps/unix/sysv/linux/riscv/readelflib.c   | 18 +++----
 sysdeps/unix/sysv/linux/s390/readelflib.c    | 18 +++----
 sysdeps/unix/sysv/linux/sparc/readelflib.c   | 18 +++----
 sysdeps/unix/sysv/linux/x86/readelflib.c     | 18 +++----
 14 files changed, 89 insertions(+), 207 deletions(-)

diff --git a/elf/cache.c b/elf/cache.c
index dbf4c83a7a..e7d751280d 100644
--- a/elf/cache.c
+++ b/elf/cache.c
@@ -144,7 +144,6 @@ struct cache_entry
   struct stringtable_entry *lib; /* Library name.  */
   struct stringtable_entry *path; /* Path to find library.  */
   int flags;			/* Flags to indicate kind of library.  */
-  unsigned int osversion;	/* Required OS version.  */
   unsigned int isa_level;	/* Required ISA level.  */
   uint64_t hwcap;		/* Important hardware capabilities.  */
   int bits_hwcap;		/* Number of bits set in hwcap.  */
@@ -163,8 +162,8 @@ static const char *flag_descr[] =
 
 /* Print a single entry.  */
 static void
-print_entry (const char *lib, int flag, unsigned int osversion,
-	     uint64_t hwcap, const char *hwcap_string, const char *key)
+print_entry (const char *lib, int flag, uint64_t hwcap,
+	     const char *hwcap_string, const char *key)
 {
   printf ("\t%s (", lib);
   switch (flag & FLAG_TYPE_MASK)
@@ -240,27 +239,6 @@ print_entry (const char *lib, int flag, unsigned int osversion,
     printf (", hwcap: \"%s\"", hwcap_string);
   else if (hwcap != 0)
     printf (", hwcap: %#.16" PRIx64, hwcap);
-  if (osversion != 0)
-    {
-      static const char *const abi_tag_os[] =
-      {
-	[0] = "Linux",
-	[1] = "Hurd",
-	[2] = "Solaris",
-	[3] = "FreeBSD",
-	[4] = "kNetBSD",
-	[5] = "Syllable",
-	[6] = N_("Unknown OS")
-      };
-#define MAXTAG (sizeof abi_tag_os / sizeof abi_tag_os[0] - 1)
-      unsigned int os = osversion >> 24;
-
-      printf (_(", OS ABI: %s %d.%d.%d"),
-	      _(abi_tag_os[os > MAXTAG ? MAXTAG : os]),
-	      (osversion >> 16) & 0xff,
-	      (osversion >> 8) & 0xff,
-	      osversion & 0xff);
-    }
   printf (") => %s\n", key);
 }
 
@@ -393,7 +371,7 @@ print_cache (const char *cache_name)
       /* Print everything.  */
       for (unsigned int i = 0; i < cache->nlibs; i++)
 	print_entry (cache_data + cache->libs[i].key,
-		     cache->libs[i].flags, 0, 0, NULL,
+		     cache->libs[i].flags, 0, NULL,
 		     cache_data + cache->libs[i].value);
     }
   else if (format == 1)
@@ -414,7 +392,6 @@ print_cache (const char *cache_name)
 				   &cache_new->libs[i]);
 	  print_entry (cache_data + cache_new->libs[i].key,
 		       cache_new->libs[i].flags,
-		       cache_new->libs[i].osversion,
 		       cache_new->libs[i].hwcap, hwcaps_string,
 		       cache_data + cache_new->libs[i].value);
 	}
@@ -467,10 +444,6 @@ compare (const struct cache_entry *e1, const struct cache_entry *e2)
 	return 1;
       else if (e2->hwcap < e1->hwcap)
 	return -1;
-      if (e2->osversion > e1->osversion)
-	return 1;
-      if (e2->osversion < e1->osversion)
-	return -1;
     }
   return res;
 }
@@ -671,7 +644,6 @@ save_cache (const char *cache_name)
 	     always begins at the beginning of the new cache
 	     struct.  */
 	  file_entries_new->libs[idx_new].flags = entry->flags;
-	  file_entries_new->libs[idx_new].osversion = entry->osversion;
 	  if (entry->hwcaps == NULL)
 	    file_entries_new->libs[idx_new].hwcap = entry->hwcap;
 	  else
@@ -792,8 +764,7 @@ save_cache (const char *cache_name)
 /* Add one library to the cache.  */
 void
 add_to_cache (const char *path, const char *filename, const char *soname,
-	      int flags, unsigned int osversion,
-	      unsigned int isa_level, uint64_t hwcap,
+	      int flags, unsigned int isa_level, uint64_t hwcap,
 	      struct glibc_hwcaps_subdirectory *hwcaps)
 {
   struct cache_entry *new_entry = xmalloc (sizeof (*new_entry));
@@ -810,7 +781,6 @@ add_to_cache (const char *path, const char *filename, const char *soname,
   new_entry->lib = stringtable_add (&strings, soname);
   new_entry->path = path_interned;
   new_entry->flags = flags;
-  new_entry->osversion = osversion;
   new_entry->isa_level = isa_level;
   new_entry->hwcap = hwcap;
   new_entry->hwcaps = hwcaps;
@@ -867,7 +837,6 @@ struct aux_cache_entry
 {
   struct aux_cache_entry_id id;
   int flags;
-  unsigned int osversion;
   unsigned int isa_level;
   int used;
   char *soname;
@@ -881,7 +850,6 @@ struct aux_cache_file_entry
   struct aux_cache_entry_id id;	/* Unique id of entry.  */
   int32_t flags;		/* This is 1 for an ELF library.  */
   uint32_t soname;		/* String table indice.  */
-  uint32_t osversion;		/* Required OS version.	 */
   uint32_t isa_level;		/* Required ISA level.	 */
 };
 
@@ -932,8 +900,7 @@ init_aux_cache (void)
 }
 
 int
-search_aux_cache (struct stat *stat_buf, int *flags,
-		  unsigned int *osversion, unsigned int *isa_level,
+search_aux_cache (struct stat *stat_buf, int *flags, unsigned int *isa_level,
 		  char **soname)
 {
   struct aux_cache_entry_id id;
@@ -951,7 +918,6 @@ search_aux_cache (struct stat *stat_buf, int *flags,
 	&& id.dev == entry->id.dev)
       {
 	*flags = entry->flags;
-	*osversion = entry->osversion;
 	*isa_level = entry->isa_level;
 	if (entry->soname != NULL)
 	  *soname = xstrdup (entry->soname);
@@ -966,8 +932,7 @@ search_aux_cache (struct stat *stat_buf, int *flags,
 
 static void
 insert_to_aux_cache (struct aux_cache_entry_id *id, int flags,
-		     unsigned int osversion, unsigned int isa_level,
-		     const char *soname, int used)
+		     unsigned int isa_level, const char *soname, int used)
 {
   size_t hash = aux_cache_entry_id_hash (id) % aux_hash_size;
   struct aux_cache_entry *entry;
@@ -982,7 +947,6 @@ insert_to_aux_cache (struct aux_cache_entry_id *id, int flags,
   entry = xmalloc (sizeof (struct aux_cache_entry) + len);
   entry->id = *id;
   entry->flags = flags;
-  entry->osversion = osversion;
   entry->isa_level = isa_level;
   entry->used = used;
   if (soname != NULL)
@@ -994,8 +958,7 @@ insert_to_aux_cache (struct aux_cache_entry_id *id, int flags,
 }
 
 void
-add_to_aux_cache (struct stat *stat_buf, int flags,
-		  unsigned int osversion, unsigned int isa_level,
+add_to_aux_cache (struct stat *stat_buf, int flags, unsigned int isa_level,
 		  const char *soname)
 {
   struct aux_cache_entry_id id;
@@ -1003,7 +966,7 @@ add_to_aux_cache (struct stat *stat_buf, int flags,
   id.ctime = (uint64_t) stat_buf->st_ctime;
   id.size = (uint64_t) stat_buf->st_size;
   id.dev = (uint64_t) stat_buf->st_dev;
-  insert_to_aux_cache (&id, flags, osversion, isa_level, soname, 1);
+  insert_to_aux_cache (&id, flags, isa_level, soname, 1);
 }
 
 /* Load auxiliary cache to search for unchanged entries.   */
@@ -1051,7 +1014,6 @@ load_aux_cache (const char *aux_cache_name)
   for (unsigned int i = 0; i < aux_cache->nlibs; ++i)
     insert_to_aux_cache (&aux_cache->libs[i].id,
 			 aux_cache->libs[i].flags,
-			 aux_cache->libs[i].osversion,
 			 aux_cache->libs[i].isa_level,
 			 aux_cache->libs[i].soname == 0
 			 ? NULL : aux_cache_data + aux_cache->libs[i].soname,
@@ -1120,7 +1082,6 @@ save_aux_cache (const char *aux_cache_name)
 	      str = mempcpy (str, entry->soname, len);
 	      str_offset += len;
 	    }
-	  file_entries->libs[idx].osversion = entry->osversion;
 	  file_entries->libs[idx++].isa_level = entry->isa_level;
 	}
 
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 57bb95ebc3..9394ac6438 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -658,7 +658,6 @@ manual_link (char *library)
   char *soname;
   struct stat stat_buf;
   int flag;
-  unsigned int osversion;
   unsigned int isa_level;
 
   /* Prepare arguments for create_links call.  Split library name in
@@ -723,8 +722,8 @@ manual_link (char *library)
       goto out;
     }
 
-  if (process_file (real_library, library, libname, &flag, &osversion,
-		    &isa_level, &soname, 0, &stat_buf))
+  if (process_file (real_library, library, libname, &flag, &isa_level, &soname,
+		    0, &stat_buf))
     {
       error (0, 0, _("No link created since soname could not be found for %s"),
 	     library);
@@ -772,7 +771,6 @@ struct dlib_entry
   char *soname;
   int flag;
   int is_link;
-  unsigned int osversion;
   unsigned int isa_level;
   struct dlib_entry *next;
 };
@@ -991,22 +989,18 @@ search_dir (const struct dir_entry *entry)
       /* First search whether the auxiliary cache contains this
 	 library already and it's not changed.  */
       char *soname;
-      unsigned int osversion;
       unsigned int isa_level;
-      if (!search_aux_cache (&lstat_buf, &flag, &osversion, &isa_level,
-			     &soname))
+      if (!search_aux_cache (&lstat_buf, &flag, &isa_level, &soname))
 	{
 	  if (process_file (real_name, file_name, direntry->d_name, &flag,
-			    &osversion, &isa_level, &soname, is_link,
-			    &lstat_buf))
+			    &isa_level, &soname, is_link, &lstat_buf))
 	    {
 	      if (real_name != real_file_name)
 		free (real_name);
 	      continue;
 	    }
 	  else if (opt_build_cache)
-	    add_to_aux_cache (&lstat_buf, flag, osversion, isa_level,
-			      soname);
+	    add_to_aux_cache (&lstat_buf, flag, isa_level, soname);
 	}
 
       if (soname == NULL)
@@ -1111,7 +1105,6 @@ search_dir (const struct dir_entry *entry)
 		  free (dlib_ptr->name);
 		  dlib_ptr->name = xstrdup (direntry->d_name);
 		  dlib_ptr->is_link = is_link;
-		  dlib_ptr->osversion = osversion;
 		  dlib_ptr->isa_level = isa_level;
 		}
 	      /* Don't add this library, abort loop.  */
@@ -1128,7 +1121,6 @@ search_dir (const struct dir_entry *entry)
 	  dlib_ptr->soname = soname;
 	  dlib_ptr->flag = flag;
 	  dlib_ptr->is_link = is_link;
-	  dlib_ptr->osversion = osversion;
 	  dlib_ptr->isa_level = isa_level;
 	  /* Add at head of list.  */
 	  dlib_ptr->next = dlibs;
@@ -1166,8 +1158,8 @@ search_dir (const struct dir_entry *entry)
 	}
       if (opt_build_cache)
 	add_to_cache (entry->path, filename, dlib_ptr->soname,
-		      dlib_ptr->flag, dlib_ptr->osversion,
-		      dlib_ptr->isa_level, hwcap, entry->hwcaps);
+		      dlib_ptr->flag, dlib_ptr->isa_level, hwcap,
+		      entry->hwcaps);
     }
 
   /* Free all resources.  */
diff --git a/elf/readelflib.c b/elf/readelflib.c
index e147416363..771182b5d0 100644
--- a/elf/readelflib.c
+++ b/elf/readelflib.c
@@ -40,8 +40,8 @@ do								\
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_elf_file (const char *file_name, const char *lib, int *flag,
-		  unsigned int *osversion, unsigned int *isa_level,
-		  char **soname, void *file_contents, size_t file_length)
+		  unsigned int *isa_level, char **soname, void *file_contents,
+		  size_t file_length)
 {
   int i;
   unsigned int j;
@@ -55,7 +55,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
   char *dynamic_strings;
 
   elf_header = (ElfW(Ehdr) *) file_contents;
-  *osversion = 0;
 
   if (elf_header->e_ident [EI_CLASS] != ElfW (CLASS))
     {
@@ -121,52 +120,6 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
 	      }
 	  break;
 
-	case PT_NOTE:
-	  if (!*osversion && segment->p_filesz >= 32 && segment->p_align >= 4)
-	    {
-	      ElfW(Word) *abi_note = (ElfW(Word) *) (file_contents
-						     + segment->p_offset);
-	      ElfW(Addr) size = segment->p_filesz;
-	      /* NB: Some PT_NOTE segment may have alignment value of 0
-		 or 1.  gABI specifies that PT_NOTE segments should be
-		 aligned to 4 bytes in 32-bit objects and to 8 bytes in
-		 64-bit objects.  As a Linux extension, we also support
-		 4 byte alignment in 64-bit objects.  If p_align is less
-		 than 4, we treate alignment as 4 bytes since some note
-		 segments have 0 or 1 byte alignment.   */
-	      ElfW(Addr) align = segment->p_align;
-	      if (align < 4)
-		align = 4;
-	      else if (align != 4 && align != 8)
-		continue;
-
-	      while (abi_note [0] != 4 || abi_note [1] != 16
-		     || abi_note [2] != 1
-		     || memcmp (abi_note + 3, "GNU", 4) != 0)
-		{
-		  ElfW(Addr) note_size
-		    = ELF_NOTE_NEXT_OFFSET (abi_note[0], abi_note[1],
-					    align);
-
-		  if (size - 32 < note_size || note_size == 0)
-		    {
-		      size = 0;
-		      break;
-		    }
-		  size -= note_size;
-		  abi_note = (void *) abi_note + note_size;
-		}
-
-	      if (size == 0)
-		break;
-
-	      *osversion = ((abi_note [4] << 24)
-			    | ((abi_note [5] & 0xff) << 16)
-			    | ((abi_note [6] & 0xff) << 8)
-			    | (abi_note [7] & 0xff));
-	    }
-	  break;
-
 	case PT_GNU_PROPERTY:
 	  /* The NT_GNU_PROPERTY_TYPE_0 note must be aligned to 4 bytes
 	     in 32-bit objects and to 8 bytes in 64-bit objects.  Skip
diff --git a/elf/readlib.c b/elf/readlib.c
index 3651dcdd8e..ed42fbd48e 100644
--- a/elf/readlib.c
+++ b/elf/readlib.c
@@ -72,9 +72,8 @@ is_gdb_python_file (const char *name)
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_file (const char *real_file_name, const char *file_name,
-	      const char *lib, int *flag, unsigned int *osversion,
-	      unsigned int *isa_level, char **soname, int is_link,
-	      struct stat *stat_buf)
+	      const char *lib, int *flag, unsigned int *isa_level,
+	      char **soname, int is_link, struct stat *stat_buf)
 {
   FILE *file;
   struct stat statbuf;
@@ -172,8 +171,8 @@ process_file (const char *real_file_name, const char *file_name,
   /* Libraries have to be shared object files.  */
   else if (elf_header->e_type != ET_DYN)
     ret = 1;
-  else if (process_elf_file (file_name, lib, flag, osversion, isa_level,
-			     soname, file_contents, statbuf.st_size))
+  else if (process_elf_file (file_name, lib, flag, isa_level, soname,
+			     file_contents, statbuf.st_size))
     ret = 1;
 
  done:
diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
index df385dca2d..2944963531 100644
--- a/sysdeps/generic/dl-cache.h
+++ b/sysdeps/generic/dl-cache.h
@@ -95,7 +95,6 @@ struct file_entry_new
       uint32_t key, value;	/* String table indices.  */
     };
   };
-  uint32_t osversion;		/* Required OS version.	 */
   uint64_t hwcap;		/* Hwcap entry.	 */
 };
 
diff --git a/sysdeps/generic/ldconfig.h b/sysdeps/generic/ldconfig.h
index 94f008bd90..7cc898db61 100644
--- a/sysdeps/generic/ldconfig.h
+++ b/sysdeps/generic/ldconfig.h
@@ -70,8 +70,7 @@ const char *glibc_hwcaps_subdirectory_name
 
 extern void add_to_cache (const char *path, const char *filename,
 			  const char *soname, int flags,
-			  unsigned int osversion, unsigned int isa_level,
-			  uint64_t hwcap,
+			  unsigned int isa_level, uint64_t hwcap,
 			  struct glibc_hwcaps_subdirectory *);
 
 extern void init_aux_cache (void);
@@ -79,28 +78,23 @@ extern void init_aux_cache (void);
 extern void load_aux_cache (const char *aux_cache_name);
 
 extern int search_aux_cache (struct stat *stat_buf, int *flags,
-			     unsigned int *osversion,
 			     unsigned int *isa_level, char **soname);
 
 extern void add_to_aux_cache (struct stat *stat_buf, int flags,
-			      unsigned int osversion,
 			      unsigned int isa_level, const char *soname);
 
 extern void save_aux_cache (const char *aux_cache_name);
 
 /* Declared in readlib.c.  */
 extern int process_file (const char *real_file_name, const char *file_name,
-			 const char *lib, int *flag,
-			 unsigned int *osversion, unsigned int *isa_level,
-			 char **soname, int is_link,
-			 struct stat *stat_buf);
+			 const char *lib, int *flag, unsigned int *isa_level,
+			 char **soname, int is_link, struct stat *stat_buf);
 
 extern char *implicit_soname (const char *lib, int flag);
 
 /* Declared in readelflib.c.  */
 extern int process_elf_file (const char *file_name, const char *lib,
-			     int *flag, unsigned int *osversion,
-			     unsigned int *isa_level, char **soname,
+			     int *flag, unsigned int *isa_level, char **soname,
 			     void *file_contents, size_t file_length);
 
 /* Declared in chroot_canon.c.  */
diff --git a/sysdeps/unix/sysv/linux/arm/readelflib.c b/sysdeps/unix/sysv/linux/arm/readelflib.c
index 428b0f85ff..d4956e2d25 100644
--- a/sysdeps/unix/sysv/linux/arm/readelflib.c
+++ b/sysdeps/unix/sysv/linux/arm/readelflib.c
@@ -17,19 +17,17 @@
 
 
 int process_elf32_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 int process_elf64_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_elf_file (const char *file_name, const char *lib, int *flag,
-		  unsigned int *osversion, unsigned int *isa_level,
-		  char **soname, void *file_contents, size_t file_length)
+		  unsigned int *isa_level, char **soname, void *file_contents,
+		  size_t file_length)
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
   int ret;
@@ -38,8 +36,8 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
     {
       Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header;
 
-      ret = process_elf32_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf32_file (file_name, lib, flag, isa_level, soname,
+				file_contents, file_length);
 
       if (!ret && EF_ARM_EABI_VERSION (elf32_header->e_flags) == EF_ARM_EABI_VER5)
 	{
@@ -57,8 +55,8 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
     }
   else
     {
-      ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf64_file (file_name, lib, flag, isa_level, soname,
+				file_contents, file_length);
       /* AArch64 libraries are always libc.so.6+.  */
       if (!ret)
 	*flag = FLAG_AARCH64_LIB64|FLAG_ELF_LIBC6;
diff --git a/sysdeps/unix/sysv/linux/ia64/readelflib.c b/sysdeps/unix/sysv/linux/ia64/readelflib.c
index cd0918176a..bfd3558675 100644
--- a/sysdeps/unix/sysv/linux/ia64/readelflib.c
+++ b/sysdeps/unix/sysv/linux/ia64/readelflib.c
@@ -17,30 +17,28 @@
 
 
 int process_elf32_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 int process_elf64_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_elf_file (const char *file_name, const char *lib, int *flag,
-		  unsigned int *osversion, unsigned int *isa_level,
-		  char **soname, void *file_contents, size_t file_length)
+		  unsigned int *isa_level, char **soname, void *file_contents,
+		  size_t file_length)
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
   int ret;
 
   if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
-    return process_elf32_file (file_name, lib, flag, osversion, isa_level,
-			       soname, file_contents, file_length);
+    return process_elf32_file (file_name, lib, flag, isa_level, soname,
+			       file_contents, file_length);
   else
     {
-      ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf64_file (file_name, lib, flag, isa_level, soname,
+				file_contents, file_length);
       /* Intel 64bit libraries are always libc.so.6+.  */
       if (!ret)
 	*flag = FLAG_IA64_LIB64|FLAG_ELF_LIBC6;
diff --git a/sysdeps/unix/sysv/linux/mips/readelflib.c b/sysdeps/unix/sysv/linux/mips/readelflib.c
index cfa6a12c1a..8c66ba1fa1 100644
--- a/sysdeps/unix/sysv/linux/mips/readelflib.c
+++ b/sysdeps/unix/sysv/linux/mips/readelflib.c
@@ -17,19 +17,17 @@
 
 
 int process_elf32_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 int process_elf64_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_elf_file (const char *file_name, const char *lib, int *flag,
-		  unsigned int *osversion, unsigned int *isa_level,
-		  char **soname, void *file_contents, size_t file_length)
+		  unsigned int *isa_level, char **soname, void *file_contents,
+		  size_t file_length)
 {
   union
     {
@@ -43,8 +41,8 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
   elf_header.eh = file_contents;
   if (elf_header.eh->e_ident [EI_CLASS] == ELFCLASS32)
     {
-      ret = process_elf32_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf32_file (file_name, lib, flag, isa_level, soname,
+				file_contents, file_length);
       if (!ret)
 	{
 	  Elf32_Word flags = elf_header.eh32->e_flags;
@@ -60,8 +58,8 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
     }
   else
     {
-      ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf64_file (file_name, lib, flag, isa_level, soname,
+				file_contents, file_length);
       /* n64 libraries are always libc.so.6+.  */
       if (!ret)
 	{
diff --git a/sysdeps/unix/sysv/linux/powerpc/readelflib.c b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
index 90ea9bf6f7..3b6902e35b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/readelflib.c
+++ b/sysdeps/unix/sysv/linux/powerpc/readelflib.c
@@ -18,30 +18,28 @@
 
 
 int process_elf32_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 int process_elf64_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_elf_file (const char *file_name, const char *lib, int *flag,
-		  unsigned int *osversion, unsigned int *isa_level,
-		  char **soname, void *file_contents, size_t file_length)
+		  unsigned int *isa_level, char **soname, void *file_contents,
+		  size_t file_length)
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
   int ret;
 
   if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
-    return process_elf32_file (file_name, lib, flag, osversion, isa_level,
-			       soname, file_contents, file_length);
+    return process_elf32_file (file_name, lib, flag, isa_level, soname,
+			       file_contents, file_length);
   else
     {
-      ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf64_file (file_name, lib, flag, isa_level, soname,
+				file_contents, file_length);
       /* PowerPC 64bit libraries are always libc.so.6+.  */
       if (!ret)
 	*flag = FLAG_POWERPC_LIB64|FLAG_ELF_LIBC6;
diff --git a/sysdeps/unix/sysv/linux/riscv/readelflib.c b/sysdeps/unix/sysv/linux/riscv/readelflib.c
index 29f1ac676f..db882c066f 100644
--- a/sysdeps/unix/sysv/linux/riscv/readelflib.c
+++ b/sysdeps/unix/sysv/linux/riscv/readelflib.c
@@ -18,12 +18,10 @@
 
 
 int process_elf32_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 int process_elf64_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 
 /* The ELF flags supported by our current glibc port:
@@ -40,8 +38,8 @@ int process_elf64_file (const char *file_name, const char *lib,
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_elf_file (const char *file_name, const char *lib, int *flag,
-		  unsigned int *osversion, unsigned int *isa_level,
-		  char **soname, void *file_contents, size_t file_length)
+		  unsigned int *isa_level, char **soname, void *file_contents,
+		  size_t file_length)
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
   Elf32_Ehdr *elf32_header = (Elf32_Ehdr *) elf_header;
@@ -54,14 +52,14 @@ process_elf_file (const char *file_name, const char *lib, int *flag,
 
   if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
     {
-      ret = process_elf32_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf32_file (file_name, lib, flag, isa_level, soname,
+				file_contents, file_length);
       flags = elf32_header->e_flags;
     }
   else
     {
-      ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf64_file (file_name, lib, flag, isa_level, soname,
+				file_contents, file_length);
       flags = elf64_header->e_flags;
     }
 
diff --git a/sysdeps/unix/sysv/linux/s390/readelflib.c b/sysdeps/unix/sysv/linux/s390/readelflib.c
index e3f51cc34d..063fce9d18 100644
--- a/sysdeps/unix/sysv/linux/s390/readelflib.c
+++ b/sysdeps/unix/sysv/linux/s390/readelflib.c
@@ -17,30 +17,28 @@
 
 
 int process_elf32_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 int process_elf64_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_elf_file (const char *file_name, const char *lib, int *flag,
-		  unsigned int *osversion, unsigned int *isa_level,
-		  char **soname, void *file_contents, size_t file_length)
+		  unsigned int *isa_level, char **soname, void *file_contents,
+		  size_t file_length)
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
   int ret;
 
   if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
-    return process_elf32_file (file_name, lib, flag, osversion, isa_level,
-			       soname, file_contents, file_length);
+    return process_elf32_file (file_name, lib, flag, isa_level, soname,
+			       file_contents, file_length);
   else
     {
-      ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf64_file (file_name, lib, flag, isa_level, soname,
+			       	file_contents, file_length);
       /* S/390 64bit libraries are always libc.so.6+.  */
       if (!ret)
 	*flag = FLAG_S390_LIB64|FLAG_ELF_LIBC6;
diff --git a/sysdeps/unix/sysv/linux/sparc/readelflib.c b/sysdeps/unix/sysv/linux/sparc/readelflib.c
index bc7b1f4f90..97d441693c 100644
--- a/sysdeps/unix/sysv/linux/sparc/readelflib.c
+++ b/sysdeps/unix/sysv/linux/sparc/readelflib.c
@@ -17,30 +17,28 @@
 
 
 int process_elf32_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 int process_elf64_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_elf_file (const char *file_name, const char *lib, int *flag,
-		  unsigned int *osversion, unsigned int *isa_level,
-		  char **soname, void *file_contents, size_t file_length)
+		  unsigned int *isa_level, char **soname, void *file_contents,
+		  size_t file_length)
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
   int ret;
 
   if (elf_header->e_ident [EI_CLASS] == ELFCLASS32)
-    return process_elf32_file (file_name, lib, flag, osversion, isa_level,
-			       soname, file_contents, file_length);
+    return process_elf32_file (file_name, lib, flag, isa_level, soname,
+			       file_contents, file_length);
   else
     {
-      ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-				soname, file_contents, file_length);
+      ret = process_elf64_file (file_name, lib, flag, isa_level, soname,
+				file_contents, file_length);
       /* Sparc 64bit libraries are always libc.so.6+.  */
       if (!ret)
 	*flag = FLAG_SPARC_LIB64|FLAG_ELF_LIBC6;
diff --git a/sysdeps/unix/sysv/linux/x86/readelflib.c b/sysdeps/unix/sysv/linux/x86/readelflib.c
index 8863b752a2..cfa2a9dd22 100644
--- a/sysdeps/unix/sysv/linux/x86/readelflib.c
+++ b/sysdeps/unix/sysv/linux/x86/readelflib.c
@@ -16,19 +16,17 @@
    <https://www.gnu.org/licenses/>.  */
 
 int process_elf32_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 int process_elf64_file (const char *file_name, const char *lib,
-			int *flag, unsigned int *osversion,
-			unsigned int *isa_level, char **soname,
+			int *flag, unsigned int *isa_level, char **soname,
 			void *file_contents, size_t file_length);
 
 /* Returns 0 if everything is ok, != 0 in case of error.  */
 int
 process_elf_file (const char *file_name, const char *lib, int *flag,
-		  unsigned int *osversion, unsigned int *isa_level,
-		  char **soname, void *file_contents, size_t file_length)
+		  unsigned int *isa_level, char **soname, void *file_contents,
+		  size_t file_length)
 {
   ElfW(Ehdr) *elf_header = (ElfW(Ehdr) *) file_contents;
   int ret, file_flag = 0;
@@ -67,11 +65,11 @@ failed:
     }
 
   if (elf_header->e_ident[EI_CLASS] == ELFCLASS32)
-    ret = process_elf32_file (file_name, lib, flag, osversion, isa_level,
-			      soname, file_contents, file_length);
+    ret = process_elf32_file (file_name, lib, flag, isa_level, soname,
+			      file_contents, file_length);
   else
-    ret = process_elf64_file (file_name, lib, flag, osversion, isa_level,
-			      soname, file_contents, file_length);
+    ret = process_elf64_file (file_name, lib, flag, isa_level, soname,
+			      file_contents, file_length);
 
   if (!ret && file_flag)
     *flag = file_flag;
-- 
2.32.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] Remove dl-librecon.h header.
  2022-03-04 13:37 [PATCH v2 0/3] Remove kernel version and distinguish library check Adhemerval Zanella
  2022-03-04 13:37 ` [PATCH v2 1/3] Remove kernel version check Adhemerval Zanella
  2022-03-04 13:38 ` [PATCH v2 2/3] elf: Remove ldconfig " Adhemerval Zanella
@ 2022-03-04 13:38 ` Adhemerval Zanella
  2022-05-16 12:49   ` Florian Weimer
  2 siblings, 1 reply; 8+ messages in thread
From: Adhemerval Zanella @ 2022-03-04 13:38 UTC (permalink / raw)
  To: libc-alpha, Florian Weimer

The Linux version used by i686 and m68k provide three overrrides for
generic code:

  1. DISTINGUISH_LIB_VERSIONS to print additional information when
     libc5 is used by a dependency.

  2. EXTRA_LD_ENVVARS to that enabled LD_LIBRARY_VERSION environment
     variable.

  3. EXTRA_UNSECURE_ENVVARS to add two environment variables related
     to aout support.

None are really requires, it has some decades since libc5 or aout
suppported was removed and Linux even remove support for aout files.
The LD_LIBRARY_VERSION is also dead code, dl_correct_cache_id is not
used anywhere.

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 NEWS                                       |  2 +
 elf/dl-support.c                           |  6 ---
 elf/rtld.c                                 | 25 +--------
 sysdeps/generic/dl-librecon.h              | 24 ---------
 sysdeps/generic/ldsodefs.h                 |  3 --
 sysdeps/unix/sysv/linux/i386/dl-librecon.h | 59 ----------------------
 sysdeps/unix/sysv/linux/m68k/dl-librecon.h |  1 -
 7 files changed, 4 insertions(+), 116 deletions(-)
 delete mode 100644 sysdeps/generic/dl-librecon.h
 delete mode 100644 sysdeps/unix/sysv/linux/i386/dl-librecon.h
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/dl-librecon.h

diff --git a/NEWS b/NEWS
index c348d948d2..3e106f2f60 100644
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,8 @@ Deprecated and removed features, and other changes affecting compatibility:
   glibc is still provided through NT_GNU_ABI_TAG ELF note and also printed
   when libc.so is issued directly.
 
+* On Linux, The LD_LIBRARY_VERSION environment variable has been removed.
+
 Changes to build and runtime requirements:
 
   [Add changes to build and runtime requirements here]
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 1e82e8c554..4af0b5b2ce 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -35,7 +35,6 @@
 #include <dl-machine.h>
 #include <libc-lock.h>
 #include <dl-cache.h>
-#include <dl-librecon.h>
 #include <dl-procinfo.h>
 #include <unsecvars.h>
 #include <hp-timing.h>
@@ -157,8 +156,6 @@ struct link_map *_dl_initfirst;
 /* Descriptor to write debug messages to.  */
 int _dl_debug_fd = STDERR_FILENO;
 
-int _dl_correct_cache_id = _DL_CACHE_DEFAULT_ID;
-
 ElfW(auxv_t) *_dl_auxv;
 const ElfW(Phdr) *_dl_phdr;
 size_t _dl_phnum;
@@ -303,9 +300,6 @@ _dl_non_dynamic_init (void)
     {
       static const char unsecure_envvars[] =
 	UNSECURE_ENVVARS
-#ifdef EXTRA_UNSECURE_ENVVARS
-	EXTRA_UNSECURE_ENVVARS
-#endif
 	;
       const char *cp = unsecure_envvars;
 
diff --git a/elf/rtld.c b/elf/rtld.c
index 11110cb436..222109e9f6 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -32,7 +32,6 @@
 #include <fpu_control.h>
 #include <hp-timing.h>
 #include <libc-lock.h>
-#include <dl-librecon.h>
 #include <unsecvars.h>
 #include <dl-cache.h>
 #include <dl-osinfo.h>
@@ -365,7 +364,6 @@ struct rtld_global_ro _rtld_global_ro attribute_relro =
     ._dl_sysinfo = DL_SYSINFO_DEFAULT,
 #endif
     ._dl_debug_fd = STDERR_FILENO,
-    ._dl_correct_cache_id = _DL_CACHE_DEFAULT_ID,
 #if !HAVE_TUNABLES
     ._dl_hwcap_mask = HWCAP_IMPORTANT,
 #endif
@@ -1697,10 +1695,6 @@ dl_main (const ElfW(Phdr) *phdr,
       if (main_map->l_ld == NULL)
 	_exit (1);
 
-      /* We allow here some platform specific code.  */
-#ifdef DISTINGUISH_LIB_VERSIONS
-      DISTINGUISH_LIB_VERSIONS;
-#endif
       _exit (has_interp ? 0 : 2);
     }
 
@@ -2654,29 +2648,14 @@ process_envvars (struct dl_main_state *state)
 		= _dl_strtoul (&envline[21], NULL) > 1;
 	    }
 	  break;
-
-	  /* We might have some extra environment variable to handle.  This
-	     is tricky due to the pre-processing of the length of the name
-	     in the switch statement here.  The code here assumes that added
-	     environment variables have a different length.  */
-#ifdef EXTRA_LD_ENVVARS
-	  EXTRA_LD_ENVVARS
-#endif
 	}
     }
 
   /* Extra security for SUID binaries.  Remove all dangerous environment
      variables.  */
-  if (__builtin_expect (__libc_enable_secure, 0))
+  if (__glibc_unlikely (__libc_enable_secure))
     {
-      static const char unsecure_envvars[] =
-#ifdef EXTRA_UNSECURE_ENVVARS
-	EXTRA_UNSECURE_ENVVARS
-#endif
-	UNSECURE_ENVVARS;
-      const char *nextp;
-
-      nextp = unsecure_envvars;
+      const char *nextp = UNSECURE_ENVVARS;
       do
 	{
 	  unsetenv (nextp);
diff --git a/sysdeps/generic/dl-librecon.h b/sysdeps/generic/dl-librecon.h
deleted file mode 100644
index 19fc70cb29..0000000000
--- a/sysdeps/generic/dl-librecon.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Optional code to distinguish library flavours.
-   Copyright (C) 1998-2022 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
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef _DL_LIBRECON_H
-#define _DL_LIBRECON_H	1
-
-/* In the general case we don't do anything.  */
-
-#endif /* dl-librecon.h */
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
index 97cbe41171..d0d94a0b77 100644
--- a/sysdeps/generic/ldsodefs.h
+++ b/sysdeps/generic/ldsodefs.h
@@ -601,9 +601,6 @@ struct rtld_global_ro
   /* Default floating-point control word.  */
   EXTERN fpu_control_t _dl_fpu_control;
 
-  /* Expected cache ID.  */
-  EXTERN int _dl_correct_cache_id;
-
   /* Mask for hardware capabilities that are available.  */
   EXTERN uint64_t _dl_hwcap;
 
diff --git a/sysdeps/unix/sysv/linux/i386/dl-librecon.h b/sysdeps/unix/sysv/linux/i386/dl-librecon.h
deleted file mode 100644
index 78e3f0d02d..0000000000
--- a/sysdeps/unix/sysv/linux/i386/dl-librecon.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Optional code to distinguish library flavours.
-   Copyright (C) 1998-2022 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
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef _DL_LIBRECON_H
-
-#define DISTINGUISH_LIB_VERSIONS \
-  do									      \
-    {									      \
-      /* We have to find out whether the binary is linked against	      \
-	 libc 5 or glibc.  We do this by looking at all the DT_NEEDED	      \
-	 entries.  If one is libc.so.5 this is a libc 5 linked binary.  */    \
-      if (main_map->l_info[DT_NEEDED])					      \
-	{								      \
-	  /* We have dependencies.  */					      \
-	  const ElfW(Dyn) *d;						      \
-	  const char *strtab;						      \
-									      \
-	  strtab = (const char *) D_PTR (main_map, l_info[DT_STRTAB]);	      \
-									      \
-	  for (d = main_map->l_ld; d->d_tag != DT_NULL; ++d)		      \
-	    if (d->d_tag == DT_NEEDED					      \
-		&& strcmp (strtab + d->d_un.d_val, "libc.so.5") == 0)	      \
-	      break;							      \
-									      \
-	  /* We print a `5' or `6' depending on the outcome.  */	      \
-	  _dl_printf (d->d_tag != DT_NULL ? "5\n" : "6\n");		      \
-	}								      \
-    }									      \
-  while (0)
-
-/* Recognizing extra environment variables.  */
-#define EXTRA_LD_ENVVARS \
-  case 15:								      \
-    if (memcmp (envline, "LIBRARY_VERSION", 15) == 0)			      \
-      GLRO(dl_correct_cache_id) = envline[16] == '5' ? 2 : 3;		      \
-    break;								      \
-
-/* Extra unsecure variables.  The names are all stuffed in a single
-   string which means they have to be terminated with a '\0' explicitly.  */
-#define EXTRA_UNSECURE_ENVVARS \
-  "LD_AOUT_LIBRARY_PATH\0"						      \
-  "LD_AOUT_PRELOAD\0"
-
-#endif /* dl-librecon.h */
diff --git a/sysdeps/unix/sysv/linux/m68k/dl-librecon.h b/sysdeps/unix/sysv/linux/m68k/dl-librecon.h
deleted file mode 100644
index dbb4e75712..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/dl-librecon.h
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/dl-librecon.h>
-- 
2.32.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] Remove kernel version check
  2022-03-04 13:37 ` [PATCH v2 1/3] Remove kernel version check Adhemerval Zanella
@ 2022-03-09 10:39   ` Florian Weimer
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Weimer @ 2022-03-09 10:39 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> The kernel version check is used to avoid glibc to run on older
> kernels where some syscall are not available and fallback code are
> not enabled to handle graciously fail.  However, it does not prevent
> if the kernel does not correctly advertise its version through
> vDSO note, uname or procfs.
>
> Also kernel version checks are sometime not desirable by users,
> where they want to deploy on different system with different kernel
> version knowing the minimum set of syscall is always presented on
> such systems.
>
> The kernel version check has been removed along with the
> LD_ASSUME_KERNEL environment variable.  The minimum kernel used to
> built glibc is still provided through NT_GNU_ABI_TAG ELF note and
> also printed when libc.so is issued.
>
> Checked on x86_64-linux-gnu.
> ---
> v2: Remove ABI note loop on elf/dl-load.c, remove missing _dl_osversion
>     on elf/dl-support.c.

This version looks okay to me, thanks.

Florian


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] elf: Remove ldconfig kernel version check
  2022-03-04 13:38 ` [PATCH v2 2/3] elf: Remove ldconfig " Adhemerval Zanella
@ 2022-05-16 12:46   ` Florian Weimer
  2022-05-16 12:50     ` Adhemerval Zanella
  0 siblings, 1 reply; 8+ messages in thread
From: Florian Weimer @ 2022-05-16 12:46 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
> index df385dca2d..2944963531 100644
> --- a/sysdeps/generic/dl-cache.h
> +++ b/sysdeps/generic/dl-cache.h
> @@ -95,7 +95,6 @@ struct file_entry_new
>        uint32_t key, value;	/* String table indices.  */
>      };
>    };
> -  uint32_t osversion;		/* Required OS version.	 */
>    uint64_t hwcap;		/* Hwcap entry.	 */
>  };
>  

Please leave this field in place and just updated the name or comment.
I don't think there is much to gain from changing the /etc/ld.so.cache
format in this way.

Rest looks okay to me.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] Remove dl-librecon.h header.
  2022-03-04 13:38 ` [PATCH v2 3/3] Remove dl-librecon.h header Adhemerval Zanella
@ 2022-05-16 12:49   ` Florian Weimer
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Weimer @ 2022-05-16 12:49 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> The Linux version used by i686 and m68k provide three overrrides for
> generic code:
>
>   1. DISTINGUISH_LIB_VERSIONS to print additional information when
>      libc5 is used by a dependency.
>
>   2. EXTRA_LD_ENVVARS to that enabled LD_LIBRARY_VERSION environment
>      variable.
>
>   3. EXTRA_UNSECURE_ENVVARS to add two environment variables related
>      to aout support.
>
> None are really requires, it has some decades since libc5 or aout
> suppported was removed and Linux even remove support for aout files.
> The LD_LIBRARY_VERSION is also dead code, dl_correct_cache_id is not
> used anywhere.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.

This version looks okay to me.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] elf: Remove ldconfig kernel version check
  2022-05-16 12:46   ` Florian Weimer
@ 2022-05-16 12:50     ` Adhemerval Zanella
  0 siblings, 0 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-05-16 12:50 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 16/05/2022 09:46, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
>> index df385dca2d..2944963531 100644
>> --- a/sysdeps/generic/dl-cache.h
>> +++ b/sysdeps/generic/dl-cache.h
>> @@ -95,7 +95,6 @@ struct file_entry_new
>>        uint32_t key, value;	/* String table indices.  */
>>      };
>>    };
>> -  uint32_t osversion;		/* Required OS version.	 */
>>    uint64_t hwcap;		/* Hwcap entry.	 */
>>  };
>>  
> 
> Please leave this field in place and just updated the name or comment.
> I don't think there is much to gain from changing the /etc/ld.so.cache
> format in this way.

Fair enough.

> 
> Rest looks okay to me.
> 
> Thanks,
> Florian
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-16 12:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-04 13:37 [PATCH v2 0/3] Remove kernel version and distinguish library check Adhemerval Zanella
2022-03-04 13:37 ` [PATCH v2 1/3] Remove kernel version check Adhemerval Zanella
2022-03-09 10:39   ` Florian Weimer
2022-03-04 13:38 ` [PATCH v2 2/3] elf: Remove ldconfig " Adhemerval Zanella
2022-05-16 12:46   ` Florian Weimer
2022-05-16 12:50     ` Adhemerval Zanella
2022-03-04 13:38 ` [PATCH v2 3/3] Remove dl-librecon.h header Adhemerval Zanella
2022-05-16 12:49   ` Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).