Re: Kernel loaded at top of memory
From: Floyd Davidson (floyd_at_barrow.com)
Date: Wed, 04 Feb 2004 07:26:01 -0900
John Reiser <jreiser@BitWagon.com> wrote:
>> The NULL pointer is also interesting.
>> Considering that the NULL pointer points to the
>> virtual address 0, ...
NULL is a macro (a source code device), which when used in a
pointer context will result in the compiled program producing a
/null/ /pointer/ (a implementation defined device). A /null/
/pointer/ is *guaranteed* not to point at a valid object. It is
*not* guaranteed to be a pointer to address 0, and in fact may
or may not actually point at that, or any, address.
>The UNIX SystemVr4 ABI requires that it be _possible_ for a read/write/
>execute page to exist at address 0; mmap(0,,,MAP_FIXED,,) must succeed
>if otherwise OK. Some software depends on (0==*(char *)0), and other code
>can take advantage of (0==*(int *)0).
Software which depends on either of the above expressions is
Conversion of a "null pointer constant", such as the integer 0,
to a pointer results in the /null/ /pointer/ described above.
Both of the two above expressions involve doing exactly that,
and the pointer which results is *guaranteed* not to point at
any valid object. Dereferencing that pointer to an invalid
object is undefined behavior.
-- Floyd L. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) email@example.com