This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: [PATCH v3 1/3] elf: Allow dlopen of filter object to work [BZ #16272]
- From: David Kilroy <David dot Kilroy at arm dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>, "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Cc: nd <nd at arm dot com>
- Date: Tue, 21 Jan 2020 15:59:11 +0000
- Subject: RE: [PATCH v3 1/3] elf: Allow dlopen of filter object to work [BZ #16272]
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N5jX8im64yQNzWilSjkcK4zWoUuKdazoc/vTPaxi99k=; b=Cic0INGCULHmX/zWeUOEq5NKlG6cox17/arfLoVcmoSkgHhPb4v7JXVoOHN2qOjOG5oMeOUBcijjRZtB5iHsphqqfa0HLSHQn8ckKQtqFCtB7MHRk2Ma/y/e5FbF3c12s3zuohxYiiHV5d0vW7M/mJqqgMlALYaxOeulhKVmt+NoGCqxJGgjkX/z1fsBf9BJixuxyjWEUczAlJPTAOpYHzY6mF0dWP/k4z7XJeqaHfmZvHVXtTkapEMAEmBEV3uz4hWchd6vmyZDbjiTq2MQwdgT8hz16cwRBSzKogH28EBmcRtJ//piKceDMdrW0Yzu8ju/XRffrcbcdaNfkWVkfQ==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cLzBNZrAT9EvE1jPMFr3nWbQW6zJe+o3RGUo8XdXO7S3Jqx27EXLnI9mI6mJjNCY0liDMbsmd4mOT4oWRuFZ1eq6dCXYnUJezDmH/f63DYd8LHn+63gDdq7FcmI1Oz1fACHUzVXSCiWPEnBXQgRK1NnC7CloSkq3JQR7kEDhILs49WnM8LXUuYPbY/sKjT8B8WtqYeupw18eQQwMITueFAkFdOnxa2s4iVCZ5cmPYOugPskZM0BJmG+mfrw7QLeR4JvSZJd3dqAC1zP2ruYSblKAccVc3eLdECsXb8BifOpi8CUyk6c7/8NI7ve6XxyWwdksd5WFyQQ6XV0S911INg==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=David dot Kilroy at arm dot com;
- 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> <DB6PR0801MB1751580C5C28AC97DA6C4D1991310@DB6PR0801MB1751.eurprd08.prod.outlook.com>
> -----Original Message-----
> From: David Kilroy
> > -----Original Message-----
> > From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> >
> > > 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 :)
Dave.