Date: Mon, 15 Jun 2020 11:45:31 -0700 From: John Baldwin <jhb@FreeBSD.org> To: Konstantin Belousov <kib@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r362152 - head/usr.bin/ldd Message-ID: <d50cf8d5-0d99-7cb3-3d7e-4981345c7ee3@FreeBSD.org> In-Reply-To: <202006131821.05DILVnR053798@repo.freebsd.org> References: <202006131821.05DILVnR053798@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 6/13/20 11:21 AM, Konstantin Belousov wrote: > Author: kib > Date: Sat Jun 13 18:21:31 2020 > New Revision: 362152 > URL: https://svnweb.freebsd.org/changeset/base/362152 > > Log: > Fix ldd for PIE binaries after rtld stopped accepting binaries for dlopen. > > ldd proclaims ET_DYN objects as shared libraries and tries to > dlopen(RTLD_TRACE) them to get dependencies. Since PIE binaries are > ET_DYN | DF_1_PIE, refusal to dlopen such binaries breaks ldd. > > Fix it by reading and parsing dynamic segment looking for DF_FLAG_1 > and taking DF_1_PIE into account when deciding between binary and > library. Hmmm, I have an alternate patch for this that instead depends on the present of PT_INTERP (since we already look at program headers) to determine PIE vs not-PIE. This has the advantage of working for older binaries since DF_1_PIE is relatively recent. (I had also changed it to use libelf to reduce code duplication for the 32-bit compat stuff, but it was pending on getting the branding sorted out since it still doesn't fully work for RISC-V and aarch64 shared libraries until they are branded as the patches also look at notes sections to check for the FreeBSD ABI note tag to decide if a shared library is a FreeBSD one that can be passed to dlopen()). -- John Baldwin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d50cf8d5-0d99-7cb3-3d7e-4981345c7ee3>