local-ldso-disable-hwcap
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Sat, 27 Aug 2022 11:38:11 +0000 (12:38 +0100)
committerAurelien Jarno <aurel32@debian.org>
Sat, 27 Aug 2022 11:38:11 +0000 (12:38 +0100)
# DP: Allow hwcap's to be disabled with the existence of a file. This
# DP: makes it easier to do upgrades with optimized (hwcap) library
# DP: packages.
# DP: Author: Rewritten by Daniel Jacobowitz <dan@debian.org>
# DP: Upstream status: Debian-Specific
# DP: Status Details: This isn't going to be acceptable upstream, we
# DP:                 only need it because we support in-place upgrades.
# DP: Date: 2003-10-28, (Updated 2005-01-02 gotom, 2007-05-20 aurel32)

# DP: Allow hwcap's to be disabled with the existence of a file. This
# DP: makes it easier to do upgrades with optimized (hwcap) library
# DP: packages.
# DP: Author: Rewritten by Daniel Jacobowitz <dan@debian.org>
# DP: Upstream status: Debian-Specific
# DP: Status Details: This isn't going to be acceptable upstream, we
# DP:                 only need it because we support in-place upgrades.
# DP: Date: 2003-10-28, (Updated 2005-01-02 gotom, 2007-05-20 aurel32)

Gbp-Pq: Topic any
Gbp-Pq: Name local-ldso-disable-hwcap.diff

elf/dl-cache.c
elf/dl-hwcaps.c
sysdeps/alpha/ldsodefs.h

index 2b8da8650d0a96e55dc3e9bc350fe48117db0a17..973bc4e5f1e5032d7413bddad8979bcc7605ad15 100644 (file)
@@ -26,6 +26,9 @@
 #include <_itoa.h>
 #include <dl-hwcaps.h>
 #include <dl-isa-level.h>
+#include <fcntl.h>
+#include <sysdep.h>
+#include <not-errno.h>
 
 #ifndef _DL_PLATFORMS_COUNT
 # define _DL_PLATFORMS_COUNT 0
@@ -216,6 +219,11 @@ search_cache (const char *string_table, uint32_t string_table_size,
 #ifdef SHARED
   uint32_t best_priority = 0;
 #endif
+  int disable_hwcap = 0;
+#ifdef NEED_LD_SO_NOHWCAP
+  if (__access_noerrno ("/etc/ld.so.nohwcap", F_OK) == 0)
+    disable_hwcap = 1;
+#endif
 
   while (left <= right)
     {
@@ -300,6 +308,8 @@ search_cache (const char *string_table, uint32_t string_table_size,
                      if (GLRO (dl_osversion)
                          && libnew->osversion > GLRO (dl_osversion))
                        continue;
+                     if (disable_hwcap && libnew->hwcap != 0)
+                       continue;
                      if (_DL_PLATFORMS_COUNT
                          && (libnew->hwcap & _DL_HWCAP_PLATFORM) != 0
                          && ((libnew->hwcap & _DL_HWCAP_PLATFORM)
index e3c611e005ffbc0d135fbe18f253c4cfc3ea40b8..23562d74f6df656848b7c36484aad64769fcbbb0 100644 (file)
@@ -22,6 +22,9 @@
 #include <libintl.h>
 #include <unistd.h>
 #include <ldsodefs.h>
+#include <fcntl.h>
+#include <sysdep.h>
+#include <not-errno.h>
 
 #include <dl-procinfo.h>
 #include <dl-hwcaps.h>
@@ -204,6 +207,23 @@ _dl_important_hwcaps (const char *glibc_hwcaps_prepend,
   /* For TLS enabled builds always add 'tls'.  */
   ++cnt;
 
+#ifdef NEED_LD_SO_NOHWCAP
+  if (__access_noerrno ("/etc/ld.so.nohwcap", F_OK) == 0)
+    {
+      /* If hwcap is disabled, we only have the base directory to search.  */
+      result = (struct r_strlenpair *) malloc (sizeof (*result));
+      if (result == NULL)
+       _dl_signal_error (ENOMEM, NULL, NULL,
+                        N_("cannot create capability list"));
+
+      result[0].str = (char *) result;  /* Does not really matter.  */
+      result[0].len = 0;
+
+      *sz = 1;
+      return result;
+    }
+#endif
+
   /* Create temporary data structure to generate result table.  */
   struct r_strlenpair temp[cnt];
   m = 0;
index 47d18aefe241690c85160cb9013780bed554b8d6..20b31e26d3e80488990b8e58bcfc5bef71549f40 100644 (file)
@@ -37,6 +37,8 @@ struct La_alpha_retval;
                                      struct La_alpha_retval *,         \
                                      const char *);
 
+#define NEED_LD_SO_NOHWCAP
+
 #include_next <ldsodefs.h>
 
 #endif