From owner-freebsd-hackers@FreeBSD.ORG Wed Nov 6 17:13:08 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4FC53D22; Wed, 6 Nov 2013 17:13:08 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 637DD2DEC; Wed, 6 Nov 2013 17:13:07 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.7/8.14.7) with ESMTP id rA6HD1h7095348; Wed, 6 Nov 2013 19:13:01 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.3 kib.kiev.ua rA6HD1h7095348 Received: (from kostik@localhost) by tom.home (8.14.7/8.14.7/Submit) id rA6HD1Cx095347; Wed, 6 Nov 2013 19:13:01 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 6 Nov 2013 19:13:01 +0200 From: Konstantin Belousov To: Mark Johnston Subject: Re: dl_iterate_phdr() omits ld-elf.so Message-ID: <20131106171301.GG59496@kib.kiev.ua> References: <20131106052010.GB2826@raichu> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="i2jtRfQnnEqHm4mE" Content-Disposition: inline In-Reply-To: <20131106052010.GB2826@raichu> User-Agent: Mutt/1.5.22 (2013-10-16) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Nov 2013 17:13:08 -0000 --i2jtRfQnnEqHm4mE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 06, 2013 at 12:20:10AM -0500, Mark Johnston wrote: > Hello, >=20 > While experimenting with dl_iterate_phdr(3), I noticed that it doesn't > include the runtime linker itself in the list of objects. This is > inconsistent with related interfaces such as /map in procfs, and > kinfo_getvmmap(3), so it seems incorrect to me that rtld is excluded > from the list of callback arguments. >=20 > Is there a reason for this behaviour? If not, does anyone have thoughts > on the diff below which fixes this? >=20 > Thanks, > -Mark >=20 > diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c > index fa6dc2a..b55effa 100644 > --- a/libexec/rtld-elf/rtld.c > +++ b/libexec/rtld-elf/rtld.c > @@ -3269,6 +3269,11 @@ dl_iterate_phdr(__dl_iterate_hdr_callback callback= , void *param) > break; > =20 > } > + if (error =3D=3D 0) { > + rtld_fill_dl_phdr_info(&obj_rtld, &phdr_info); > + error =3D callback(&phdr_info, sizeof(phdr_info), param); > + } > + > lock_release(rtld_bind_lock, &bind_lockstate); > lock_release(rtld_phdr_lock, &phdr_lockstate); I cannot make a case where this patch would be problematic, but rtld is very special object in the process address space indeed. The patch is needed exactly because rtld is not included into the list of the loaded objects, and more, symbol resolution from rtld is a special case. Doing dlopen() on rtld path would probably break things in funny way. Still, I think the patch is worth committing, but be prepared to handle the broken cases, which could come out in quite indirect ways. BTW, why do you need this ? --i2jtRfQnnEqHm4mE Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (FreeBSD) iQIcBAEBAgAGBQJSenidAAoJEJDCuSvBvK1B73sP+gIcruqWZrtdXa9QmeBKIQUF RFeurKNDCgx1qx9GNQa5KmzqkXPeAxyZG0D7Tm7hkIyA9sWc4/QU6/0hEYQj5GW/ ZmzVv5ryG6zxdMsxsiKwqL80OjlEFUxMkws5ZxmcEOT+LJXQAGRKSekZCpHtAV7v 7nCMzlwXsCJFT12Dg4qRmCsm119x7BcjdO8mTC88Gtrl0cWijrllz/1bXslGghsn 7OjBozr/QqZ5rs1qSZd4M8Qkw/DudFAW2OqToCvsRm/XHVg0QtAGWF+bgCIngYtX 2vXiYnQituaYcXK4mx8GZBKE6zPy8KjaHPso/MSXukAN1GC7PAVAHbVbUSE10KZo 1MiVWcDjLHsG1iidMXRmVXHUqfigvLCDRPvr+HHvwvMQ5lJ4uQDSFRwOteWpSN5h r/pGlGwZ77FyAJJX9zUbPCsbtfYnGw37OuHwx49+77rKKAqee6IyC7WI6W9n+ElW uPtgf2Gi6qkZKQg/XcObj2XAmg2Usw1E80EdO7RNyM3OMBbU9clb+6JTTMdom5oM xJOg+L3y0KgmgvYhQ6vKm3jNIGuJV+nRguQv1PicgpKKPY3bWphmKa8OeYdsto49 Aul9vtXAJnh58TrbABqz1+GPBouevJ3EKc8z5cQDCMGH8LAIKLj18s2f9UGD+yJm 8i2qhhY7HtOzJ4ah94lR =f+ZW -----END PGP SIGNATURE----- --i2jtRfQnnEqHm4mE--