aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-04-18 16:27:11 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-04-18 16:27:11 -0300
commitdd727ee173ba60b492a1105693d11cf05c087276 (patch)
tree43070af0606fc63eae5b6ffbc3af0bf0b2abf449
parent5a3b7503e46f7d8e5286dc88d479ec493bd8da4b (diff)
downloadglibc-azanella/clang.zip
glibc-azanella/clang.tar.gz
glibc-azanella/clang.tar.bz2
x86: Fix bsearch for compiler that do not define __USE_EXTERN_INLINESazanella/clang
The bsearch is called early during process initialization on Intel platform, before TCB has been set up; and if compiler does not enable __extern_inline it might call the symbol which might use an invalid thread-pointer. Expand the bsearch implementation from stdlib-bsearch.h with a different name. Checked on x86_64-linux-gnu with Intel chip.
-rw-r--r--sysdeps/x86/dl-cacheinfo.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
index 5a98f70..1943dc7 100644
--- a/sysdeps/x86/dl-cacheinfo.h
+++ b/sysdeps/x86/dl-cacheinfo.h
@@ -98,6 +98,12 @@ static const struct intel_02_cache_info
#define nintel_02_known (sizeof (intel_02_known) / sizeof (intel_02_known [0]))
+/* The bsearch is called early during process initialization, before TCB has
+ been set up; and if compiler does not enable __extern_inline it might call
+ the symbol which might use an invalid thread-pointer. */
+#define bsearch bsearch_inline
+#include <bits/stdlib-bsearch.h>
+
static int
intel_02_known_compare (const void *p1, const void *p2)
{
@@ -214,8 +220,8 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
struct intel_02_cache_info search;
search.idx = byte;
- found = bsearch (&search, intel_02_known, nintel_02_known,
- sizeof (intel_02_known[0]), intel_02_known_compare);
+ found = bsearch_inline (&search, intel_02_known, nintel_02_known,
+ sizeof (intel_02_known[0]), intel_02_known_compare);
if (found != NULL)
{
if (found->rel_name == folded_rel_name)