From patchwork Sat Sep 17 14:18:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Pello X-Patchwork-Id: 57717 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 841CB38515FC for ; Sat, 17 Sep 2022 14:20:33 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [IPv6:2001:4b98:dc4:8::231]) by sourceware.org (Postfix) with ESMTPS id AACF93858294 for ; Sat, 17 Sep 2022 14:20:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AACF93858294 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=otheo.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=otheo.eu Received: (Authenticated sender: #01#@otheo.eu) by mail.gandi.net (Postfix) with ESMTPSA id 2F73E100003 for ; Sat, 17 Sep 2022 14:20:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=otheo.eu; s=gm1; t=1663424417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DO7mIB5fuI4NkdjLtQie57M4Ue+pKmQty6uCxfEcr5k=; b=FOu1xg8PT2p3q4uqD6covefgtdQNmyoawWCrQxHQFC5VIG6VDV8ZWZYDl3g9LwVaLbf/vf m/42Z+EAKzQhyCZPjiqLUuDp+IJAkvktg5kbLKjSjK4688qwaypW+OSVOi/TdsuL92tX+O rw1L7ofAAZFJkyAUmUoeJcrs4tUhY8qugBeDPb8UIyv5RoyzKoClaHPKHzZYIbruIKKzB5 jcYuby55kjpfNUeM7bux56pJKmlIeBcbVPcm1ukueIFWbidZAcSjn0mlh/LB3rJbtesoZy ixNbNliUogi6fG4VB3iXrlAw61RIm1I1VJTCZZXwdWucPGgirDiZ2vdzPKM4EQ== Date: Sat, 17 Sep 2022 16:18:58 +0200 From: Javier Pello To: libc-alpha@sourceware.org Subject: [PATCH v2 1/6] elf: Remove legacy hwcaps support from the dynamic loader Message-Id: <20220917161858.e1841841102a61bdfc2f7bcb@otheo.eu> In-Reply-To: <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> References: <20220905200652.d69204581d15c64647da5cd2@otheo.eu> <87h71l9crb.fsf@oldenburg.str.redhat.com> <20220906201207.e7b3d08272af5649754e76b1@otheo.eu> <87h71i6rfa.fsf@oldenburg.str.redhat.com> <20220914200724.8e685fbbaf441c96d19011c6@otheo.eu> <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; i686-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Remove support for the legacy hwcaps subdirectories from the dynamic loader. Signed-off-by: Javier Pello Reviewed-by: Florian Weimer --- elf/Makefile | 6 -- elf/dl-hwcaps.c | 184 +++--------------------------------------------- elf/dl-usage.c | 32 --------- 3 files changed, 10 insertions(+), 212 deletions(-) diff --git a/elf/Makefile b/elf/Makefile index 008770bf..276343a4 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -2689,12 +2689,6 @@ $(objpfx)tst-rtld-help.out: $(objpfx)ld.so $(test-wrapper) $(rtld-prefix) --help > $@; \ status=$$?; \ echo "info: ld.so exit status: $$status" >> $@; \ - if ! grep -q 'Legacy HWCAP subdirectories under library search path directories' $@; then \ - echo "error: missing subdirectory pattern" >> $@; \ - if test $$status -eq 0; then \ - status=1; \ - fi; \ - fi; \ (exit $$status); \ $(evaluate-test) diff --git a/elf/dl-hwcaps.c b/elf/dl-hwcaps.c index 92eb5379..ae2423eb 100644 --- a/elf/dl-hwcaps.c +++ b/elf/dl-hwcaps.c @@ -170,17 +170,7 @@ _dl_important_hwcaps (const char *glibc_hwcaps_prepend, const char *glibc_hwcaps_mask, size_t *sz, size_t *max_capstrlen) { - uint64_t hwcap_mask = GET_HWCAP_MASK(); - /* Determine how many important bits are set. */ - uint64_t masked = GLRO(dl_hwcap) & hwcap_mask; - size_t cnt = GLRO (dl_platform) != NULL; - size_t n, m; - struct r_strlenpair *result; - struct r_strlenpair *rp; - char *cp; - - /* glibc-hwcaps subdirectories. These are exempted from the power - set construction below. */ + /* glibc-hwcaps subdirectories. */ uint32_t hwcaps_subdirs_active = _dl_hwcaps_subdirs_active (); struct hwcaps_counts hwcaps_counts = { 0, }; update_hwcaps_counts (&hwcaps_counts, glibc_hwcaps_prepend, -1, NULL); @@ -193,72 +183,14 @@ _dl_important_hwcaps (const char *glibc_hwcaps_prepend, /* Each hwcaps subdirectory has a GLIBC_HWCAPS_PREFIX string prefix and a "/" suffix once stored in the result. */ hwcaps_counts.maximum_length += strlen (GLIBC_HWCAPS_PREFIX) + 1; - size_t hwcaps_sz = (hwcaps_counts.count * (strlen (GLIBC_HWCAPS_PREFIX) + 1) + size_t total = (hwcaps_counts.count * (strlen (GLIBC_HWCAPS_PREFIX) + 1) + hwcaps_counts.total_length); - /* Count the number of bits set in the masked value. */ - for (n = 0; (~((1ULL << n) - 1) & masked) != 0; ++n) - if ((masked & (1ULL << n)) != 0) - ++cnt; - - /* For TLS enabled builds always add 'tls'. */ - ++cnt; - - /* Create temporary data structure to generate result table. */ - struct r_strlenpair temp[cnt]; - m = 0; - for (n = 0; masked != 0; ++n) - if ((masked & (1ULL << n)) != 0) - { - temp[m].str = _dl_hwcap_string (n); - temp[m].len = strlen (temp[m].str); - masked ^= 1ULL << n; - ++m; - } - if (GLRO (dl_platform) != NULL) - { - temp[m].str = GLRO (dl_platform); - temp[m].len = GLRO (dl_platformlen); - ++m; - } - - temp[m].str = "tls"; - temp[m].len = 3; - ++m; - - assert (m == cnt); - - /* Determine the total size of all strings together. */ - size_t total; - if (cnt == 1) - total = temp[0].len + 1; - else - { - total = temp[0].len + temp[cnt - 1].len + 2; - if (cnt > 2) - { - total <<= 1; - for (n = 1; n + 1 < cnt; ++n) - total += temp[n].len + 1; - if (cnt > 3 - && (cnt >= sizeof (size_t) * 8 - || total + (sizeof (*result) << 3) - >= (1UL << (sizeof (size_t) * 8 - cnt + 3)))) - _dl_signal_error (ENOMEM, NULL, NULL, - N_("cannot create capability list")); - - total <<= cnt - 3; - } - } + *sz = hwcaps_counts.count + 1; - *sz = hwcaps_counts.count + (1 << cnt); - - /* This is the overall result, including both glibc-hwcaps - subdirectories and the legacy hwcaps subdirectories using the - power set construction. */ - total += hwcaps_sz; + /* This is the overall result. */ struct r_strlenpair *overall_result - = malloc (*sz * sizeof (*result) + total); + = malloc (*sz * sizeof (*overall_result) + total); if (overall_result == NULL) _dl_signal_error (ENOMEM, NULL, NULL, N_("cannot create capability list")); @@ -271,110 +203,14 @@ _dl_important_hwcaps (const char *glibc_hwcaps_prepend, copy_hwcaps (&target, glibc_hwcaps_prepend, -1, NULL); copy_hwcaps (&target, _dl_hwcaps_subdirs, hwcaps_subdirs_active, glibc_hwcaps_mask); - /* Set up the write target for the power set construction. */ - result = target.next_pair; - cp = target.next_string; - } - - /* Power set construction begins here. We use a very compressed way - to store the various combinations of capability names. */ - - if (cnt == 1) - { - result[0].str = cp; - result[0].len = temp[0].len + 1; - result[1].str = cp; - result[1].len = 0; - cp = __mempcpy (cp, temp[0].str, temp[0].len); - *cp = '/'; - if (result[0].len > hwcaps_counts.maximum_length) - *max_capstrlen = result[0].len; - else - *max_capstrlen = hwcaps_counts.maximum_length; - - return overall_result; - } - - /* Fill in the information. This follows the following scheme - (indices from TEMP for four strings): - entry #0: 0, 1, 2, 3 binary: 1111 - #1: 0, 1, 3 1101 - #2: 0, 2, 3 1011 - #3: 0, 3 1001 - This allows the representation of all possible combinations of - capability names in the string. First generate the strings. */ - result[1].str = result[0].str = cp; -#define add(idx) \ - cp = __mempcpy (__mempcpy (cp, temp[idx].str, temp[idx].len), "/", 1); - if (cnt == 2) - { - add (1); - add (0); - } - else - { - n = 1 << (cnt - 1); - do - { - n -= 2; - - /* We always add the last string. */ - add (cnt - 1); - - /* Add the strings which have the bit set in N. */ - for (m = cnt - 2; m > 0; --m) - if ((n & (1 << m)) != 0) - add (m); - - /* Always add the first string. */ - add (0); - } - while (n != 0); - } -#undef add - - /* Now we are ready to install the string pointers and length. */ - for (n = 0; n < (1UL << cnt); ++n) - result[n].len = 0; - n = cnt; - do - { - size_t mask = 1 << --n; - - rp = result; - for (m = 1 << cnt; m > 0; ++rp) - if ((--m & mask) != 0) - rp->len += temp[n].len + 1; - } - while (n != 0); - - /* The first half of the strings all include the first string. */ - n = (1 << cnt) - 2; - rp = &result[2]; - while (n != (1UL << (cnt - 1))) - { - if ((--n & 1) != 0) - rp[0].str = rp[-2].str + rp[-2].len; - else - rp[0].str = rp[-1].str; - ++rp; - } - - /* The second half starts right after the first part of the string of - the corresponding entry in the first half. */ - do - { - rp[0].str = rp[-(1 << (cnt - 1))].str + temp[cnt - 1].len + 1; - ++rp; - } - while (--n != 0); + /* Append an empty entry for the base directory itself. */ + target.next_pair->str = target.next_string; + target.next_pair->len = 0; + } /* The maximum string length. */ - if (result[0].len > hwcaps_counts.maximum_length) - *max_capstrlen = result[0].len; - else - *max_capstrlen = hwcaps_counts.maximum_length; + *max_capstrlen = hwcaps_counts.maximum_length; return overall_result; } diff --git a/elf/dl-usage.c b/elf/dl-usage.c index 98d8c989..efd6c77c 100644 --- a/elf/dl-usage.c +++ b/elf/dl-usage.c @@ -193,37 +193,6 @@ print_hwcaps_subdirectories (const struct dl_main_state *state) No subdirectories of glibc-hwcaps directories are searched.\n"); } -/* Write a list of hwcap subdirectories to standard output. See - _dl_important_hwcaps in dl-hwcaps.c. */ -static void -print_legacy_hwcap_directories (void) -{ - _dl_printf ("\n\ -Legacy HWCAP subdirectories under library search path directories:\n"); - - const char *platform = GLRO (dl_platform); - if (platform != NULL) - _dl_printf (" %s (AT_PLATFORM; supported, searched)\n", platform); - - _dl_printf (" tls (supported, searched)\n"); - - uint64_t hwcap_mask = GET_HWCAP_MASK(); - uint64_t searched = GLRO (dl_hwcap) & hwcap_mask; - for (int n = 63; n >= 0; --n) - { - uint64_t bit = 1ULL << n; - if (HWCAP_IMPORTANT & bit) - { - _dl_printf (" %s", _dl_hwcap_string (n)); - bool first = true; - print_hwcap_1 (&first, GLRO (dl_hwcap) & bit, "supported"); - print_hwcap_1 (&first, !(hwcap_mask & bit), "masked"); - print_hwcap_1 (&first, searched & bit, "searched"); - print_hwcap_1_finish (&first); - } - } -} - void _dl_help (const char *argv0, struct dl_main_state *state) { @@ -270,6 +239,5 @@ This program interpreter self-identifies as: " RTLD "\n\ argv0); print_search_path_for_help (state); print_hwcaps_subdirectories (state); - print_legacy_hwcap_directories (); _exit (EXIT_SUCCESS); } From patchwork Sat Sep 17 14:19:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Pello X-Patchwork-Id: 57718 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DFEAC385275B for ; Sat, 17 Sep 2022 14:21:22 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by sourceware.org (Postfix) with ESMTPS id A29E0385C400 for ; Sat, 17 Sep 2022 14:21:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A29E0385C400 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=otheo.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=otheo.eu Received: (Authenticated sender: #01#@otheo.eu) by mail.gandi.net (Postfix) with ESMTPSA id 02EE5100002 for ; Sat, 17 Sep 2022 14:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=otheo.eu; s=gm1; t=1663424468; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k/uH6NeQ1beI3VhnKFAnBCy9ktojNGqY0q6IF1gtzpU=; b=NvU3ClwSbVZj0lUwO4ub3/Ezl8UN50kUpea7lNGR6XFMjyCvvy9oMgOgHo/jVD/KBhFxEc xEgfd9VI18ShjdF0ZHj4+c0pvDz41+PQi28rXsmFL2CUAiWmDcuL48t6G/mkaXTrMQBSlU 62LjgTA2zXroCkuoCcxYFw6WzSINF7pSltcY6rPvBwCUfMpbC+9oVlKPJR0leEGt3Ucq8p /sq6c3FgrX5SzZ9F26iezGKe2oGJnq/ydNmGO2GaBDbXVPOuAviDW6+wgp2FT34Ga5LUDe vT+KC9rEht4/DQwKJWwW6/QAiNz6JCUr0p+V+6mSC/Bf6m3fFbEasao7PSFQGg== Date: Sat, 17 Sep 2022 16:19:49 +0200 From: Javier Pello To: libc-alpha@sourceware.org Subject: [PATCH v2 2/6] elf: Remove legacy hwcaps support from ldconfig Message-Id: <20220917161949.c555288a52d870ef80b95126@otheo.eu> In-Reply-To: <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> References: <20220905200652.d69204581d15c64647da5cd2@otheo.eu> <87h71l9crb.fsf@oldenburg.str.redhat.com> <20220906201207.e7b3d08272af5649754e76b1@otheo.eu> <87h71i6rfa.fsf@oldenburg.str.redhat.com> <20220914200724.8e685fbbaf441c96d19011c6@otheo.eu> <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; i686-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Remove support for the legacy hwcaps subdirectories from ldconfig. Signed-off-by: Javier Pello --- elf/ldconfig.c | 149 +++---------------------------------------------- 1 file changed, 8 insertions(+), 141 deletions(-) diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 6f37f38f..9399c228 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -46,16 +46,6 @@ #include -/* This subpath in search path entries is always supported and - included in the cache for backwards compatibility. */ -#define TLS_SUBPATH "tls" - -/* The MSB of the hwcap field is set for objects in TLS_SUBPATH - directories. There is always TLS support in glibc, so the dynamic - loader does not check the bit directly. But more hwcap bits make a - an object more preferred, so the bit still has meaning. */ -#define TLS_HWCAP_BIT 63 - #ifndef LD_SO_CONF # define LD_SO_CONF SYSCONFDIR "/ld.so.conf" #endif @@ -120,9 +110,6 @@ static char *cache_file; /* Configuration file. */ static const char *config_file; -/* Mask to use for important hardware capabilities. */ -static unsigned long int hwcap_mask = HWCAP_IMPORTANT; - /* Name and version of program. */ static void print_version (FILE *stream, struct argp_state *state); void (*argp_program_version_hook) (FILE *, struct argp_state *) @@ -163,75 +150,6 @@ static struct argp argp = options, parse_opt, NULL, doc, NULL, more_help, NULL }; -/* Check if string corresponds to an important hardware capability or - a platform. */ -static int -is_hwcap_platform (const char *name) -{ - int hwcap_idx = _dl_string_hwcap (name); - - /* Is this a normal hwcap for the machine like "fpu?" */ - if (hwcap_idx != -1 && ((1 << hwcap_idx) & hwcap_mask)) - return 1; - - /* Is this a platform pseudo-hwcap like "i686?" */ - hwcap_idx = _dl_string_platform (name); - if (hwcap_idx != -1) - return 1; - - /* Backwards-compatibility for the "tls" subdirectory. */ - if (strcmp (name, TLS_SUBPATH) == 0) - return 1; - - return 0; -} - -/* Get hwcap (including platform) encoding of path. */ -static uint64_t -path_hwcap (const char *path) -{ - char *str = xstrdup (path); - char *ptr; - uint64_t hwcap = 0; - uint64_t h; - - size_t len; - - len = strlen (str); - if (str[len] == '/') - str[len] = '\0'; - - /* Search pathname from the end and check for hwcap strings. */ - for (;;) - { - ptr = strrchr (str, '/'); - - if (ptr == NULL) - break; - - h = _dl_string_hwcap (ptr + 1); - - if (h == (uint64_t) -1) - { - h = _dl_string_platform (ptr + 1); - if (h == (uint64_t) -1) - { - if (strcmp (ptr + 1, TLS_SUBPATH) == 0) - h = TLS_HWCAP_BIT; - else - break; - } - } - hwcap += 1ULL << h; - - /* Search the next part of the path. */ - *ptr = '\0'; - } - - free (str); - return hwcap; -} - /* Handle program arguments. */ static error_t parse_opt (int key, char *arg, struct argp_state *state) @@ -747,27 +665,15 @@ struct dlib_entry static void search_dir (const struct dir_entry *entry) { - uint64_t hwcap; - if (entry->hwcaps == NULL) - { - hwcap = path_hwcap (entry->path); - if (opt_verbose) - { - if (hwcap != 0) - printf ("%s: (hwcap: %#.16" PRIx64 ")", entry->path, hwcap); - else - printf ("%s:", entry->path); - } - } - else + if (opt_verbose) { - hwcap = 0; - if (opt_verbose) + if (entry->hwcaps == NULL) + printf ("%s:", entry->path); + else printf ("%s: (hwcap: \"%s\")", entry->path, glibc_hwcaps_subdirectory_name (entry->hwcaps)); + printf (_(" (from %s:%d)\n"), entry->from_file, entry->from_line); } - if (opt_verbose) - printf (_(" (from %s:%d)\n"), entry->from_file, entry->from_line); char *dir_name; char *real_file_name; @@ -813,9 +719,7 @@ search_dir (const struct dir_entry *entry) subdirectory)? The dynamic linker is also considered as shared library. */ if (!_dl_is_dso (direntry->d_name) - && (direntry->d_type == DT_REG - || (entry->hwcaps == NULL - && !is_hwcap_platform (direntry->d_name)))) + && (direntry->d_type == DT_REG || entry->hwcaps == NULL)) continue; size_t len = strlen (direntry->d_name); @@ -863,7 +767,6 @@ search_dir (const struct dir_entry *entry) } struct stat stat_buf; - bool is_dir; int is_link = S_ISLNK (lstat_buf.st_mode); if (is_link) { @@ -898,37 +801,13 @@ search_dir (const struct dir_entry *entry) if (opt_chroot != NULL) free (target_name); - is_dir = S_ISDIR (stat_buf.st_mode); - /* lstat_buf is later stored, update contents. */ lstat_buf.st_dev = stat_buf.st_dev; lstat_buf.st_ino = stat_buf.st_ino; lstat_buf.st_size = stat_buf.st_size; lstat_buf.st_ctime = stat_buf.st_ctime; } - else - is_dir = S_ISDIR (lstat_buf.st_mode); - - /* No descending into subdirectories if this directory is a - glibc-hwcaps subdirectory (which are not recursive). */ - if (entry->hwcaps == NULL - && is_dir && is_hwcap_platform (direntry->d_name)) - { - if (!is_link - && direntry->d_type != DT_UNKNOWN - && __builtin_expect (lstat (real_file_name, &lstat_buf), 0)) - { - error (0, errno, _("Cannot lstat %s"), file_name); - continue; - } - - /* Handle subdirectory later. */ - struct dir_entry *new_entry = new_sub_entry (entry, file_name, - &lstat_buf); - add_single_dir (new_entry, 0); - continue; - } - else if (!S_ISREG (lstat_buf.st_mode) && !is_link) + else if (!S_ISREG (lstat_buf.st_mode)) continue; char *real_name; @@ -1103,7 +982,7 @@ search_dir (const struct dir_entry *entry) } if (opt_build_cache) add_to_cache (entry->path, filename, dlib_ptr->soname, - dlib_ptr->flag, dlib_ptr->isa_level, hwcap, + dlib_ptr->flag, dlib_ptr->isa_level, 0, entry->hwcaps); } @@ -1290,16 +1169,6 @@ parse_conf_include (const char *config_file, unsigned int lineno, free (copy); } -/* Honour LD_HWCAP_MASK. */ -static void -set_hwcap (void) -{ - char *mask = getenv ("LD_HWCAP_MASK"); - - if (mask) - hwcap_mask = strtoul (mask, NULL, 0); -} - int main (int argc, char **argv) @@ -1332,8 +1201,6 @@ main (int argc, char **argv) add_dir_1 (argv[i], "", 0); } - set_hwcap (); - if (opt_chroot != NULL) { /* Normalize the path a bit, we might need it for printing later. */ From patchwork Sat Sep 17 14:20:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Pello X-Patchwork-Id: 57719 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EFC603831DD1 for ; Sat, 17 Sep 2022 14:22:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by sourceware.org (Postfix) with ESMTPS id 41FF23851C04 for ; Sat, 17 Sep 2022 14:22:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 41FF23851C04 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=otheo.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=otheo.eu Received: (Authenticated sender: #01#@otheo.eu) by mail.gandi.net (Postfix) with ESMTPSA id E9500E0002 for ; Sat, 17 Sep 2022 14:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=otheo.eu; s=gm1; t=1663424524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i7Z++S4hGkdAeZM0qpLH9d9rwKku6YiuqOCxgwmlLPU=; b=RC4S1bl4a/VrILa/1kTiynpmbC7T03sNy4ueyXcCijXNwk9leE3rQ5MPR+dN9iGf/aTDFN kgoJ6V1Yd/K6JbJ5mXRmMTAtlKCx0TVzhFg74yBj8Iy6Q0/0oF3VEwNnpY9PQS/tIIPz/l GNlW+o0LTU3K3qDi43URQRw0oih5z90VIz1K4ZbrGehZXYmxD2CF2uXmV2jO8UOx3Gzibf w+7tq43YGOiD9YXaRklMnTOXX2Q5/kSHbYENgwRUdQtI6HgVK06L7fC6LTP+TJBtDdEaIt p2KjPRIVpkbQqneTAY3qR9cDCDE8cPMfNZTSvYhP+4GZTXLrlKlhqqO5zu4OmQ== Date: Sat, 17 Sep 2022 16:20:45 +0200 From: Javier Pello To: libc-alpha@sourceware.org Subject: [PATCH v2 3/6] elf: Remove hwcap parameter from add_to_cache signature Message-Id: <20220917162045.56fa6e596f4e2e65b99eec37@otheo.eu> In-Reply-To: <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> References: <20220905200652.d69204581d15c64647da5cd2@otheo.eu> <87h71l9crb.fsf@oldenburg.str.redhat.com> <20220906201207.e7b3d08272af5649754e76b1@otheo.eu> <87h71i6rfa.fsf@oldenburg.str.redhat.com> <20220914200724.8e685fbbaf441c96d19011c6@otheo.eu> <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; i686-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Last commit made it so that the value passed for that parameter was always 0 at its only call site. Signed-off-by: Javier Pello Reviewed-by: Florian Weimer --- elf/cache.c | 16 +++------------- elf/ldconfig.c | 3 +-- sysdeps/generic/ldconfig.h | 2 +- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/elf/cache.c b/elf/cache.c index f5f3ef8c..ecbea2a0 100644 --- a/elf/cache.c +++ b/elf/cache.c @@ -764,7 +764,7 @@ save_cache (const char *cache_name) /* Add one library to the cache. */ void add_to_cache (const char *path, const char *filename, const char *soname, - int flags, unsigned int isa_level, uint64_t hwcap, + int flags, unsigned int isa_level, struct glibc_hwcaps_subdirectory *hwcaps) { struct cache_entry *new_entry = xmalloc (sizeof (*new_entry)); @@ -782,22 +782,12 @@ add_to_cache (const char *path, const char *filename, const char *soname, new_entry->path = path_interned; new_entry->flags = flags; new_entry->isa_level = isa_level; - new_entry->hwcap = hwcap; + new_entry->hwcap = 0; new_entry->hwcaps = hwcaps; new_entry->bits_hwcap = 0; if (hwcaps != NULL) - { - assert (hwcap == 0); - hwcaps->used = true; - } - - /* Count the number of bits set in the masked value. */ - for (size_t i = 0; - (~((1ULL << i) - 1) & hwcap) != 0 && i < 8 * sizeof (hwcap); ++i) - if ((hwcap & (1ULL << i)) != 0) - ++new_entry->bits_hwcap; - + hwcaps->used = true; /* Keep the list sorted - search for right place to insert. */ struct cache_entry *ptr = entries; diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 9399c228..56325c6c 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -982,8 +982,7 @@ search_dir (const struct dir_entry *entry) } if (opt_build_cache) add_to_cache (entry->path, filename, dlib_ptr->soname, - dlib_ptr->flag, dlib_ptr->isa_level, 0, - entry->hwcaps); + dlib_ptr->flag, dlib_ptr->isa_level, entry->hwcaps); } /* Free all resources. */ diff --git a/sysdeps/generic/ldconfig.h b/sysdeps/generic/ldconfig.h index 7cc898db..24222b0f 100644 --- a/sysdeps/generic/ldconfig.h +++ b/sysdeps/generic/ldconfig.h @@ -70,7 +70,7 @@ const char *glibc_hwcaps_subdirectory_name extern void add_to_cache (const char *path, const char *filename, const char *soname, int flags, - unsigned int isa_level, uint64_t hwcap, + unsigned int isa_level, struct glibc_hwcaps_subdirectory *); extern void init_aux_cache (void); From patchwork Sat Sep 17 14:22:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Pello X-Patchwork-Id: 57720 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 56E1E3832D08 for ; Sat, 17 Sep 2022 14:23:43 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by sourceware.org (Postfix) with ESMTPS id 0109138358A5 for ; Sat, 17 Sep 2022 14:23:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0109138358A5 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=otheo.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=otheo.eu Received: (Authenticated sender: #01#@otheo.eu) by mail.gandi.net (Postfix) with ESMTPSA id EC52BE0004 for ; Sat, 17 Sep 2022 14:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=otheo.eu; s=gm1; t=1663424609; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Zwwd9vDytu0guy1j39EHqf1/dT9aTAlbSb1d//TDFEE=; b=nTSHHTdOpwtvzl9xXJwzwGfd/p1l1WhH4MC1LlPc3/6dkws0ggl7r7xwD4xfk/yx8OEU3y aBOLDACt8ovPXY70HEO158jew/XmkXj5e/FVf1tUZ+lLoDY1EwsxVLgon30XEgMBRUPlMI 7EZfcAuF6VujFqW9MoXC+l1oAv0mpTQDEZyYW/OFDSDiPK9G1dtTevmkV+dlL7FofK7C+/ sGzZ6erl06CRsQV1WuX+EpEBMVEVxldzh7jLXMDhoH3qHhFVrh3mNKieXaE0bptc3rF1vl fUgAsU92DhXWCjW/3OAbBzbXB8+YM9InAaFlHYzymGVgzUwfhp2dEsETZbqbbA== Date: Sat, 17 Sep 2022 16:22:10 +0200 From: Javier Pello To: libc-alpha@sourceware.org Subject: [PATCH v2 4/6] elf: Remove hwcap and bits_hwcap fields from struct cache_entry Message-Id: <20220917162210.a1350405571069c399e632f6@otheo.eu> In-Reply-To: <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> References: <20220905200652.d69204581d15c64647da5cd2@otheo.eu> <87h71l9crb.fsf@oldenburg.str.redhat.com> <20220906201207.e7b3d08272af5649754e76b1@otheo.eu> <87h71i6rfa.fsf@oldenburg.str.redhat.com> <20220914200724.8e685fbbaf441c96d19011c6@otheo.eu> <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; i686-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" They were set to 0 on initialisation and never changed later after last commit. Signed-off-by: Javier Pello Reviewed-by: Florian Weimer --- elf/cache.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/elf/cache.c b/elf/cache.c index ecbea2a0..10e61ae4 100644 --- a/elf/cache.c +++ b/elf/cache.c @@ -145,10 +145,8 @@ struct cache_entry struct stringtable_entry *path; /* Path to find library. */ int flags; /* Flags to indicate kind of library. */ unsigned int isa_level; /* Required ISA level. */ - uint64_t hwcap; /* Important hardware capabilities. */ - int bits_hwcap; /* Number of bits set in hwcap. */ - /* glibc-hwcaps subdirectory. If not NULL, hwcap must be zero. */ + /* glibc-hwcaps subdirectory. */ struct glibc_hwcaps_subdirectory *hwcaps; struct cache_entry *next; /* Next entry in list. */ @@ -433,15 +431,6 @@ compare (const struct cache_entry *e1, const struct cache_entry *e2) if (res != 0) return res; } - /* Sort by most specific hwcap. */ - if (e2->bits_hwcap > e1->bits_hwcap) - return 1; - else if (e2->bits_hwcap < e1->bits_hwcap) - return -1; - else if (e2->hwcap > e1->hwcap) - return 1; - else if (e2->hwcap < e1->hwcap) - return -1; } return res; } @@ -547,14 +536,13 @@ save_cache (const char *cache_name) int cache_entry_count = 0; /* The old format doesn't contain hwcap entries and doesn't contain libraries in subdirectories with hwcaps entries. Count therefore - also all entries with hwcap == 0. */ + all entries. */ int cache_entry_old_count = 0; for (entry = entries; entry != NULL; entry = entry->next) { ++cache_entry_count; - if (entry->hwcap == 0) - ++cache_entry_old_count; + ++cache_entry_old_count; } struct stringtable_finalized strings_finalized; @@ -626,7 +614,7 @@ save_cache (const char *cache_name) for (idx_old = 0, idx_new = 0, entry = entries; entry != NULL; entry = entry->next, ++idx_new) { - if (opt_format != opt_format_new && entry->hwcap == 0) + if (opt_format != opt_format_new) { file_entries->libs[idx_old].flags = entry->flags; /* XXX: Actually we can optimize here and remove duplicates. */ @@ -644,7 +632,7 @@ save_cache (const char *cache_name) file_entries_new->libs[idx_new].flags = entry->flags; file_entries_new->libs[idx_new].osversion_unused = 0; if (entry->hwcaps == NULL) - file_entries_new->libs[idx_new].hwcap = entry->hwcap; + file_entries_new->libs[idx_new].hwcap = 0; else file_entries_new->libs[idx_new].hwcap = compute_hwcap_value (entry); @@ -654,9 +642,7 @@ save_cache (const char *cache_name) = str_offset + entry->path->offset; } - /* Ignore entries with hwcap for old format. */ - if (entry->hwcap == 0) - ++idx_old; + ++idx_old; } /* Duplicate last old cache entry if needed. */ @@ -782,9 +768,7 @@ add_to_cache (const char *path, const char *filename, const char *soname, new_entry->path = path_interned; new_entry->flags = flags; new_entry->isa_level = isa_level; - new_entry->hwcap = 0; new_entry->hwcaps = hwcaps; - new_entry->bits_hwcap = 0; if (hwcaps != NULL) hwcaps->used = true; From patchwork Sat Sep 17 14:23:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Pello X-Patchwork-Id: 57721 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 39CA23832D26 for ; Sat, 17 Sep 2022 14:25:07 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by sourceware.org (Postfix) with ESMTPS id 25F0C3858294 for ; Sat, 17 Sep 2022 14:24:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 25F0C3858294 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=otheo.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=otheo.eu Received: (Authenticated sender: #01#@otheo.eu) by mail.gandi.net (Postfix) with ESMTPSA id 2765E100004 for ; Sat, 17 Sep 2022 14:24:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=otheo.eu; s=gm1; t=1663424694; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hFe0LnVq/YAGnxiSI5XWM5cyFd9oC62JmAH7d/dzePI=; b=WYL3HF83ElVTci3Ml96eEZEW9EJXKw0bhulUVQkxc35dcPQQFIYUMBffqsvtizYwZCj0no eEvu46K5mNQ98Oo+MTqRMXQgTrVSShC5xLIwkcuNj91El+tjQrUqzD++V0BT6BAWFEZ7Rm Rj2c4nOosVcVFoVmKkUwP8aTXx2xU27CseS9TbzsUswlBhSaI4E/awI9x1bdY/Uk0VW22P ufYHLqoQoaj1o8G1w8Lz9J3m1AtoogJlQ3GifcOmNDKpR32/Ku9UaD3+zPfSqxvO/pXKuV 60cxVYLGwx1WMuPv6LepCUVjhWjJKDgUa+qRRG4JjUupXHdONSuDtN6GOGgHsA== Date: Sat, 17 Sep 2022 16:23:35 +0200 From: Javier Pello To: libc-alpha@sourceware.org Subject: [PATCH v2 5/6] elf: Remove _dl_string_hwcap Message-Id: <20220917162335.255f717fcde8775a03e5cd95@otheo.eu> In-Reply-To: <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> References: <20220905200652.d69204581d15c64647da5cd2@otheo.eu> <87h71l9crb.fsf@oldenburg.str.redhat.com> <20220906201207.e7b3d08272af5649754e76b1@otheo.eu> <87h71i6rfa.fsf@oldenburg.str.redhat.com> <20220914200724.8e685fbbaf441c96d19011c6@otheo.eu> <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; i686-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Removal of legacy hwcaps support from the dynamic loader left no users of _dl_string_hwcap. Signed-off-by: Javier Pello --- sysdeps/alpha/dl-procinfo.h | 2 -- sysdeps/csky/dl-procinfo.h | 2 -- sysdeps/generic/dl-procinfo.h | 2 -- sysdeps/mips/dl-procinfo.h | 2 -- sysdeps/powerpc/dl-procinfo.h | 10 ---------- sysdeps/s390/dl-procinfo.h | 14 -------------- sysdeps/sparc/dl-procinfo.h | 13 ------------- sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h | 12 ------------ sysdeps/unix/sysv/linux/arm/dl-procinfo.h | 12 ------------ sysdeps/x86/dl-hwcap.h | 14 -------------- 10 files changed, 83 deletions(-) diff --git a/sysdeps/alpha/dl-procinfo.h b/sysdeps/alpha/dl-procinfo.h index 31630fbb..6a12297d 100644 --- a/sysdeps/alpha/dl-procinfo.h +++ b/sysdeps/alpha/dl-procinfo.h @@ -54,6 +54,4 @@ _dl_string_platform (const char *str) /* We don't have any hardware capabilities. */ #define _DL_HWCAP_COUNT 0 -#define _dl_string_hwcap(str) (-1) - #endif /* dl-procinfo.h */ diff --git a/sysdeps/csky/dl-procinfo.h b/sysdeps/csky/dl-procinfo.h index d29e19a9..5da90087 100644 --- a/sysdeps/csky/dl-procinfo.h +++ b/sysdeps/csky/dl-procinfo.h @@ -54,6 +54,4 @@ _dl_string_platform (const char *str) /* We don't have any hardware capabilities. */ #define _DL_HWCAP_COUNT 0 -#define _dl_string_hwcap(str) (-1) - #endif /* dl-procinfo.h */ diff --git a/sysdeps/generic/dl-procinfo.h b/sysdeps/generic/dl-procinfo.h index 8f736e1d..033bcb3e 100644 --- a/sysdeps/generic/dl-procinfo.h +++ b/sysdeps/generic/dl-procinfo.h @@ -34,8 +34,6 @@ /* We don't have any hardware capabilities. */ #define _DL_HWCAP_COUNT 0 -#define _dl_string_hwcap(str) (-1) - #define _dl_string_platform(str) (-1) #endif /* dl-procinfo.h */ diff --git a/sysdeps/mips/dl-procinfo.h b/sysdeps/mips/dl-procinfo.h index 619dc089..25127c36 100644 --- a/sysdeps/mips/dl-procinfo.h +++ b/sysdeps/mips/dl-procinfo.h @@ -54,6 +54,4 @@ _dl_string_platform (const char *str) /* We don't have any hardware capabilities. */ #define _DL_HWCAP_COUNT 0 -#define _dl_string_hwcap(str) (-1) - #endif /* dl-procinfo.h */ diff --git a/sysdeps/powerpc/dl-procinfo.h b/sysdeps/powerpc/dl-procinfo.h index 6ed15610..a0b2d779 100644 --- a/sysdeps/powerpc/dl-procinfo.h +++ b/sysdeps/powerpc/dl-procinfo.h @@ -69,16 +69,6 @@ _dl_hwcap_string (int idx) return GLRO(dl_powerpc_cap_flags)[idx]; } -static inline int -__attribute__ ((unused)) -_dl_string_hwcap (const char *str) -{ - for (int i = 0; i < _DL_HWCAP_COUNT; ++i) - if (strcmp (str, _dl_hwcap_string (i)) == 0) - return i; - return -1; -} - static inline int __attribute__ ((unused, always_inline)) _dl_string_platform (const char *str) diff --git a/sysdeps/s390/dl-procinfo.h b/sysdeps/s390/dl-procinfo.h index e1f88b9a..73aad1fd 100644 --- a/sysdeps/s390/dl-procinfo.h +++ b/sysdeps/s390/dl-procinfo.h @@ -83,20 +83,6 @@ _dl_hwcap_string (int idx) return _dl_s390_cap_flags[idx]; }; -static inline int -__attribute__ ((unused, always_inline)) -_dl_string_hwcap (const char *str) -{ - int i; - - for (i = 0; i < _DL_HWCAP_COUNT; i++) - { - if (strcmp (str, _dl_s390_cap_flags[i]) == 0) - return i; - } - return -1; -}; - static inline int __attribute__ ((unused, always_inline)) _dl_string_platform (const char *str) diff --git a/sysdeps/sparc/dl-procinfo.h b/sysdeps/sparc/dl-procinfo.h index 4a723b53..fa095832 100644 --- a/sysdeps/sparc/dl-procinfo.h +++ b/sysdeps/sparc/dl-procinfo.h @@ -52,19 +52,6 @@ _dl_hwcap_string (int idx) return GLRO(dl_sparc_cap_flags)[idx]; }; -static inline int -__attribute__ ((unused, always_inline)) -_dl_string_hwcap (const char *str) -{ - int i; - for (i = 0; i < _DL_HWCAP_COUNT; i++) - { - if (strcmp (str, GLRO(dl_sparc_cap_flags) [i]) == 0) - return i; - } - return -1; -}; - #include #define HWCAP_IMPORTANT_V9 (__WORDSIZE == 64 ? 0 : HWCAP_SPARC_V9) #define HWCAP_IMPORTANT (HWCAP_IMPORTANT_V9 | HWCAP_SPARC_ULTRA3 \ diff --git a/sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h b/sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h index aa505223..f7382f63 100644 --- a/sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h +++ b/sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h @@ -37,18 +37,6 @@ _dl_hwcap_string (int idx) return (unsigned)idx < _DL_HWCAP_COUNT ? GLRO(dl_aarch64_cap_flags)[idx] : ""; }; -static inline int -__attribute__ ((unused)) -_dl_string_hwcap (const char *str) -{ - for (int i = 0; i < _DL_HWCAP_COUNT; i++) - { - if (strcmp (str, _dl_hwcap_string (i)) == 0) - return i; - } - return -1; -}; - /* There're no platforms to filter out. */ #define _DL_HWCAP_PLATFORM 0 diff --git a/sysdeps/unix/sysv/linux/arm/dl-procinfo.h b/sysdeps/unix/sysv/linux/arm/dl-procinfo.h index 1f4c8c3a..d8c0f262 100644 --- a/sysdeps/unix/sysv/linux/arm/dl-procinfo.h +++ b/sysdeps/unix/sysv/linux/arm/dl-procinfo.h @@ -75,18 +75,6 @@ _dl_procinfo (unsigned int type, unsigned long int word) #define HWCAP_IMPORTANT (HWCAP_ARM_VFP | HWCAP_ARM_NEON) -static inline int -__attribute__ ((unused)) -_dl_string_hwcap (const char *str) -{ - for (int i = 0; i < _DL_HWCAP_COUNT; i++) - { - if (strcmp (str, _dl_hwcap_string (i)) == 0) - return i; - } - return -1; -}; - #define _dl_string_platform(str) (-1) #endif /* dl-procinfo.h */ diff --git a/sysdeps/x86/dl-hwcap.h b/sysdeps/x86/dl-hwcap.h index 26790afc..1313cecd 100644 --- a/sysdeps/x86/dl-hwcap.h +++ b/sysdeps/x86/dl-hwcap.h @@ -57,20 +57,6 @@ _dl_hwcap_string (int idx) return GLRO(dl_x86_hwcap_flags)[idx]; }; -static inline int -__attribute__ ((unused, always_inline)) -_dl_string_hwcap (const char *str) -{ - int i; - - for (i = HWCAP_START; i < HWCAP_COUNT; i++) - { - if (strcmp (str, GLRO(dl_x86_hwcap_flags)[i]) == 0) - return i; - } - return -1; -}; - /* We cannot provide a general printing function. */ #define _dl_procinfo(type, word) -1 From patchwork Sat Sep 17 14:24:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Pello X-Patchwork-Id: 57722 X-Patchwork-Delegate: fweimer@redhat.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C7253830B11 for ; Sat, 17 Sep 2022 14:26:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::222]) by sourceware.org (Postfix) with ESMTPS id 710983831A59 for ; Sat, 17 Sep 2022 14:26:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 710983831A59 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=otheo.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=otheo.eu Received: (Authenticated sender: #01#@otheo.eu) by mail.gandi.net (Postfix) with ESMTPSA id 14A4340009 for ; Sat, 17 Sep 2022 14:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=otheo.eu; s=gm1; t=1663424760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gdna0x4w3Z/JnzXHoMdTX4NhsTYKIwyuNZYwgH9cr9U=; b=kssFneir6QrDeA7U68AWxW+eMF2hd5KWrbgUF73zG9Mz/nSn4MWPqG5qm/L7NEvZIWNmkr qDhT6ZF1IHXSfQCN8sI+apg8y9Gi6ig4P9q5olLlsFTqFB1yg797JrS7xDSdBYdG7qihPi zbSpzOPkZNg6Hp8Pdx8lz3PDnQrPJNf3iZwkSt2EYMLjr3Weao73k06TTqC4zkWOCyPKTF SyQaummCSAxJPWLHZMBSaLVOvDM/1A7ZhGn8PHHKgjK6D6I16wtCLpHJsu66hoPQvs2+xX l19RCILzj8xJRtWs2YuPCnsDW29qsLkx3cyaHVs5Jjzik7Ts/gLNUuGWZtl+rg== Date: Sat, 17 Sep 2022 16:24:41 +0200 From: Javier Pello To: libc-alpha@sourceware.org Subject: [PATCH v2 6/6] elf: Simplify output of hwcap subdirectories in ld.so help Message-Id: <20220917162441.713b2dfcbc3588b902722545@otheo.eu> In-Reply-To: <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> References: <20220905200652.d69204581d15c64647da5cd2@otheo.eu> <87h71l9crb.fsf@oldenburg.str.redhat.com> <20220906201207.e7b3d08272af5649754e76b1@otheo.eu> <87h71i6rfa.fsf@oldenburg.str.redhat.com> <20220914200724.8e685fbbaf441c96d19011c6@otheo.eu> <20220917161748.2b76e1731a27eb78880ee57c@otheo.eu> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; i686-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The print_hwcap_1 machinery was useful for the legacy hwcaps subdirectories, but it is not worth the trouble now that they are gone. Signed-off-by: Javier Pello --- elf/dl-usage.c | 43 +++++++------------------------------------ 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/elf/dl-usage.c b/elf/dl-usage.c index efd6c77c..754a6391 100644 --- a/elf/dl-usage.c +++ b/elf/dl-usage.c @@ -104,34 +104,6 @@ print_search_path_for_help (struct dl_main_state *state) print_search_path_for_help_1 (__rtld_search_dirs.dirs); } -/* Helper function for printing flags associated with a HWCAP name. */ -static void -print_hwcap_1 (bool *first, bool active, const char *label) -{ - if (active) - { - if (*first) - { - _dl_printf (" ("); - *first = false; - } - else - _dl_printf (", "); - _dl_printf ("%s", label); - } -} - -/* Called after a series of print_hwcap_1 calls to emit the line - terminator. */ -static void -print_hwcap_1_finish (bool *first) -{ - if (*first) - _dl_printf ("\n"); - else - _dl_printf (")\n"); -} - /* Print the header for print_hwcaps_subdirectories. */ static void print_hwcaps_subdirectories_header (bool *nothing_printed) @@ -165,9 +137,7 @@ print_hwcaps_subdirectories (const struct dl_main_state *state) { print_hwcaps_subdirectories_header (¬hing_printed); print_hwcaps_subdirectories_name (&split); - bool first = true; - print_hwcap_1 (&first, true, "searched"); - print_hwcap_1_finish (&first); + _dl_printf (" (searched)\n"); } /* The built-in glibc-hwcaps subdirectories. Do the filtering @@ -178,13 +148,14 @@ print_hwcaps_subdirectories (const struct dl_main_state *state) { print_hwcaps_subdirectories_header (¬hing_printed); print_hwcaps_subdirectories_name (&split); - bool first = true; - print_hwcap_1 (&first, mask & 1, "supported"); bool listed = _dl_hwcaps_contains (state->glibc_hwcaps_mask, split.segment, split.length); - print_hwcap_1 (&first, !listed, "masked"); - print_hwcap_1 (&first, (mask & 1) && listed, "searched"); - print_hwcap_1_finish (&first); + if (mask & 1) + _dl_printf (" (supported, %s)\n", listed ? "searched" : "masked"); + else if (!listed) + _dl_printf (" (masked)\n"); + else + _dl_printf ("\n"); mask >>= 1; }