Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jan 2007 16:53:21 +0100
From:      Tijl Coosemans <tijl@ulyssis.org>
To:        freebsd-current@freebsd.org
Cc:        Boris Samorodov <bsam@ipt.ru>, Alexander Leidinger <Alexander@leidinger.net>, Divacky Roman <xdivac02@stud.fit.vutbr.cz>
Subject:   Re: broken linuxulator in -current as of Jan 8 17:51:45 CET
Message-ID:  <200701101653.25773.tijl@ulyssis.org>
In-Reply-To: <20070110132101.k8zzn281ic8w04ks@webmail.leidinger.net>
References:  <20070108165157.GA94941@stud.fit.vutbr.cz> <200701101151.51662.tijl@ulyssis.org> <20070110132101.k8zzn281ic8w04ks@webmail.leidinger.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday 10 January 2007 13:21, Alexander Leidinger wrote:
> Quoting Tijl Coosemans <tijl@ulyssis.org>
>> On Wednesday 10 January 2007 07:53, Alexander Leidinger wrote:
>>> That's not possible. The way the linuxulator works is:
>>>   - the linker in userland calls open("/foo/bar")
>>>   - kernel looks for "/compat/linux/foo/bar"
>>>     * it is there -> return it
>>>     * it is not there -> look for "/foo/bar"
>>>       + if it is there -> return it
>>>       + if it is not there -> return error
>>>   - the userland get's something which may be linux or FreeBSD stuff
>>>   - the linker read()s this
>>>   - the linker sees a wrong ELF ABI and bails out
>>
>> That means the linker tries to open /usr/lib/librt.so.1 instead of
>> /lib/librt.so.1 which doesn't exist under /compat/linux. So I added a
>> symlink there.
>>
>> ln -s ../../lib/librt-2.3.6.so /compat/linux/usr/lib/librt.so.1
>>
>> And now everything works.
>>
>> % ldd /compat/linux/bin/ls
>> /compat/linux/bin/ls:
>>         librt.so.1 => /lib/obsolete/linuxthreads/librt.so.1 (0x4807c000)
>>
>> I think this is an easier solution than changing the runtime linker.
> 
> Does it still work with 2.6.16 (can't test ATM)? If yes: I agree, it
> is more easy and we can change this in the linux base port very fast

Yes, it works with 2.6.16. Here's what I think is happening:

ls is linked against librt.so.1 with /lib and /usr/lib as runtime
search paths and thus:

- linker calls open("/lib/librt.so.1")
- kernel returns "/compat/linux/lib/librt.so.1"
- linker reads and sees it requires kernel ABI 2.4.20
  * when osrelease=2.6.16, this is ok, all done
  * when osrelease=2.4.2
    + linker calls open("/usr/lib/librt.so.1")
    + kernel returns "/compat/linux/usr/lib/librt.so.1" (symlink)
      (previously kernel returned FreeBSD "/usr/lib/librt.so.1" here,
       which caused linker error)
    + linker reads and sees it requires kernel ABI 2.4.20, not ok
    + linker calls open("/lib/obsolete/linuxthreads/librt.so.1")
    + kernel returns "/compat/linux/lib/obsolete/linuxthreads/librt.so.1"
    + linker reads and sees it requires kernel ABI 2.2.5, ok, all done



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701101653.25773.tijl>