From owner-freebsd-amd64@FreeBSD.ORG Thu Sep 11 12:41:41 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 90C951065672 for ; Thu, 11 Sep 2008 12:41:41 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.24]) by mx1.freebsd.org (Postfix) with ESMTP id 18C6F8FC15 for ; Thu, 11 Sep 2008 12:41:40 +0000 (UTC) (envelope-from rpaulo@gmail.com) Received: by ey-out-2122.google.com with SMTP id 6so137160eyi.7 for ; Thu, 11 Sep 2008 05:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:date:from:to:cc :subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:sender; bh=T3JYCz/+CoVUMQjb5T+mEOusUoFMgNzBh3wEJYbVcgk=; b=TdgywFNwRj1BQXWpgdovMDwLK9RJRjw82jTZJdV91C2xSFk6Wpy/MyXbwVWy0hjcv7 QX+YSSLu2LJZDJI1U1b+h4SQLDW/AKu258QWwHKMpyyQ7ijmaX0yT6KlVtPgqzi6MYHs iXiaVUEkIbhebSZ5S9yoVtPO95/p9wUHHajl4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent:sender; b=LX4OkLHPUAAsCMA+KqEwgvyzWbUAcCuIAYbJ8+UoYLX2mwb5Xfb5gX6eCqd7VT84zS z/SwVOBlPyOPnC7r2BRYjhNXjiRLwxMdwbVEtZ+tDqybngDzBJchESmHRDk/nP2B5nYF v3Aqs1T6iE7mUKNeB2bJCGk/kU8twHf40LQ+I= Received: by 10.210.22.8 with SMTP id 8mr1828049ebv.98.1221135209963; Thu, 11 Sep 2008 05:13:29 -0700 (PDT) Received: from alpha.local ( [83.144.140.92]) by mx.google.com with ESMTPS id g9sm17206080gvc.0.2008.09.11.05.13.28 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 11 Sep 2008 05:13:29 -0700 (PDT) Received: by alpha.local (Postfix, from userid 1001) id 6119F11B99; Thu, 11 Sep 2008 13:10:58 +0100 (WEST) Date: Thu, 11 Sep 2008 13:10:58 +0100 From: Rui Paulo To: Dominic Fandrey Message-ID: <20080911121058.GA69162@alpha.local> References: <200809101744.m8AHiaQq053643@www.freebsd.org> <200809101610.13951.jhb@freebsd.org> <48C8A615.7070800@bsdforen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48C8A615.7070800@bsdforen.de> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: Rui Paulo 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 12:41:41 -0000 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, -- Rui Paulo