The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: <ron@ronnatalie.com>
To: "'The Eunuchs Hysterical Society'" <tuhs@tuhs.org>
Subject: [TUHS] Magic numbers
Date: Thu, 3 Jan 2019 11:04:49 -0500	[thread overview]
Message-ID: <083c01d4a37e$0e2af4d0$2a80de70$@ronnatalie.com> (raw)

The issue of a.out magic numbers came up.   The a.out header was 16 bytes.    The first two bytes was 0407 in the original code.    This was followed by 16 bit quantities for text, data, and bss sizes.   Then the size of the symbol tables.   I'm pretty sure the rest of the fields were blank in V6.   Later a start address (previously always assumed to be zero) was added.

The number 407 was a neat kludge.   It was a (relative) branch instruction on the PDP-11.   0400 was the base op code.  7 referred to jumping ahead 7 words which skipped you over the a.out header (the PC had already been incremented for the branch instruction itself).    This allowed you to make a boot block without having to strip off the header.   Boot blocks were just one 512 byte block loaded from block zero of the disk into low memory.

Later executables used 410 for a write protected text segment and 411 for split-I/D executables.   Later versions added more codes (413 was used in BSD to indicate aligned pages followed etc...   Even later systems coded the hardware type into the magic number to distinguish between different architectures.

Note that the fact that 410 and 411 were also PDP-11 branch instructions wasn't ever really used for anything.



                 reply	other threads:[~2019-01-03 16:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='083c01d4a37e$0e2af4d0$2a80de70$@ronnatalie.com' \
    --to=ron@ronnatalie.com \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).