From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-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-Spam-SWARE-Status: No, score=-22.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=dig, dlopen 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== Return-Path: 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 20:39:00 -0000 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 X-SW-Source: 2020-01/txt/msg00517.txt.bz2 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'.