Subject: COMPAT_LINUX/powerpc: mmap'ing dynamic libraries
To: None <tech-kern@netbsd.org>
From: Emmanuel Dreyfus <p99dreyf@criens.u-psud.fr>
List: tech-kern
Date: 01/08/2001 14:20:50
Hi!

I did fix the arguments problem. I can now successfully run a program
like this, statically linked on a LinuxPPC box:

#include <stdio.h>

int main (int argc, char** argv) {
  int i;

  for (i=3D0;i<=3Dargc;i++)=20
    printf("argc[%d]=3D%s\n",i,argv[i]);
=20
  if (argc>=3D2)=20
    return (atoi(argv[1]));
  return 0;
}

So now, I want dynamically linked binaries to run. Now the argument
problem is fixed, Linux's ld.so is able to load dynamic libraries. I
have a few other problems, and I'm looking for ideas about where the
problem exactly is.

Here is the ktrace output for the previous program, dynamically linked:
   171 ktrace   EMUL  "netbsd"
   171 ktrace   RET   ktrace 0
   171 ktrace   CALL  execve(0x7fffeab7,0x7fffea08,0x7fffea14)
   171 ktrace   NAMI  "./arg.dyn"
   171 ktrace   NAMI  "/emul/linux/lib/ld.so.1"
   171 ktrace   NAMI  "/emul/linux"
   171 ktrace   NAMI  "/emul/linux/lib/ld.so.1"
   171 arg.dyn  EMUL  "linux"
   171 arg.dyn  RET   olduname -1 errno -2 No such file or directory
   171 arg.dyn  CALL  getuid
   171 arg.dyn  RET   getuid 500/0x1f4
   171 arg.dyn  CALL  getgid
   171 arg.dyn  RET   getgid 500/0x1f4
   171 arg.dyn  CALL  geteuid
   171 arg.dyn  RET   geteuid 500/0x1f4
   171 arg.dyn  CALL  getegid
   171 arg.dyn  RET   getegid 500/0x1f4
   171 arg.dyn  CALL  brk(0)
   171 arg.dyn  RET   brk 25440256/0x1843000
   171 arg.dyn  CALL  open(0x4188c46c,0,0x3)
   171 arg.dyn  NAMI  "/emul/linux/etc/ld.so.preload"
   171 arg.dyn  NAMI  "/etc/ld.so.preload"
   171 arg.dyn  RET   open -1 errno -2 No such file or directory
   171 arg.dyn  CALL  open(0x7fffe610,0,0xa)
   171 arg.dyn  NAMI  "/emul/linux/usr/lib/libc.so.6"
   171 arg.dyn  NAMI  "/usr/lib/libc.so.6"
   171 arg.dyn  RET   open -1 errno -2 No such file or directory
   171 arg.dyn  CALL  open(0x4188c76c,0,0x1)
   171 arg.dyn  NAMI  "/emul/linux/etc/ld.so.cache"
   171 arg.dyn  NAMI  "/etc/ld.so.cache"
   171 arg.dyn  RET   open -1 errno -2 No such file or directory
   171 arg.dyn  CALL  open(0x7fffe640,0,0xa)
   171 arg.dyn  NAMI  "/emul/linux/lib/libc.so.6"
   171 arg.dyn  NAMI  "/emul/linux"
   171 arg.dyn  NAMI  "/emul/linux/lib/libc.so.6"
   171 arg.dyn  RET   open 3
   171 arg.dyn  CALL  mmap(0,0x1000,0x1,0x2,0x3,0,0x4188dec8,0x1010101)
   171 arg.dyn  RET   mmap 1099223297/0x4184d101
   171 arg.dyn  PSIG  SIGSEGV SIG_DFL
   171 arg.dyn  NAMI  "arg.dyn.core"

What I see here is that Linux's ld.so was successfully launched, and it
successfully found the library we need. But it seems we still have a
problem when mmap'ing the library in memory. I assume I now have to work
on mmap(). Anyone can tell me what can possibly happen here?

Another problem: I never expected this to happen:
   171 arg.dyn  EMUL  "linux"
   171 arg.dyn  RET   olduname -1 errno -2 No such file or directory
=20
This is what I expected:
   171 arg.dyn  EMUL  "linux"
   171 arg.dyn  RET   execve JUSTRETURN

Any idea for this? If it helps, I can submit the new patches in PR
kern/11857...

--=20
Emmanuel Dreyfus.
Windows 95, Windows 98, Windows 2000
D=E9sormais, les OS portent la date de peremption dans leurs noms.
p99dreyf@criens.u-psud.fr