Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Nov 2013 19:13:01 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Mark Johnston <markj@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: dl_iterate_phdr() omits ld-elf.so
Message-ID:  <20131106171301.GG59496@kib.kiev.ua>
In-Reply-To: <20131106052010.GB2826@raichu>
References:  <20131106052010.GB2826@raichu>

next in thread | previous in thread | raw e-mail | index | archive | help

--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 <pid>/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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20131106171301.GG59496>