From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id A74A83858D3C; Thu, 18 Apr 2024 19:30:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A74A83858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713468629; bh=PYdwEQgEUVGivlOt86frf6ac5/qcCNpJNZ8Bw8Ge9fo=; h=From:To:Subject:Date:From; b=VwwTxqeErGtd7/4mLzUCD0sEVTYE/F42ax0BzyuugSJiVOzWay8+WVoCVbAlkavsn 1bwTK8cdXTVXNYhqpm0aMc4ZlrMHbceQPRhh8sm7Hm3eFbMTutPYikfmYPIEr/RcGQ y70nsOShyOh1ZqHvWP7T5zmObez+QKIPqRJQrpMs= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] x86: Fix bsearch for compiler that do not define __USE_EXTERN_INLINES X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: 5a3b7503e46f7d8e5286dc88d479ec493bd8da4b X-Git-Newrev: dd727ee173ba60b492a1105693d11cf05c087276 Message-Id: <20240418193029.A74A83858D3C@sourceware.org> Date: Thu, 18 Apr 2024 19:30:29 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dd727ee173ba60b492a1105693d11cf05c087276 commit dd727ee173ba60b492a1105693d11cf05c087276 Author: Adhemerval Zanella Date: Thu Apr 18 16:27:11 2024 -0300 x86: Fix bsearch for compiler that do not define __USE_EXTERN_INLINES 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. Diff: --- sysdeps/x86/dl-cacheinfo.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h index 5a98f70364..1943dc7db6 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 + 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)