From nobody@FreeBSD.org  Tue Oct 18 12:05:21 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CDFF616A41F
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Oct 2005 12:05:21 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 476DF43D48
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Oct 2005 12:05:21 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j9IC5KvE051919
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 18 Oct 2005 12:05:20 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j9IC5Kwi051914;
	Tue, 18 Oct 2005 12:05:20 GMT
	(envelope-from nobody)
Message-Id: <200510181205.j9IC5Kwi051914@www.freebsd.org>
Date: Tue, 18 Oct 2005 12:05:20 GMT
From: Marcin Koziej <creep@desk.pl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Linux binaries need execution of shared libraries (ld.so) under linux emulation
X-Send-Pr-Version: www-2.3

>Number:         87615
>Category:       kern
>Synopsis:       Linux binaries need execution of shared libraries (ld.so) under linux emulation
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 18 12:10:17 GMT 2005
>Closed-Date:    Tue Jan 10 09:21:26 GMT 2006
>Last-Modified:  Sat Feb  4 16:40:03 GMT 2006
>Originator:     Marcin Koziej
>Release:        6.0-RC1
>Organization:
>Environment:
FreeBSD carnivore 6.0-RC1 FreeBSD 6.0-RC1 #0: Wed Oct 12 12:03:21 CEST 2005 creep@carnivore:/home/src/sys/i386/compile/AVI  i386

>Description:
Under linux, libraries can be run as executables.
It is used particuralry with dynamic linker /lib/ld-linux.so.2 (symlink to /lib/ld-2.y.z.so) which is run by ldd, or can be run with an executable as an argument to alternate it's interpreter.
It is also linked to normal executables and has e_type = ET_DYN and e_itent[EI_OSABI]=0.

FreeBSD will not allow running libraries which results with:
/lib/ld-linux.so.2: cannot execute binary file
errors.
( http://docs.freebsd.org/cgi/getmsg.cgi?fetch=23819+0+archive/2001/freebsd-emulation/20010520.freebsd-emulation 
http://lists.freebsd.org/pipermail/freebsd-questions/2004-April/045349.html )
>How-To-Repeat:
Run a library uner linux emulation. In linux running /lib/libc.so.6 gives 

GNU C Library stable release version 2.3.2, by Roland McGrath et al.
Copyright (C) 2003 Free Software Foundation, Inc.
This is free software;(...)
Report bugs using the `glibcbug' script to <bugs@gnu.org>.

and /lib/ld-linux.so
Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]
You have invoked `ld.so', the helper program for shared library executables.
(....)

Under FreeBSD linux emulation:
zsh: exec format error: /compat/linux/lib/libc.so.6
or
sh: /lib/ld-linux.so.2: cannot execute binary file
(message depends on shell)
meaning execve returned ENOEXEC.
>Fix:

The ultimate solution would be to allow execution of shared libraries under linux emulation.

The hacks/workarounds do not fix the problem entirely. 

Changing the e_type to ET_EXEC and e_ident[EI_OSABI] to ELFOSABI_LINUX allows one to execute ld-linux.so, but it breaks linking against ld-linux.so. A workaround can be to make executable copy of ld-linux.so and point ldd to that copy, but this hack is hard to use when one tries to build glibc, because makefiles repeatedly link and execute new ld.so, there is no global variable to specify a different RTLD and sometimes the name ld.so is hardcoded in Makefiles. This can also be true for other applications using ld.so as executable.
>Release-Note:
>Audit-Trail:

From: Maxim Sobolev <sobomax@portaone.com>
To: bug-followup@freebsd.org, creep@desk.pl
Cc:  
Subject: Re: kern/87615: Linux binaries need execution of shared libraries
 (ld.so) under linux emulation
Date: Mon, 26 Dec 2005 03:19:17 -0800

 Hi!
 
 Proposed patch for 7.0-CURRENT is here:
 
 http://www.pbxpress.com/~sobomax/linux_et_dynamic.patch
 
 If there will be no objections and will commit it into 7.0 soon and 
 shortly after that MFC to 6.0/5.0-STABLE.
 
 -Maxim
State-Changed-From-To: open->closed 
State-Changed-By: sobomax 
State-Changed-When: Tue Jan 10 09:20:22 UTC 2006 
State-Changed-Why:  
The fix has been commited into 7-CURRENT, 6-STABLE and 5-STABLE. Thank you for 
reporting! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=87615 

From: hotlips Internet admin <hostmaster@GTS.NET>
To: bug-followup@FreeBSD.org, creep@desk.pl
Cc: freebsd-bugs@FreeBSD.org
Subject: Re: kern/87615
Date: Sat, 4 Feb 2006 11:32:26 -0500 (EST)

 Re: kern/87615: Linux binaries need execution of shared libraries (ld.so)
 under linux emulation
 
 
 It was stated that the fix has been commited into 7-CURRENT,
 6-STABLE and 5-STABLE, but in fact a 6.0-STABLE build does not
 pick up this fix, apparently because it is on a different branch
 (1.7.2.1 RELENG_6) from the version 1.14 committed to MAIN branch.
 
 
 It would be very good to have this patch since we are experiencing
 the problems it deals with ...
 
 
 Thanks,
 Bruce Becker			+1 416 410 0879
 GTS Network Administration	Toronto, Ont.
 Email:	hostmaster@gts.net
>Unformatted:
