Subject: Re: Disallowing mmapping of NULL
To: Steven M. Bellovin <smb@cs.columbia.edu>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 01/29/2007 22:17:26
On Mon, Jan 29, 2007 at 09:52:55PM +0000, Steven M. Bellovin wrote:
> On Mon, 29 Jan 2007 21:31:36 +0000
> David Laight <david@l8s.co.uk> wrote:
> 
> 
> > 
> > Historically a byte read from address 0 returned the value 0, so that
> > code could do 'if (*ptr)' instead of 'if (ptr && *ptr)' in order to
> > save code bytes.
> > 
> That depends on how historical you want to get.  On PDP-11s, 0 was the
> start of the text segment, and was where the kernel branched after an
> exec.  From a.out(5) from 7th Edition Unix:
> 
> 	The text segment begins at 0 in the core image; the  header
> 	is not loaded.
> 
> I confess I do not remember the optimization you refer to.

I only remember someone talking about it.....
I'm not sure I ever looked on the pdp11 I used to use (which ran RSX/11M
and/or RT11).  In any case if the code started:
	br   .+2
	br   after_header
	<program header>
after_header:

byte 0 would be zero.

	David

-- 
David Laight: david@l8s.co.uk