[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

i386-ELF Portability of statically-linked executables



We agreed that there is some portability of binaries across intel x86's ELF
based  UNIXes (i.e Linux, SCO UNIX and Solaris x86), and that binaries of
one flavour can sometimes run on the different OSes. However, most compiled
executables are dynamically linked with libc and other libraries, and so
the question is what happens if they are not.

An open(), read(), write() or any other system call on an executable which
uses libc as a shared (dynamic) library, is in fact implemented within the
library. Since libc can be, and usually is, different on every platform,
the binary will still work, as long the ELF shared library loading and
calling routines have the same bytecode in all of them.

But what happens if libc is statically linked to an executable? In this
case the system calls code reside within the executable file, and it might
not work if a different code is used on a different platform. 

I downloaded GNU libc and tried to figure how it differs across the
Linux-SCO-Solar86 platforms, but I couldn't understand much of it. Anyway,
as far as my understanding goes, I assume they are implemented by calling
Assembler interrupts, which have handlers within the kernel. And unless
they use exactly the same interrupts and interrupt functions as Linux, they
probably will not function without a heavy emulation layer (e.g. DOS-Emu)

Someone said that the POSIX-compliance is supposed to make sure that even
binaries will be compatible across OSes on the same platform. The 3 OSes
are POSIX compliant, but so are many non-i386 based flavours. Does POSIX
dictates the interrupt numbers to be used and other such binary
information? Or does it just deal with the C function prototypes and the
values of the parameters they receive?

So, what really goes on?

	Shlomi Fish



-----------------------------------------------------------------------------
Shlomi Fish                                Smart Link Ltd.
Home E-mail: shlomif@ibm.net               Work E-mail: shlomi@slink.co.il
Home Page: http://www.slink.co.il/~shlomi

"If I had not been insane already, I would have long ago driven myself mad."

                            The Enemy and how I Helped to Fight it.
-----------------------------------------------------------------------------