diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2020-12-05 07:01:58 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2021-01-13 05:51:17 -0800 |
commit | efbbd9c33adfa843d65860b1b02adebb8ecb57ce (patch) | |
tree | 79c61c55698036fc99ec936ea400c7a9975eef28 /sysdeps/generic | |
parent | 86a4d3fa7d1bda3c02cf713cf289d6f893970117 (diff) | |
download | glibc-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')
-rw-r--r-- | sysdeps/generic/dl-cache.h | 16 | ||||
-rw-r--r-- | sysdeps/generic/dl-isa-level.h | 25 | ||||
-rw-r--r-- | sysdeps/generic/elf-read-prop.h | 34 | ||||
-rw-r--r-- | sysdeps/generic/ldconfig.h | 22 |
4 files changed, 86 insertions, 11 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. */ diff --git a/sysdeps/generic/dl-isa-level.h b/sysdeps/generic/dl-isa-level.h new file mode 100644 index 0000000000..6fcd319c49 --- /dev/null +++ b/sysdeps/generic/dl-isa-level.h @@ -0,0 +1,25 @@ +/* Support for reading ISA level in /etc/ld.so.cache files written by + Linux ldconfig. Generic version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +/* Return true if the ISA level in ENTRY is compatible with CPU. */ +static inline bool +dl_cache_hwcap_isa_level_compatible (struct file_entry_new *entry) +{ + return true; +} diff --git a/sysdeps/generic/elf-read-prop.h b/sysdeps/generic/elf-read-prop.h new file mode 100644 index 0000000000..98c3d2acb5 --- /dev/null +++ b/sysdeps/generic/elf-read-prop.h @@ -0,0 +1,34 @@ +/* Support for GNU properties in ldconfig. Generic version. + Copyright (C) 2021 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef _ELF_READ_PROP_H +#define _ELF_READ_PROP_H + +/* Called for each property in the NT_GNU_PROPERTY_TYPE_0 note of SEGMENT. + Return value: + false: Continue processing the properties. + true : Stop processing the properties. + */ +static inline bool __attribute__ ((always_inline)) +read_gnu_property (unsigned int *isal_level, uint32_t type, uint32_t + datasz, void *data) +{ + return true; +} + +#endif diff --git a/sysdeps/generic/ldconfig.h b/sysdeps/generic/ldconfig.h index eb070fd259..3ab757077d 100644 --- a/sysdeps/generic/ldconfig.h +++ b/sysdeps/generic/ldconfig.h @@ -70,8 +70,9 @@ const char *glibc_hwcaps_subdirectory_name (const struct glibc_hwcaps_subdirectory *); extern void add_to_cache (const char *path, const char *filename, - const char *soname, - int flags, unsigned int osversion, uint64_t hwcap, + const char *soname, int flags, + unsigned int osversion, unsigned int isa_level, + uint64_t hwcap, struct glibc_hwcaps_subdirectory *); extern void init_aux_cache (void); @@ -79,23 +80,28 @@ extern void init_aux_cache (void); extern void load_aux_cache (const char *aux_cache_name); extern int search_aux_cache (struct stat64 *stat_buf, int *flags, - unsigned int *osversion, char **soname); + unsigned int *osversion, + unsigned int *isa_level, char **soname); extern void add_to_aux_cache (struct stat64 *stat_buf, int flags, - unsigned int osversion, const char *soname); + unsigned int osversion, + unsigned int isa_level, const char *soname); extern void save_aux_cache (const char *aux_cache_name); /* Declared in readlib.c. */ extern int process_file (const char *real_file_name, const char *file_name, - const char *lib, int *flag, unsigned int *osversion, - char **soname, int is_link, struct stat64 *stat_buf); + const char *lib, int *flag, + unsigned int *osversion, unsigned int *isa_level, + char **soname, int is_link, + struct stat64 *stat_buf); extern char *implicit_soname (const char *lib, int flag); /* Declared in readelflib.c. */ -extern int process_elf_file (const char *file_name, const char *lib, int *flag, - unsigned int *osversion, char **soname, +extern int process_elf_file (const char *file_name, const char *lib, + int *flag, unsigned int *osversion, + unsigned int *isa_level, char **soname, void *file_contents, size_t file_length); /* Declared in chroot_canon.c. */ |