about summary refs log tree commit diff
path: root/sysdeps/generic/dl-cache.h
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-12-05 07:01:58 -0800
committerH.J. Lu <hjl.tools@gmail.com>2021-01-13 05:51:17 -0800
commitefbbd9c33adfa843d65860b1b02adebb8ecb57ce (patch)
tree79c61c55698036fc99ec936ea400c7a9975eef28 /sysdeps/generic/dl-cache.h
parent86a4d3fa7d1bda3c02cf713cf289d6f893970117 (diff)
downloadglibc-efbbd9c33adfa843d65860b1b02adebb8ecb57ce.tar.gz
glibc-efbbd9c33adfa843d65860b1b02adebb8ecb57ce.tar.xz
glibc-efbbd9c33adfa843d65860b1b02adebb8ecb57ce.zip
ldconfig/x86: Store ISA level in cache and aux cache
Store ISA level in the portion of the unused upper 32 bits of the hwcaps
field in cache and the unused pad field in aux cache.  ISA level is stored
and checked only for shared objects in glibc-hwcaps subdirectories.  The
shared objects in the default directories aren't checked since there are
no fallbacks for these shared objects.

Tested on x86-64-v2, x86-64-v3 and x86-64-v4 machines with
--disable-hardcoded-path-in-tests and --enable-hardcoded-path-in-tests.
Diffstat (limited to 'sysdeps/generic/dl-cache.h')
-rw-r--r--sysdeps/generic/dl-cache.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/sysdeps/generic/dl-cache.h b/sysdeps/generic/dl-cache.h
index c7eca70d0c..964d50a486 100644
--- a/sysdeps/generic/dl-cache.h
+++ b/sysdeps/generic/dl-cache.h
@@ -106,14 +106,24 @@ struct file_entry_new
    entries.  */
 #define DL_CACHE_HWCAP_EXTENSION (1ULL << 62)
 
+/* The number of the ISA level bits in the upper 32 bits of the hwcap
+   field.  */
+#define DL_CACHE_HWCAP_ISA_LEVEL_COUNT 10
+
+/* The mask of the ISA level bits in the hwcap field.  */
+#define DL_CACHE_HWCAP_ISA_LEVEL_MASK \
+  ((1 << DL_CACHE_HWCAP_ISA_LEVEL_COUNT) -1)
+
 /* Return true if the ENTRY->hwcap value indicates that
    DL_CACHE_HWCAP_EXTENSION is used.  */
 static inline bool
 dl_cache_hwcap_extension (struct file_entry_new *entry)
 {
-  /* If DL_CACHE_HWCAP_EXTENSION is set, but other bits as well, this
-     is a different kind of extension.  */
-  return (entry->hwcap >> 32) == (DL_CACHE_HWCAP_EXTENSION >> 32);
+  /* This is an hwcap extension if only the DL_CACHE_HWCAP_EXTENSION bit
+     is set, ignoring the lower 32 bits as well as the ISA level bits in
+     the upper 32 bits.  */
+  return (((entry->hwcap >> 32) & ~DL_CACHE_HWCAP_ISA_LEVEL_MASK)
+	  == (DL_CACHE_HWCAP_EXTENSION >> 32));
 }
 
 /* See flags member of struct cache_file_new below.  */