Subject: Re: When is ELF coming?
To: Curt Sampson <cjs@portal.ca>
From: Frank van der Linden <frank@fwi.uva.nl>
List: tech-kern
Date: 11/24/1996 12:15:29
The problem with ELF is, that the designers seemed to have one OS with
one ABI in mind (SVR4). Then people started using it with more OSs,
and things got out of hand.

In theory, you could hide everything in libc.so.. if everyone had
the same set of function in libc, with the same set of parameters.
Suuure.. that's likely :-)

Quoting Curt Sampson,

> This may be a stupid question, but my ELF docs haven't arrived yet,
> so I'm working only on what I've seen in Chapter 6 of Pate's _Unix
> Internals_ (which describes SCO). However: if there is a PT_INTERP
> program header, this contains the pathname to the dynamic linker,
> right? This means that, assuming different systems have different
> pathnames naming the dynamic linker, we can easily distinguish
> between ELF binaries from different systems, right?

Unfortunately, you're currently pretty much stuck doing this. It's
a bad way of doing things, the path to the interpreter effectively
functions as an OS identification. Linux has the following in the kernel
sources:

                        /* If the program interpreter is one of these two,
                           then assume an iBCS2 image. Otherwise assume
                           a native linux image. */
                        if (strcmp(elf_interpreter,"/usr/lib/libc.so.1") == 0 ||
                            strcmp(elf_interpreter,"/usr/lib/ld.so.1") == 0)
                          ibcs2_interpreter = 1;

Well, call me strange, but I think this should not be in a kernel. Currently,
the emulations using ELF try to see if the interpreter specified in the
PT_INTERP section exists, if not, they return ENOEXEC, which gets you
off the hook in most cases too. This is slightly different and better, but
it's still a bad thing to have to do. The Linux emulation also looks
for a GNU signature, since it's safe to assume all Linux binaries have
been linked with GNU ld.

As you can see, seeing which OS the binary is for is a huge problem,
and needs to be solved properly. An OS type field is really needed.
ELF is unsuited for cross-OS use until then. I'm not sure what the people
were thinking when they designed this.. I can only assume they had
just one target OS in mind.

- Frank