Porting linux-wine

Ulrich Spoerlein q at galgenberg.net
Fri Oct 28 07:25:12 PDT 2005


On Fri, 28.10.2005 at 15:48:59 +0200, Alexander Leidinger wrote:
> [error]
> 
> You said you branded *all* libs, but libtermcap is still unbranded... is
> there anything obvious which I overlooked?

Yes, the list I grepped was made _before_ branding. I just wanted to
show, that it worked before branding, as it had brand 0. Then after
branding to 3 it stopped working. But see below.

> [libtermcap]
> >It was one of the non-branded libs. So, is branding everything
> >considered bad practice?
> 
> In an ideal Ports Collection, every ELF object which is supposed to be a
> linux object, is branded as such.

Better not! I just found out, that even ICC, which isn't even installed
in /compat/linux will not run, after branding all libs

/usr/local/intel_cc_80/bin/icpcbin: error while loading shared libraries: /lib/libm.so.6: ELF file O
S ABI invalid
*** Error code 127

> A static linux binary has to be branded, else you will shoot yourself in the
> foot (it may cause the system to reboot or do other things you don't want to
> happen). A shared linux ELF object may work as intended, but if you want to
> do it properly, you have to brand them. I vote for doing it properly.

I was thinking along the same lines, but there's obviously something
wrong with this approach, as nearly all linux-apps stopped working here.

> The "find ... brandelf" line is from the linux_base-8 port, althought I only
> brand files in /{,usr/}{,s}bin there... obviously it needs to be extended
> (not only in the linux_base-8 port). Patches are welcome.

I think I can explain why things don't work and the culprit seems to be
/lib/ld-linux.so.2 which won't load libs when they are branded with type
3.

Observe.
% /compat/linux/usr/bin/djpeg
Empty input file
(1)% file /compat/linux/usr/bin/djpeg
/compat/linux/usr/bin/djpeg: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.0.0, dynamical
ly linked (uses shared libs), stripped
% ldd /compat/linux/usr/bin/djpeg
/compat/linux/usr/bin/djpeg:
        libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0x48060000)
        libc.so.6 => /lib/libc.so.6 (0x48083000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x4804d000)
% brandelf /compat/linux/usr/bin/djpeg
File '/compat/linux/usr/bin/djpeg' is of brand 'SVR4' (0).
% brandelf /compat/linux/usr/lib/libjpeg.so.62
File '/compat/linux/usr/lib/libjpeg.so.62' is of brand 'SVR4' (0).

Everything working so far.

% sudo brandelf -t Linux /compat/linux/usr/lib/libjpeg.so.62
% ldd /compat/linux/usr/bin/djpeg
/compat/linux/usr/bin/djpeg:
/compat/linux/usr/bin/djpeg: error while loading shared libraries: /usr/lib/libjpeg.so.62: ELF file OS ABI invalid
/compat/linux/usr/bin/djpeg: exit status 127
(1)% /compat/linux/usr/bin/djpeg
/compat/linux/usr/bin/djpeg: error while loading shared libraries: /usr/lib/libjpeg.so.62: ELF file OS ABI invalid
(127)%

The way I see it (and I don't know nothing about ELF and shared
libraries), the Linuxulator loads the branded binary, ok. Then
ld-linux.so.2 kicks in and tries to load all necessary shared libraries.
But it will only load them, if their brand is '0' (as that is what Linux
uses). So when it encounters a lib with a brand of '3' it will error
out.

Does this make sense? If so, there a two possible fixes:
1) Tell the Linux folks to fix their ld-linux.so so it accepts brand 3
   (is this standardized? Or did the FreeBSD Project make up the number
   '3' here?). Then wait for it to become available in the next
   linux_base and brand *all* binaries and libs.
2) Brand all binaries, that can/will be called directly from FreeBSD.
   Don't touch any libs that ld-linux.so could possibly load.

I then even made some progress with wine. Branding the binaries only I
got this:
wine: failed to initialize: /usr/lib/wine/ntdll.dll.so: failed to map segment from shared object: Cannot allocate memory
which is probably due to the tricks wine plays with the heap. Perhaps,
after all, linux-wine can never possibly work on FreeBSD?

Ulrich Spoerlein
-- 
 PGP Key ID: F0DB9F44				Encrypted mail welcome!
Fingerprint: F1CE D062 0CA9 ADE3 349B  2FE8 980A C6B5 F0DB 9F44
Ok, which part of "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn."
didn't you understand?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-emulation/attachments/20051028/3f28b94c/attachment.bin


More information about the freebsd-emulation mailing list