public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Javier Pello <devel@otheo.eu>
To: libc-alpha@sourceware.org
Subject: [PATCH v3 3/8] elf: Remove legacy hwcaps support from ldconfig
Date: Tue, 27 Sep 2022 20:06:45 +0200	[thread overview]
Message-ID: <20220927200645.eeb9a0d2c2864f03fec3d1ca@otheo.eu> (raw)
In-Reply-To: <20220927200352.0424a12908a437fef9d3a7bc@otheo.eu>

Remove support for the legacy hwcaps subdirectories from ldconfig.

Signed-off-by: Javier Pello <devel@otheo.eu>
---
 elf/ldconfig.c | 155 ++++---------------------------------------------
 1 file changed, 10 insertions(+), 145 deletions(-)

diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 6f37f38f..0d19d847 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -46,16 +46,6 @@
 
 #include <dl-procinfo.h>
 
-/* This subpath in search path entries is always supported and
-   included in the cache for backwards compatibility.  */
-#define TLS_SUBPATH "tls"
-
-/* The MSB of the hwcap field is set for objects in TLS_SUBPATH
-   directories.  There is always TLS support in glibc, so the dynamic
-   loader does not check the bit directly.  But more hwcap bits make a
-   an object more preferred, so the bit still has meaning.  */
-#define TLS_HWCAP_BIT 63
-
 #ifndef LD_SO_CONF
 # define LD_SO_CONF SYSCONFDIR "/ld.so.conf"
 #endif
@@ -120,9 +110,6 @@ static char *cache_file;
 /* Configuration file.  */
 static const char *config_file;
 
-/* Mask to use for important hardware capabilities.  */
-static unsigned long int hwcap_mask = HWCAP_IMPORTANT;
-
 /* Name and version of program.  */
 static void print_version (FILE *stream, struct argp_state *state);
 void (*argp_program_version_hook) (FILE *, struct argp_state *)
@@ -163,75 +150,6 @@ static struct argp argp =
   options, parse_opt, NULL, doc, NULL, more_help, NULL
 };
 
-/* Check if string corresponds to an important hardware capability or
-   a platform.  */
-static int
-is_hwcap_platform (const char *name)
-{
-  int hwcap_idx = _dl_string_hwcap (name);
-
-  /* Is this a normal hwcap for the machine like "fpu?"  */
-  if (hwcap_idx != -1 && ((1 << hwcap_idx) & hwcap_mask))
-    return 1;
-
-  /* Is this a platform pseudo-hwcap like "i686?"  */
-  hwcap_idx = _dl_string_platform (name);
-  if (hwcap_idx != -1)
-    return 1;
-
-  /* Backwards-compatibility for the "tls" subdirectory.  */
-  if (strcmp (name, TLS_SUBPATH) == 0)
-    return 1;
-
-  return 0;
-}
-
-/* Get hwcap (including platform) encoding of path.  */
-static uint64_t
-path_hwcap (const char *path)
-{
-  char *str = xstrdup (path);
-  char *ptr;
-  uint64_t hwcap = 0;
-  uint64_t h;
-
-  size_t len;
-
-  len = strlen (str);
-  if (str[len] == '/')
-    str[len] = '\0';
-
-  /* Search pathname from the end and check for hwcap strings.  */
-  for (;;)
-    {
-      ptr = strrchr (str, '/');
-
-      if (ptr == NULL)
-	break;
-
-      h = _dl_string_hwcap (ptr + 1);
-
-      if (h == (uint64_t) -1)
-	{
-	  h = _dl_string_platform (ptr + 1);
-	  if (h == (uint64_t) -1)
-	    {
-	      if (strcmp (ptr + 1, TLS_SUBPATH) == 0)
-		h = TLS_HWCAP_BIT;
-	      else
-		break;
-	    }
-	}
-      hwcap += 1ULL << h;
-
-      /* Search the next part of the path.  */
-      *ptr = '\0';
-    }
-
-  free (str);
-  return hwcap;
-}
-
 /* Handle program arguments.  */
 static error_t
 parse_opt (int key, char *arg, struct argp_state *state)
