kern/87615: Linux binaries need execution of shared libraries (ld.so) under linux emulation

Marcin Koziej creep at desk.pl
Tue Oct 18 05:10:30 PDT 2005


>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:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 18 12:10:17 GMT 2005
>Closed-Date:
>Last-Modified:
>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 at 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 at 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:
>Unformatted:


More information about the freebsd-bugs mailing list