From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id D2C6E3858D32 for ; Mon, 29 Aug 2022 16:40:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D2C6E3858D32 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-ot1-x32c.google.com with SMTP id h20-20020a056830165400b00638ac7ddba5so6275184otr.4 for ; Mon, 29 Aug 2022 09:40:28 -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; bh=QDz8YxtcwTS2ywdprI1GFeiCWE2REypeTzpdC28qlTg=; b=GSFjQ2jp1CfTvdOeUSX4xywwBJ2dNoBnrB5/rGF670p7VaFzSx/2El4nSfpTOW+Ihv GLxI8iVGNlN9txa1i8cLd8XHehFJ4UUhjCYUAsWpa3b4C8kg9PNoHSmy+DBix6aAc0uh OQvvIObU1Ci10S53TJys3SZBZDUSNfobSz2YGf3n7/qs4MNNYCHtv3xlTf6VI7b/M+Kf lI9fsgiD2fD7ryhUjDahfqJ8bnlnQIZu+l9NuroN1jPqjoG3uAfSLNtIrdqLgHBQhu0M 63zQjJQG3mbaDYi+FACiUj3D2OjYRFsEQzMTl5R5W32jzBkYAb2gc801IfK1k8nluBLI ghLw== 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; bh=QDz8YxtcwTS2ywdprI1GFeiCWE2REypeTzpdC28qlTg=; b=o7Riyp1ajmS5uLS71L1CcWczygfMLdCLYaglG9OnCxnbV3zXDSPo4tXdqUu2b1ztw/ wJtD0YUTTUMwG03vfM5Cf80RM4/DPmCenIrXM539K4qnQUQsqGi5/nuD6KcCGLeyyRn6 Dn54ZkZrG33AMqlIuvzgBdLel9I2CcIirSuZWV88DAwGpQdiezTbR280tRzZLqbKZl2e jK1wYuK1ZnO3n73gvyNw2Bw5BCGIcJQ+0dDN9LHvBfIEsdopONEJYJ2O8CAHt7YFFdCA ipAqV6z/xda2XAqsM2XaFdwIkOfznNkk7CfZWCTt2hraNsykLUa8XwOV5chwiuTkZ9uC W5CQ== X-Gm-Message-State: ACgBeo2JO0lfx9AeFxGr7Cn7aUTlXqjRVr0b0GLleffAgMfYiiHput3U gJedAAJGkXB/tXiNoMF7kiKmsovPdA5cQA== X-Google-Smtp-Source: AA6agR7kx+OSJ/K/erScxmOHAU3hnY+0X8Hcy8Eqv7iV/0z38jR/o7oKpesAU6Tf0Y7Dj4orwVfAQw== X-Received: by 2002:a9d:4e05:0:b0:63b:2ab9:fa7e with SMTP id p5-20020a9d4e05000000b0063b2ab9fa7emr2904834otf.281.1661791227203; Mon, 29 Aug 2022 09:40:27 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:745e:189c:ed50:a343:6adf? ([2804:1b3:a7c0:745e:189c:ed50:a343:6adf]) by smtp.gmail.com with ESMTPSA id u41-20020a05687100a900b00118927e0dacsm6346784oaa.4.2022.08.29.09.40.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Aug 2022 09:40:26 -0700 (PDT) Message-ID: <48f6a478-3bb3-a661-6539-f564e2bc3477@linaro.org> Date: Mon, 29 Aug 2022 13:40:24 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH 2/3] elf: Rename _dl_sort_maps parameter from skip to force_first Content-Language: en-US To: Florian Weimer , libc-alpha@sourceware.org References: <73eda777eb55b19db402aad4ead96964cedd7550.1660573629.git.fweimer@redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <73eda777eb55b19db402aad4ead96964cedd7550.1660573629.git.fweimer@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.9 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,T_SCC_BODY_TEXT_LINE 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 15/08/22 11:30, Florian Weimer via Libc-alpha wrote: > The new implementation will not be able to skip an arbitrary number > of objects. LGTM, thanks. Reviewed-by: Adhemerval Zanella > --- > elf/dl-sort-maps.c | 14 +++++++------- > sysdeps/generic/ldsodefs.h | 6 ++++-- > 2 files changed, 11 insertions(+), 9 deletions(-) > > diff --git a/elf/dl-sort-maps.c b/elf/dl-sort-maps.c > index 96638d7ed1..5b550b1e94 100644 > --- a/elf/dl-sort-maps.c > +++ b/elf/dl-sort-maps.c > @@ -27,12 +27,12 @@ > If FOR_FINI is true, this is called for finishing an object. */ > static void > _dl_sort_maps_original (struct link_map **maps, unsigned int nmaps, > - unsigned int skip, bool for_fini) > + bool force_first, bool for_fini) > { > /* Allows caller to do the common optimization of skipping the first map, > usually the main binary. */ > - maps += skip; > - nmaps -= skip; > + maps += force_first; > + nmaps -= force_first; > > /* A list of one element need not be sorted. */ > if (nmaps <= 1) > @@ -182,7 +182,7 @@ dfs_traversal (struct link_map ***rpo, struct link_map *map, > > static void > _dl_sort_maps_dfs (struct link_map **maps, unsigned int nmaps, > - unsigned int skip __attribute__ ((unused)), bool for_fini) > + bool force_first __attribute__ ((unused)), bool for_fini) > { > for (int i = nmaps - 1; i >= 0; i--) > maps[i]->l_visited = 0; > @@ -286,7 +286,7 @@ _dl_sort_maps_init (void) > > void > _dl_sort_maps (struct link_map **maps, unsigned int nmaps, > - unsigned int skip, bool for_fini) > + bool force_first, bool for_fini) > { > /* It can be tempting to use a static function pointer to store and call > the current selected sorting algorithm routine, but experimentation > @@ -296,9 +296,9 @@ _dl_sort_maps (struct link_map **maps, unsigned int nmaps, > input cases. A simple if-case with direct function calls appears to > be the fastest. */ > if (__glibc_likely (GLRO(dl_dso_sort_algo) == dso_sort_algorithm_original)) > - _dl_sort_maps_original (maps, nmaps, skip, for_fini); > + _dl_sort_maps_original (maps, nmaps, force_first, for_fini); > else > - _dl_sort_maps_dfs (maps, nmaps, skip, for_fini); > + _dl_sort_maps_dfs (maps, nmaps, force_first, for_fini); > } > > #endif /* HAVE_TUNABLES. */ > diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h > index 050a3032de..6b256b8388 100644 > --- a/sysdeps/generic/ldsodefs.h > +++ b/sysdeps/generic/ldsodefs.h > @@ -1048,9 +1048,11 @@ extern void _dl_init (struct link_map *main_map, int argc, char **argv, > initializer functions have completed. */ > extern void _dl_fini (void) attribute_hidden; > > -/* Sort array MAPS according to dependencies of the contained objects. */ > +/* Sort array MAPS according to dependencies of the contained objects. > + If FORCE_FIRST, MAPS[0] keeps its place even if the dependencies > + say otherwise. */ > extern void _dl_sort_maps (struct link_map **maps, unsigned int nmaps, > - unsigned int skip, bool for_fini) attribute_hidden; > + bool force_first, bool for_fini) attribute_hidden; > > /* The dynamic linker calls this function before and having changing > any shared object mappings. The `r_state' member of `struct r_debug'