From owner-freebsd-amd64@FreeBSD.ORG Thu Sep 11 18:00:15 2008 Return-Path: Delivered-To: freebsd-amd64@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 715DC10656B1 for ; Thu, 11 Sep 2008 18:00:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 63F728FC16 for ; Thu, 11 Sep 2008 18:00:15 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.2/8.14.2) with ESMTP id m8BI0FGK024144 for ; Thu, 11 Sep 2008 18:00:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.2/8.14.1/Submit) id m8BI0FbU024143; Thu, 11 Sep 2008 18:00:15 GMT (envelope-from gnats) Date: Thu, 11 Sep 2008 18:00:15 GMT Message-Id: <200809111800.m8BI0FbU024143@freefall.freebsd.org> To: freebsd-amd64@FreeBSD.org From: John Baldwin Cc: Subject: Re: amd64/127276: ldd invokes linux yes X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: John Baldwin 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 18:00:15 -0000 The following reply was made to PR amd64/127276; it has been noted by GNATS. From: John Baldwin To: Dominic Fandrey Cc: freebsd-amd64@freebsd.org, freebsd-gnats-submit@freebsd.org Subject: Re: amd64/127276: ldd invokes linux yes Date: Thu, 11 Sep 2008 10:38:32 -0400 On Thursday 11 September 2008 01:01:09 am Dominic Fandrey wrote: > John Baldwin wrote: > > On Wednesday 10 September 2008 01:44:36 pm Dominic Fandrey wrote: > >>> Number: 127276 > >>> Category: amd64 > >>> Synopsis: ldd invokes linux yes > >>> Confidential: no > >>> Severity: serious > >>> Priority: medium > >>> Responsible: freebsd-amd64 > >>> State: open > >>> Quarter: > >>> Keywords: > >>> Date-Required: > >>> Class: sw-bug > >>> Submitter-Id: current-users > >>> Arrival-Date: Wed Sep 10 17:50:01 UTC 2008 > >>> Closed-Date: > >>> Last-Modified: > >>> Originator: Dominic Fandrey > >>> Release: RELENG_7 > >>> Organization: > >> private > >>> Environment: > >> FreeBSD mobileKamikaze.norad 7.1-PRERELEASE FreeBSD 7.1-PRERELEASE #0: Fri > > Aug 29 23:22:22 CEST 2008 > > root@mobileKamikaze.norad:/usr/obj/HP6510b/amd64/usr/src/sys/HP6510b amd64 > >>> Description: > >> When ldd is used on linux yes it invokes it instead of producing the usual > > output. > >> # pkg_info -W /compat/linux/usr/bin/yes > >> /compat/linux/usr/bin/yes was installed by package linux_base-f8-8_4 > >> # sysctl compat.linux.osrelease > >> compat.linux.osrelease: 2.6.16 > >> > >> This behaviour breaks pkg_libchk from the sysutils/bsdadminscripts port. > >>> How-To-Repeat: > >> # ldd /compat/linux/usr/bin/yes > > > > ldd is not going to work for Linux binaries. The Linux ldd should be used for > > Linux binaries. > > > > 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. As Rui indicated, ldd always execs binaries. It just sets environment variables that the FreeBSD runtime linker checks for. If the runtime linker sees them, it will modify it's behavior. You can achieve the same thing using env: % ldd /bin/ls /bin/ls: libutil.so.7 => /lib/libutil.so.7 (0x2808b000) libncurses.so.7 => /lib/libncurses.so.7 (0x28099000) libc.so.7 => /lib/libc.so.7 (0x280d8000) % env LD_TRACE_LOADED_OBJECTS=yes /bin/ls libutil.so.7 => /lib/libutil.so.7 (0x2808b000) libncurses.so.7 => /lib/libncurses.so.7 (0x28099000) libc.so.7 => /lib/libc.so.7 (0x280d8000) All the "ldd" printfs, etc. are actually from the runtime linker, not ldd itself. The Linux runtime linker doesn't modify it's behavior for LD_TRACE_LOADED_OBJECTS, so Linux apps just run normally when invoked by ldd. -- John Baldwin