@@ -747,27 +665,15 @@ struct dlib_entry
 static void
 search_dir (const struct dir_entry *entry)
 {
-  uint64_t hwcap;
-  if (entry->hwcaps == NULL)
-    {
-      hwcap = path_hwcap (entry->path);
-      if (opt_verbose)
-	{
-	  if (hwcap != 0)
-	    printf ("%s: (hwcap: %#.16" PRIx64 ")", entry->path, hwcap);
-	  else
-	    printf ("%s:", entry->path);
-	}
-    }
-  else
+  if (opt_verbose)
     {
-      hwcap = 0;
-      if (opt_verbose)
+      if (entry->hwcaps == NULL)
+	printf ("%s:", entry->path);
+      else
 	printf ("%s: (hwcap: \"%s\")", entry->path,
 		glibc_hwcaps_subdirectory_name (entry->hwcaps));
+      printf (_(" (from %s:%d)\n"), entry->from_file, entry->from_line);
     }
-  if (opt_verbose)
-    printf (_(" (from %s:%d)\n"), entry->from_file, entry->from_line);
 
   char *dir_name;
   char *real_file_name;
@@ -808,14 +714,10 @@ search_dir (const struct dir_entry *entry)
 	  && direntry->d_type != DT_REG
 	  && direntry->d_type != DT_DIR)
 	continue;
-      /* Does this file look like a shared library or is it a hwcap
-	 subdirectory (if not already processing a glibc-hwcaps
-	 subdirectory)?  The dynamic linker is also considered as
-	 shared library.  */
+      /* Does this file look like a shared library?  The dynamic linker
+	 is also considered as shared library.  */
       if (!_dl_is_dso (direntry->d_name)
-	  && (direntry->d_type == DT_REG
-	      || (entry->hwcaps == NULL
-		  && !is_hwcap_platform (direntry->d_name))))
+	  && (direntry->d_type == DT_REG || entry->hwcaps == NULL))
 	continue;
 
       size_t len = strlen (direntry->d_name);
@@ -863,7 +765,6 @@ search_dir (const struct dir_entry *entry)
 	  }
 
       struct stat stat_buf;
-      bool is_dir;
       int is_link = S_ISLNK (lstat_buf.st_mode);
       if (is_link)
 	{
@@ -898,37 +799,13 @@ search_dir (const struct dir_entry *entry)
 	  if (opt_chroot != NULL)
 	    free (target_name);
 
-	  is_dir = S_ISDIR (stat_buf.st_mode);
-
 	  /* lstat_buf is later stored, update contents.  */
 	  lstat_buf.st_dev = stat_buf.st_dev;
 	  lstat_buf.st_ino = stat_buf.st_ino;
 	  lstat_buf.st_size = stat_buf.st_size;
 	  lstat_buf.st_ctime = stat_buf.st_ctime;
 	}
-      else
-	is_dir = S_ISDIR (lstat_buf.st_mode);
-
-      /* No descending into subdirectories if this directory is a
-	 glibc-hwcaps subdirectory (which are not recursive).  */
-      if (entry->hwcaps == NULL
-	  && is_dir && is_hwcap_platform (direntry->d_name))
-	{
-	  if (!is_link
-	      && direntry->d_type != DT_UNKNOWN
-	      && __builtin_expect (lstat (real_file_name, &lstat_buf), 0))
-	    {
-	      error (0, errno, _("Cannot lstat %s"), file_name);
-	      continue;
-	    }
-
-	  /* Handle subdirectory later.  */
-	  struct dir_entry *new_entry = new_sub_entry (entry, file_name,
-						       &lstat_buf);
-	  add_single_dir (new_entry, 0);
-	  continue;
-	}
-      else if (!S_ISREG (lstat_buf.st_mode) && !is_link)
+      else if (!S_ISREG (lstat_buf.st_mode))
 	continue;
 
       char *real_name;
@@ -1103,7 +980,7 @@ 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->isa_level, hwcap,
+		      dlib_ptr->flag, dlib_ptr->isa_level, 0,
 		      entry->hwcaps);
     }
 
@@ -1290,16 +1167,6 @@ parse_conf_include (const char *config_file, unsigned int lineno,
   free (copy);
 }
 
-/* Honour LD_HWCAP_MASK.  */
-static void
-set_hwcap (void)
-{
-  char *mask = getenv ("LD_HWCAP_MASK");
-
-  if (mask)
-    hwcap_mask = strtoul (mask, NULL, 0);
-}
-
 
 int
 main (int argc, char **argv)
@@ -1332,8 +1199,6 @@ main (int argc, char **argv)
 	  add_dir_1 (argv[i], "<cmdline>", 0);
     }
 
