Subject: Re: FreeBSD binary emulation failing (cannot execute 'ldd-freebsd')
To: NetBSD-help list <netbsd-help@netbsd.org>
From: Rogier Krieger <rogier@virgiel.nl>
List: netbsd-users
Date: 07/08/2003 21:51:05
Hi there Ambarish,

thanks for the pointers. Before posting, I saw your suggestion of adding
the ld-elf.so library to my freebsd-emul tree, but I still ended up with
the same error. Even adding the emulation tree directories to the
LD_LIBRARY_PATH variable did not work.

Perhaps I should make clear which things I did before trying to
run the binaries/ldd-freebsd. (ldd-freebsd is only the name of
the freebsd-version ldd on my system). Maybe it sheds some
light on where things go wrong.

I run a GENERIC kernel, so COMPAT_FREEBSD shoudn't be a problem.
The ldconfig-freebsd runs fine, so that part is covered.

I installed the pkgsrc 'emulators/freebsd_lib' package. This
went off without a hitch.

Following the compat_freebsd man page, I further populated the
/usr/pkg/emul/freebsd tree (/emul/freebsd is a symlink).

I copied the following libraries (from a FreeBSD-4.7 release box) to
the same location on my NetBSD (under the /emul/freebsd tree) system.

/usr/lib/*.so.*	(tar'ed, to conserve symlinks)
/usr/libexec/ld-elf.so.1
/usr/bin/ldd
/sbin/ldconfig

For ldd and ldconfig, I created ldd-freebsd and ldconfig-freebsd copies
in /usr/local/bin (regular NetBSD tree, not /emul/freebsd).

I also created the /var/run/ld-elf.so.hints and /var/run/ld.so.hints files
(in /emul/freebsd) and re-ran ldconfig-freebsd with both the -aout and
directory arguments. Running ldconfig-freebsd now yields:

root@karres:/usr/pkg/emul/freebsd# ldconfig-freebsd -r -aout
/var/run/ld.so.hints:
        search directories:
/usr/lib/aout:/usr/lib/compat/aout:/usr/X11R6/lib/aout

root@karres:/usr/pkg/emul/freebsd# ldconfig-freebsd -r      
/var/run/ld-elf.so.hints:
        search directories:
/usr/lib:/usr/local/lib:/usr/X11R6/lib:/usr/libexec
        0:-lc.4 => /usr/lib/libc.so.4
        <snip> A whole list of modules, as copied from the FreeBSD system
</snip>
        66:-lz.2 => /usr/lib/libz.so.2


Still I get the 'cannot execute' error trying to run ldd-freebsd (or the
in-tree version:
/emul/freebsd/usr/bin/ldd). Am I missing something obvious or something
broken?

Any insight is greatly appreciated,

Rogier Krieger