From 89e5cef3817a4caf7dea19c8fe4ec7a7ef13ed10 Mon Sep 17 00:00:00 2001 From: GNU Libc Maintainers Date: Sun, 25 Dec 2022 18:42:32 +0000 Subject: [PATCH] local-ldso-disable-hwcap # 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 # 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 # 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 | 10 ++++++++++ elf/dl-hwcaps.c | 20 ++++++++++++++++++++ sysdeps/alpha/ldsodefs.h | 2 ++ 3 files changed, 32 insertions(+) diff --git a/elf/dl-cache.c b/elf/dl-cache.c index b97c17b3a..cb5d4f5d4 100644 --- a/elf/dl-cache.c +++ b/elf/dl-cache.c @@ -26,6 +26,9 @@ #include <_itoa.h> #include #include +#include +#include +#include #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) { @@ -297,6 +305,8 @@ search_cache (const char *string_table, uint32_t string_table_size, if ((libnew->hwcap & hwcap_exclude) && !named_hwcap) continue; + if (disable_hwcap && libnew->hwcap != 0) + continue; if (_DL_PLATFORMS_COUNT && (libnew->hwcap & _DL_HWCAP_PLATFORM) != 0 && ((libnew->hwcap & _DL_HWCAP_PLATFORM) diff --git a/elf/dl-hwcaps.c b/elf/dl-hwcaps.c index 92eb53790..e67637374 100644 --- a/elf/dl-hwcaps.c +++ b/elf/dl-hwcaps.c @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include #include #include @@ -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; diff --git a/sysdeps/alpha/ldsodefs.h b/sysdeps/alpha/ldsodefs.h index a04f6ddc7..8ea560577 100644 --- a/sysdeps/alpha/ldsodefs.h +++ b/sysdeps/alpha/ldsodefs.h @@ -37,6 +37,8 @@ struct La_alpha_retval; struct La_alpha_retval *, \ const char *); +#define NEED_LD_SO_NOHWCAP + #include_next #endif -- 2.30.2