-  set_hwcap ();
-
   if (opt_chroot != NULL)
     {
       /* Normalize the path a bit, we might need it for printing later.  */
-- 
2.37.3

  parent reply	other threads:[~2022-09-27 18:06 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 18:06 [PATCH 0/4] elf: Fix hwcaps string size overestimation Javier Pello
2022-09-05 18:09 ` [PATCH 1/4] " Javier Pello
2022-09-08 10:15   ` Florian Weimer
2022-09-05 18:10 ` [PATCH 2/4] elf: Simplify hwcaps masked value bit counting Javier Pello
2022-09-05 18:12 ` [PATCH 3/4] elf: Remove unneeded conditional in _dl_important_hwcaps Javier Pello
2022-09-05 18:13 ` [PATCH 4/4] elf: Simplify hwcaps power set string construction Javier Pello
2022-09-06  7:35 ` [PATCH 0/4] elf: Fix hwcaps string size overestimation Florian Weimer
2022-09-06 18:12   ` Javier Pello
2022-09-08 11:23     ` Florian Weimer
2022-09-14 18:07       ` [PATCH 0/6] Remove legacy hwcaps support Javier Pello
2022-09-14 18:08         ` [PATCH 1/6] elf: Remove legacy hwcaps support from the dynamic loader Javier Pello
2022-09-14 18:10         ` [PATCH 2/6] elf: Remove legacy hwcaps support from ldconfig Javier Pello
2022-09-14 18:10         ` [PATCH 3/6] elf: Remove hwcap parameter from add_to_cache signature Javier Pello
2022-09-14 18:12         ` [PATCH 4/6] elf: Remove hwcap and bits_hwcap fields from struct cache_entry Javier Pello
2022-09-14 18:13         ` [PATCH 5/6] elf: Remove _dl_string_hwcap Javier Pello
2022-09-14 18:15         ` [PATCH 6/6] elf: Simplify output of hwcap subdirectories in ld.so help Javier Pello
2022-09-15  8:42           ` Carlos O'Donell
2022-09-15 19:12             ` Javier Pello
2022-09-14 21:23         ` [PATCH 0/6] Remove legacy hwcaps support Joseph Myers
2022-09-17 14:17         ` [PATCH v2 " Javier Pello
2022-09-17 14:18           ` [PATCH v2 1/6] elf: Remove legacy hwcaps support from the dynamic loader Javier Pello
2022-09-22 11:46             ` Florian Weimer
2022-09-17 14:19           ` [PATCH v2 2/6] elf: Remove legacy hwcaps support from ldconfig Javier Pello
2022-09-22 12:14             ` Florian Weimer
2022-09-17 14:20           ` [PATCH v2 3/6] elf: Remove hwcap parameter from add_to_cache signature Javier Pello
2022-09-22 16:02             ` Florian Weimer
2022-09-17 14:22           ` [PATCH v2 4/6] elf: Remove hwcap and bits_hwcap fields from struct cache_entry Javier Pello
2022-09-22 16:03             ` Florian Weimer
2022-09-17 14:23           ` [PATCH v2 5/6] elf: Remove _dl_string_hwcap Javier Pello
2022-09-17 14:24           ` [PATCH v2 6/6] elf: Simplify output of hwcap subdirectories in ld.so help Javier Pello
2022-09-21 16:26           ` [PATCH v2 0/6] Remove legacy hwcaps support Joseph Myers
2022-09-27 18:03           ` [PATCH v3 0/8] " Javier Pello
2022-09-27 18:05             ` [PATCH v3 1/8] x86_64: Remove platform directory library loading test Javier Pello
2022-10-03 14:56               ` Adhemerval Zanella Netto
2022-10-04 17:53                 ` Javier Pello
2022-10-04 17:59                   ` Adhemerval Zanella Netto
2022-09-27 18:05             ` [PATCH v3 2/8] elf: Remove legacy hwcaps support from the dynamic loader Javier Pello
2022-09-27 18:06             ` Javier Pello [this message]
2022-10-03 15:31               ` [PATCH v3 3/8] elf: Remove legacy hwcaps support from ldconfig Adhemerval Zanella Netto
2022-09-27 18:07             ` [PATCH v3 4/8] elf: Remove hwcap parameter from add_to_cache signature Javier Pello
2022-09-27 18:08             ` [PATCH v3 5/8] elf: Remove hwcap and bits_hwcap fields from struct cache_entry Javier Pello
2022-09-27 18:08             ` [PATCH v3 6/8] Add NEWS entry for legacy hwcaps removal Javier Pello
2022-10-03 15:44               ` Adhemerval Zanella Netto
2022-10-03 19:29                 ` Andreas Schwab
2022-10-03 19:49                   ` Adhemerval Zanella Netto
2022-10-03 19:59                     ` Florian Weimer
2022-10-04 18:00                       ` Adhemerval Zanella Netto
2022-10-05 18:12                         ` Javier Pello
2022-10-06 11:03                           ` Adhemerval Zanella Netto
2022-09-27 18:09             ` [PATCH v3 7/8] elf: Remove _dl_string_hwcap Javier Pello
2022-10-03 16:52               ` Adhemerval Zanella Netto
2022-09-27 18:10             ` [PATCH v3 8/8] elf: Simplify output of hwcap subdirectories in ld.so help Javier Pello
2022-10-03 17:02               ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220927200645.eeb9a0d2c2864f03fec3d1ca@otheo.eu \
    --to=devel@otheo.eu \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).