From owner-freebsd-amd64@FreeBSD.ORG Thu Sep 11 16:38:19 2008 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E51791065676; Thu, 11 Sep 2008 16:38:19 +0000 (UTC) (envelope-from kamikaze@bsdforen.de) Received: from mail.bsdforen.de (bsdforen.de [212.204.60.79]) by mx1.freebsd.org (Postfix) with ESMTP id 9870B8FC21; Thu, 11 Sep 2008 16:38:19 +0000 (UTC) (envelope-from kamikaze@bsdforen.de) Received: from mobileKamikaze.norad (unknown [92.116.185.144]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bsdforen.de (Postfix) with ESMTP id 90E568A000A; Thu, 11 Sep 2008 18:37:42 +0200 (CEST) Message-ID: <48C94943.7010802@bsdforen.de> Date: Thu, 11 Sep 2008 18:37:23 +0200 From: Dominic Fandrey User-Agent: Thunderbird 2.0.0.16 (X11/20080810) MIME-Version: 1.0 To: Rui Paulo References: <200809101744.m8AHiaQq053643@www.freebsd.org> <200809101610.13951.jhb@freebsd.org> <48C8A615.7070800@bsdforen.de> <20080911121058.GA69162@alpha.local> In-Reply-To: <20080911121058.GA69162@alpha.local> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Thu, 11 Sep 2008 17:29:35 +0000 Cc: freebsd-gnats-submit@freebsd.org, freebsd-amd64@freebsd.org Subject: Re: amd64/127276: ldd invokes linux yes X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Sep 2008 16:38:20 -0000 Rui Paulo wrote: > On Thu, Sep 11, 2008 at 07:01:09AM +0200, Dominic Fandrey wrote: >> I don't need it to work, I just need it not to invoke linux binaries. I'm >> using ldd in a script and by ldd not returning 0 the script should know that >> it hasn't encountered a valid binary. Instead ldd opens a linux binary like >> yes and the script spills out ys (yes) or waits for input from stdin >> (md5sum). I'm pretty certain ldd is in no way meant to invoke programs. > > I chatted briefly with John about this. The way our ldd works is by > setting the environment variable TRACE_LOADED_OBJECTS and after some > dlopen() magic it exec()'s the binary. FreeBSD rtld detects the environmental > variable, prints the list of shared objects and quits. > > Linux rtld doesn't work this way, so FreeBSD ldd on a Linux binary will > just run the Linux binary (Linux rtld will ignore the rest). > > Also, ldd wil return 1 on static binaries. Your best bet is to use > file(1) to detect FreeBSD binaries. Something like `file $binary | grep > FreeBSD-style` does the trick. > > Regards, Ok, thanks. I have already created a workaround with readelf, but I'd still consider this a bug in ldd. Shouldn't it check the elf brand if it only works for a single one? Regards