Referencing through a null pointer
mcdonald at uxe.cso.uiuc.edu
mcdonald at uxe.cso.uiuc.edu
Wed Apr 27 23:50:00 AEST 1988
/* Written 6:04 pm Apr 25, 1988 by henry at utzoo.uucp in uxe.cso.uiuc.edu:comp.lang.c */
> I imagine that PDP-11s without split I&D had *(char *)0 == 7 or 8, and
> *(short *)0 == 0407 or 0408 (OMAGIC and NMAGIC respectively).
Actually, no. The a.out header was not part of the actual core image, so
the first instruction of the program was first; in practice this was the
"setd" that got the floating-point processor into the right mode (or tipped
the software off that the processor lacked hardware floating point), which
gave *(char *)0 == 011 and *(short *)0 == 0170011. The programs which
made assumptions about *0 were generally the big ones, which ran split-space
of necessity.
--
"Noalias must go. This is | Henry Spencer @ U of Toronto Zoology
non-negotiable." --DMR | {ihnp4,decvax,uunet!mnetor}!utzoo!henry
/* End of text from uxe.cso.uiuc.edu:comp.lang.c */
Actually, yes. I think Henry is making a unstated assumption: his use
of the phrase "a.out" implies he is thinking of Unix. Most PDP-11's run
RT-11. The memory location 0 in RT-11 is indeed 7. Thus if you're
not using relocation, *(char *)0 is 7. I just tried it.
Doug McDonald
More information about the Comp.lang.c
mailing list