Subject: Re: Linux ELF binaries on current
To: None <frank@fwi.uva.nl>
From: Roland McGrath <roland@frob.com>
List: port-i386
Date: 10/21/1995 15:27:19
   From: frank@fwi.uva.nl (Frank van der Linden)
   X-Organisation: Faculty of Mathematics, Computer Science, Physics & Astronomy
		   University of Amsterdam
		   Kruislaan 403
		   NL-1098 SJ Amsterdam
		   The Netherlands
   X-Phone:        +31 20 525 7463
   X-Fax:          +31 20 525 7490
   Date: Sat, 21 Oct 1995 20:20:20 +0100 (MET)
   X-Mailer: ELM [version 2.4 PL23]
   MIME-Version: 1.0
   Content-Type: text/plain; charset=US-ASCII
   Content-Transfer-Encoding: 7bit
   Content-Length: 1011      

   Quoting Roland McGrath,

   > Linux ELF binaries make a particular system call (SYS_personality,
   > using the Linux int $0x80 convention) first thing.  This is how SVR4
   > and Linux ELF binaries are distinguished on Linux.  The emulation code
   > could grko this and win if someone wanted to bother hacking it.

   Yeah, I thought about doing this. It would mean adding a piece of
   code like: "We came in through the Linux trap, but this process'
   emul is set to svr4, so it must be Linux ELF binary trying to
   do a personality() call". This ugly hack used in Linux would have
   thus have an ugly solution. It would work in this case. I had a
   discussion with Christos about it, but decided not to do it
   because I was hoping things could be solved in a more general way.
   I sent some mail to the guy who did the Linux code, but got no
   indication that the implementation was going to change. I guess we
   might have to do it the ugly way after all. But the real problem
   is in the lack of OS distinction in the ELF format.

The ELF format is a published USL standard.  Don't hold your breath on
it changing to make it easier to use something other than SVR4.

Since Linux and SVR4 use two different system call conventions (int $0x80
and lcall $7,$0, repsectively), I don't see why both could not be
simultaneously emulated rather than being two separate "emulation modes".
If you get an int $0x80 trap in "ELF mode", then it's a Linux system call.
If you get an lcall $7,$0 trap in "ELF mode", then it's a SVR4 system call.

I believe Linux can also accept lcall $7,$0 system calls, and perhaps some
program you want to run under emulation uses them.  But in that case
probably it makes the "personality" system call, which the emulation code
can use to switch emulation modes.