Subject: Re: Disallowing mmapping of NULL
To: David Laight <david@l8s.co.uk>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: tech-kern
Date: 01/29/2007 21:52:55
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.
--Steve Bellovin, http://www.cs.columbia.edu/~smb