local-ldso-disable-hwcap
authorGNU Libc Maintainers <debian-glibc@lists.debian.org>
Tue, 4 Oct 2022 05:07:58 +0000 (06:07 +0100)
committerAurelien Jarno <aurel32@debian.org>
Tue, 4 Oct 2022 05:07:58 +0000 (06:07 +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 88bf78ad7c914b02109d6ddef7e08c0e8fd4574d..984f18bd0a79ea46cdf4ff81f8a7d829eb1d88a0 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 92eb53790ef8d32005c0da5e28804bc5843a94d3..e676373747be386bd7e75c9c4de7fc12e3e1d9d3 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 a04f6ddc715fa954d543340ce1c684b093385df1..8ea5605775751d78b8cc58b69303592f9456a311 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