Subject: Re: Linux ELF binaries on current
To: None <port-i386@NetBSD.ORG>
From: Christos Zoulas <christos@deshaw.com>
List: port-i386
Date: 10/22/1995 00:54:07
In article <199510211927.PAA14538@baalperazim.frob.com> roland@frob.com (Roland McGrath) writes:
>   > 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.

I don't think that this is a general and workable solution. What happens
when NetBSD gets native elf binaries?

I suggest that Linux starts using the "note" field to indicate that it
is a linux binary. If NetBSD/ELF uses that field too to indicate that this
is a NetBSD binary, then that should identify between the 3 exec formats
using elf.

christos