386 and 486 binaries observation

Bill White poppa%griggs at slip-4-23.shore.net
Fri Jun 2 00:37:56 EDT 1995


It probably doesn't have anything to do with the x in x86.  There
are several binary formats under Unix -- ZMAGIC and QMAGIC among
them.  I don't remember the differences off the top of my head, and
I don't have the manual page for the a.out format on my machine here.
One of the differences in binary formats is this:

    An a.out binary file looks like this:
    	+----------------------+
    	|   A header, called   |
    	|   the magic header   |
    	+----------------------+
    	|  The binary image of |
    	| the instructions of  |
    	| your program.  This  |
    	| is called the text   |
    	| segment.             |
    	+----------------------+
    	| The binary image of  |
    	| initialized data     |
    	+----------------------+
    	| A sequence of text   |
    	| segment relocation   |
    	| records              |
    	+----------------------+
    	| A sequence of data   |
    	| segment relocation   |
    	| records              |
    	+----------------------+
    	| A table of strings,  |
    	| which holds the names|
    	| of internal and ex-  |
    	| ternal symbols.      |
    	+----------------------+

The magic header has several 32 bit numbers.  The first is the magic
number, which tells what format the file has.  (QMAGIC and ZMAGIC are
among these.)  The others are the sizes of the text and data segments,
and the sizes of the relocation records.  Look in 
/usr/include/linux/a.out.h for a cryptic but precise definition.  The
problem is: what happens if you want to demand load the text segment.
The first byte of the text segment is not on a page boundary.  It's
after the magic header, which is only 32 or so bytes.  The original
a.out format (NMAGIC?) saved an entire page for the magic header,
and put the text segment on page 2 of the binary file.  With 512
byte pages this is not so terrible, but with 8K pages, that wastes
8k bytes per executable.  Another binary format (ZMAGIC?) added the
magic header as the first few bytes of the first page of text
segment.  This uses a small bit of text segment, but saves multiple
megabytes of space in the file system.

As an aside, I believe OMAGIC is for files in which the text segment
is not sharable.  There are others, but I don't know what they are for.

I don't believe there is a way to convert between them, but you could
try to recompile your kernel to understand both formats.  It's surprising
that it doesn't support the newer format already, however.  Presumably
the executables you get now are newer format.  Perhaps you could just
get a newer kernel -- one with boty NMAGIC and ZMAGIC support.

Hope this helps.  I don't want to discourage you from buying a faster
computer.  If this is the excuse you need, don't let me stand in your
way, but I wouldn't think this should stop you from running whatever you
want, albeit slowly.

					Peace,
					Bill White



More information about the Discuss mailing list