elf: Remove loading legacy hwcaps/platform entries in dynamic loader

The legacy hwcaps mechanism was removed with glibc 2.37:
See this commit series:
- d178c67535
x86_64: Remove platform directory library loading test
- 6099908fb8
elf: Remove legacy hwcaps support from the dynamic loader
- b78ff5a25d
elf: Remove legacy hwcaps support from ldconfig
- 4a7094119c
elf: Remove hwcap parameter from add_to_cache signature
- cfbf883db3
elf: Remove hwcap and bits_hwcap fields from struct cache_entry
- 78d9a1620b
Add NEWS entry for legacy hwcaps removal
- ab40f20364
elf: Remove _dl_string_hwcap
- e76369ed63
elf: Simplify output of hwcap subdirectories in ld.so help

According to Florian Weimer, this was an oversight and should also
have been removed.

As ldconfig does not generate ld.so.cache entries with hwcap/platform
bits in the hwcap-field anymore, this patch now skips those entries.
Thus currently only named-hwcap-entries and the default entries are
allowed.
For named-hwcap entries bit 62 is set and also the isa-level bits can
be set.
For the default entries the hwcap-field is 0.
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Stefan Liebler 2024-06-07 13:42:37 +02:00
parent f14b6dfc87
commit c5aa5fd40a

View File

@ -27,10 +27,6 @@
#include <dl-hwcaps.h> #include <dl-hwcaps.h>
#include <dl-isa-level.h> #include <dl-isa-level.h>
#ifndef _DL_PLATFORMS_COUNT
# define _DL_PLATFORMS_COUNT 0
#endif
/* This is the starting address and the size of the mmap()ed file. */ /* This is the starting address and the size of the mmap()ed file. */
static struct cache_file *cache; static struct cache_file *cache;
static struct cache_file_new *cache_new; static struct cache_file_new *cache_new;
@ -201,15 +197,6 @@ search_cache (const char *string_table, uint32_t string_table_size,
struct file_entry *libs, uint32_t nlibs, uint32_t entry_size, struct file_entry *libs, uint32_t nlibs, uint32_t entry_size,
const char *name) const char *name)
{ {
/* Used by the HWCAP check in the struct file_entry_new case. */
uint64_t platform = _dl_string_platform (GLRO (dl_platform));
if (platform != (uint64_t) -1)
platform = 1ULL << platform;
uint64_t hwcap_mask = TUNABLE_GET (glibc, cpu, hwcap_mask, uint64_t, NULL);
#define _DL_HWCAP_TLS_MASK (1LL << 63)
uint64_t hwcap_exclude = ~((GLRO (dl_hwcap) & hwcap_mask)
| _DL_HWCAP_PLATFORM | _DL_HWCAP_TLS_MASK);
int left = 0; int left = 0;
int right = nlibs - 1; int right = nlibs - 1;
const char *best = NULL; const char *best = NULL;
@ -295,12 +282,9 @@ search_cache (const char *string_table, uint32_t string_table_size,
if (!named_hwcap && best != NULL) if (!named_hwcap && best != NULL)
break; break;
if ((libnew->hwcap & hwcap_exclude) && !named_hwcap) /* Skip entries with the legacy hwcap/platform mechanism
continue; which was removed with glibc 2.37. */
if (_DL_PLATFORMS_COUNT if (!named_hwcap && libnew->hwcap != 0)
&& (libnew->hwcap & _DL_HWCAP_PLATFORM) != 0
&& ((libnew->hwcap & _DL_HWCAP_PLATFORM)
!= platform))
continue; continue;
#ifdef SHARED #ifdef SHARED