Messing with 0 ptr on m68020 & sys V / 68

Henry Spencer henry at utzoo.uucp
Wed Nov 30 03:52:53 AEST 1988


In article <1564 at nud.UUCP> df at nud.UUCP (Dale Farnsworth) writes:
>... Once upon a time, the standard UNIX distribution
>from AT&T ran on the PDP-11 family.  The instruction which began each program
>(from crt0.o) just "happened" to have a zero-valued first byte...

Not quite correct.  The first instruction did not in fact have a zero low
byte (or a zero high byte).  However, when a pdp11 program was compiled
split-space, to get maximum address space on a large 11, a one-word "shim"
was inserted at location 0 in data space to ensure that no legitimate
variable ever got put there (since C guarantees that &x != 0 for any x).
The shim, unfortunately, was a zero.  Most large and complex programs
needed split space, so their developers got used to having a readable
zero at location zero.

Friends of mine (at HCR) ran into this when using overlaying to make the
big stuff work on small (non-split-space) 11s.  They ended up inserting
a contrived instruction with a zero low byte at the beginning of the
startup code.  (They would have preferred a zero word, but that's a
HALT instruction -- illegal in user mode -- on the 11!)
-- 
SunOSish, adj:  requiring      |     Henry Spencer at U of Toronto Zoology
32-bit bug numbers.            | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list