Subject: FIXED! Re: Linux emul broken for us
To: None <port-i386@NetBSD.ORG>
From: Brian C. Grayson <bgrayson@ece.utexas.edu>
List: port-i386
Date: 04/25/1997 18:13:31
  I _finally_ figured out what was wrong with our Linux emul setup.
The fix:  set the executable bits on /emul/linux/lib/ld-linux.so.1.
Now everything works like a charm.

  Hopefully someone else can benefit from this.  For some reason,
kernels before October didn't fail when the execute bit wasn't
set.  I didn't see ld-linux.so mentioned anywhere in the
compat_linux man page, and the executable in question doesn't
list ld-linux in its ldd output:

6:09pm:130 file hello
hello: ELF 32-bit LSB executable, Intel 80386, version 1
6:09pm:131 ldd-linux hello
        libc.so.5 => /lib/libc.so.5.2.18

  An ldd-linux on linux's ld.so also doesn't mention ld-linux.so.

  Here's the appropriate snippet from my original post.

Brian C. Grayson wrote:
> 
>   First of all:  NetBSD-i386, running -current.
> 
>   Linux emulation used to be working on our machines -- a kernel
> from early October can run a Linux version of Adobe Acrobat,
> among other things, with no problem.  However, for the past few
> weeks, I haven't been able to get a -current kernel to work.  I
> know I must have done something stupid, and have not been able to
> find my problem so far.
> 
>   More details:
>   I wrote helloworld and compiled it on a Linux machine.  If I
> boot with the October kernel, ktrace says:
>    305 ktrace   RET   ktrace 0
>    305 ktrace   CALL  execve(0xf7bfd4e7,0xf7bfd434,0xf7bfd43c)
>    305 ktrace   NAMI  "./hello"
>    305 ktrace   NAMI  "/emul/linux/lib/ld-linux.so.1"
>    305 ktrace   NAMI  "/emul/linux"
>    305 ktrace   NAMI  "/emul/linux/lib/ld-linux.so.1"
>    305 hello    EMUL  "linux"
>    305 hello    RET   oldolduname 0
>    ...
> and things work fine.
> 
>   With a -current kernel (same machine), ktrace says:
>    289 ktrace   RET   ktrace 0
>    289 ktrace   CALL  execve(0xf7bfd4e7,0xf7bfd434,0xf7bfd43c)
>    289 ktrace   NAMI  "./hello"
>    289 ktrace   NAMI  "/emul/linux/lib/ld-linux.so.1"
>    289 ktrace   NAMI  "/emul/linux"
>    289 ktrace   NAMI  "/emul/linux/lib/ld-linux.so.1"
>    289 ktrace   RET   execve -1 errno 8 Exec format error
>    ...
> and then tries to run /bin/sh on it, which fails.
> 
>   I added zillions of debugging to exec_elf32.c, and found that
> the failure that causes the ENOEXEC stems from load_file in
> exec_elf32.c:384, in the VOP_ACCESS check.

-- 
Brian Grayson (bgrayson@ece.utexas.edu)
Graduate Student, Electrical and Computer Engineering
The University of Texas at Austin
Office:  ENS 406       (512) 471-8011
Finger bgrayson@orac.ece.utexas.edu for PGP key.