From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 1EC541F46C for ; Wed, 22 Jan 2020 20:27:26 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:cc:references:from:subject:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=yFUudiaHtEaS0eax FGGf9s/ME8O/slJEZ/DRAMUT7qNiD7LdqmlL6TRgEdpqxBmnNBsTHWLAzR6XKkPn koFZSHeC4G8W95w4/R2XBSerbaaXurY7aUZXNZAgOz4yh8cXThqeJAxw71SZ/hrV 3Ptry3YbAsCpGWNTD3UDp3jtLXM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:cc:references:from:subject:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=KufOw7Ln8j53NwyyQNXgc6 X8i2s=; b=FiqZmy0Uighg4+uvyhRk8smMDoHj+iDYNuNpBmBzCF/TOoyxWDsRlc znTuOfY3NzJCLkz14eOMmjjIhVMbGZ4Euo0HFnDZXqsKTXpBlC8WeTzfTqDqDU1r LK+gJ3lC/Y1aFiDuumcirNPZMo7v8Xrfe5Yjm9M45cdupWdPDovA0= Received: (qmail 23836 invoked by alias); 22 Jan 2020 20:27:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 23828 invoked by uid 89); 22 Jan 2020 20:27:23 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-qv1-f66.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=to:cc:references:from:autocrypt:subject:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=rvqHZDrek734u0536EkAMizgZMngo4wK2h/SKLEpfIA=; b=T+RSWBZPU7YyKovFxIaFYp9ZBcOUBr3Qd4A8M7Nu7UuFLk7pkM/nIooVMa2gZEkkgX RJRqNurvPQVrHVHRi8Jt5THXMFhOiBszAvZxWKJvlMF8kMIj9OOk7NEIpWPYkMzoFgtS BuiGVwNob+i2eR1RPH0+fp1bDPjMCiPGMV3yjLPAnUM2HMnvJc1jDMhve56grkeyuzjS HdhviMON3XWlZhhm7OFGmOdlpAPP2QA/rUx+yQDQ9vPdp2NOQYWN74HCpDZ32nNWlzir TNUJRDyoq80wMQYymm4CWwSoSd18Nsyfc8VSbvspDV0kvQGnV+LwEHR+i5f8HWLfmu62 KGKA== To: David Kilroy , "libc-alpha@sourceware.org" Cc: nd References: <1575394197-18006-1-git-send-email-david.kilroy@arm.com> <1575394197-18006-2-git-send-email-david.kilroy@arm.com> <2729fb89-bc76-6b15-8f52-50322e6d0307@linaro.org> From: Adhemerval Zanella Subject: Re: [PATCH v3 1/3] elf: Allow dlopen of filter object to work [BZ #16272] Message-ID: <147b54d9-b841-535c-8e79-25ee69baeeb0@linaro.org> Date: Wed, 22 Jan 2020 17:27:16 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 21/01/2020 12:59, David Kilroy wrote: >> -----Original Message----- >> From: David Kilroy >>> -----Original Message----- >>> From: Adhemerval Zanella >>> >>>> diff --git a/elf/dl-deps.c b/elf/dl-deps.c >>>> index c29b988..bb85c83 100644 >>>> --- a/elf/dl-deps.c >>>> +++ b/elf/dl-deps.c >>>> @@ -550,13 +550,14 @@ Filters not supported with >>> LD_TRACE_PRELINKING")); >>>> } >>>> >>>> /* Maybe we can remove some relocation dependencies now. */ >>>> - assert (map->l_searchlist.r_list[0] == map); >>> >>> Ok, the first entry is the filtee object. >>> >>>> struct link_map_reldeps *l_reldeps = NULL; >>>> if (map->l_reldeps != NULL) >>>> { >>>> - for (i = 1; i < nlist; ++i) >>>> + for (i = 0; i < nlist; ++i) >>>> map->l_searchlist.r_list[i]->l_reserved = 1; >>>> >>>> + /* Avoid removing relocation dependencies of the main binary. >>> */ >>>> + map->l_reserved = 0; >>>> struct link_map **list = &map->l_reldeps->list[0]; >>>> for (i = 0; i < map->l_reldeps->act; ++i) >>>> if (list[i]->l_reserved) >>>> @@ -581,16 +582,32 @@ Filters not supported with >>> LD_TRACE_PRELINKING")); >>>> } >>>> } >>>> >>>> - for (i = 1; i < nlist; ++i) >>>> + for (i = 0; i < nlist; ++i) >>>> map->l_searchlist.r_list[i]->l_reserved = 0; >>>> } >>> >>> I am trying to understand why we can't skip first element here. >> Neither >>> of the tests actually exercise this code patch (they won't add a >>> dependency on l_reldeps), so could you provide an example/testcase >>> where it requires such change? >> >> I haven't observed the use case that this code handles. I just tried to >> maintain the existing behaviour that we avoid doing this for the main >> object. >> >> I've been trying to understand what triggers this, but not getting very >> far. >> Does anyone have any hints as to how I need to setup the test so that >> we do >> trigger relocation removals? > > OK, so I git blamed this code to commit c4bb124a75 from 2001. I adapted > elf/relmod5 to include a filter library, and that is working. But it's not > hitting the relocation removal code (checked by adding _dlerror_printfs). > I then ran all tests in the elf directory. Only elf/tst-libc_dlvsym-static and > elf/tst-dlmopen1 enter the for loop, but the l_reserved check is always false. > In both of the above cases map is libc.so.6 and list[i] is libdl.so.2 > > I verified the same is the case without any of my commits applied. > > Have changes elsewhere superseded this? Suggestions as to what I should do > here appreciated :) I am trying to understand how exactly this code is exercised, the l_reldeps will be set by add_dependency function and this is set only on _dl_lookup_symbol for some specific case. I will probably need more time to dig into this, but my understanding so far the this change should not change current semantic since removing the main binary with 'map->l_reserved'.