From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe29.google.com (mail-vs1-xe29.google.com [IPv6:2607:f8b0:4864:20::e29]) by sourceware.org (Postfix) with ESMTPS id C76213858D38 for ; Mon, 3 Oct 2022 15:31:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C76213858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-vs1-xe29.google.com with SMTP id k6so11703528vsc.8 for ; Mon, 03 Oct 2022 08:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=Ug4VypnNiLkGDxPIPNvwWjHTQ2hzDdZ5SzgKIsLXMRQ=; b=jG/txYxJcfpubm/yi6I26uYmXpGFC25U5wOYXZzVuGJgHojXjdDX6+H/s7aVm0GK9S 5IN3sFVnK5uSo1U5JJGYcy7a9ohDlu6T1MDvS530TuGCOfdYkbkRxCerx7jPYvAi1Ra4 kkup8uhPZK20IwNn29V1LmtM5p24tQ0ib1ft58BIKrmHCQVZxABcY0s0xgVKIg8fNXSf 69YhHtNSMPhcn9jiOCDgyhjMSB0mMBdRg+iAWPbfrD9yxD+DesqdfeNQY4ShHZjQQBAx J99cQk2WXro4rxm4gE2OSMzhDKQ9394hNmjhEV+mPmkBvLMOw6x+20fSvA/UFiVFf/ZN ITow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=Ug4VypnNiLkGDxPIPNvwWjHTQ2hzDdZ5SzgKIsLXMRQ=; b=aYi4rFFg8FrS/ZY6PDaNSOS0X6pY257AvhhsqP273xxmd99x/X0cjz572AEhDcp7TX zD37JYEjSjEexjx9DASriS5QKw8Jz7KkWCDQnTi+7vjLMSjZ/Mbd+5qgvmYecv02GT1M mxdhO2Yi8zm2bcAZbmhLlc1on/0/7upZzpz4EbjyvOO8nOa8zd+2aULa2QAvcyA4sdfh 0eK0Kh993J7/AgL3ib6VWNjq2jchrP5mdoccHIkLa+gVc9UKY69iALXSnqGBTD3+qqxo Tcevn2ZXtw3kw5pTuBnfoU01WxqITJdeSWoX33eVv6kc1WqLLQQAXrQ5POeZI1kfXMlq Lg8g== X-Gm-Message-State: ACrzQf3QjDVqO4dS6z+7zU4pYsP2+O3/BglT84eObDttTWIXxknupcP6 vD2TLQdt3oW46IjKW70ANJgfSKdrG8BSvCeO X-Google-Smtp-Source: AMsMyM6g5hIVMHNCmwgw3kFqjr6qIofHaVkbNwkGv52CAOjnL8hKMYfM8izi528RbfSlq4L4a1nf4g== X-Received: by 2002:a67:d986:0:b0:3a6:5714:f72b with SMTP id u6-20020a67d986000000b003a65714f72bmr3560450vsj.20.1664811079307; Mon, 03 Oct 2022 08:31:19 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c2:b87d:f936:fc03:6bdb:fa59? ([2804:1b3:a7c2:b87d:f936:fc03:6bdb:fa59]) by smtp.gmail.com with ESMTPSA id s135-20020a1f458d000000b003a9be3e0a34sm4202363vka.13.2022.10.03.08.31.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Oct 2022 08:31:18 -0700 (PDT) Message-ID: <1678195c-4dda-b83e-9365-5f2470271049@linaro.org> Date: Mon, 3 Oct 2022 12:31:16 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v3 3/8] elf: Remove legacy hwcaps support from ldconfig Content-Language: en-US To: Javier Pello , libc-alpha@sourceware.org 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> <20220927200352.0424a12908a437fef9d3a7bc@otheo.eu> <20220927200645.eeb9a0d2c2864f03fec3d1ca@otheo.eu> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20220927200645.eeb9a0d2c2864f03fec3d1ca@otheo.eu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,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 List-Id: On 27/09/22 15:06, Javier Pello wrote: > Remove support for the legacy hwcaps subdirectories from ldconfig. > > Signed-off-by: Javier Pello LGTM, thanks. Reviewed-by: Adhemerval Zanella > --- > elf/ldconfig.c | 155 ++++--------------------------------------------- > 1 file changed, 10 insertions(+), 145 deletions(-) > > diff --git a/elf/ldconfig.c b/elf/ldconfig.c > index 6f37f38f..0d19d847 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; > @@ -808,14 +714,10 @@ search_dir (const struct dir_entry *entry) > && direntry->d_type != DT_REG > && direntry->d_type != DT_DIR) > continue; > - /* Does this file look like a shared library or is it a hwcap > - subdirectory (if not already processing a glibc-hwcaps > - subdirectory)? The dynamic linker is also considered as > - shared library. */ > + /* Does this file look like a shared library? 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 +765,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 +799,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 +980,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 +1167,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 +1199,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. */