[LLVMdev] Is address space 1 reserved?
David Chisnall
David.Chisnall at cl.cam.ac.uk
Sat Jan 10 11:37:31 PST 2015
On 10 Jan 2015, at 19:17, Herbie Robinson <HerbieRobinson at verizon.net> wrote:
>
> There is also standardized code that assumes there are at least 4 distinct pointer values that can't point to a valid memory address: Look up SIG_DFL, SIG_ERR, SIG_HOLD and SIG_IGN in the POSIX standard. We actually leave the entire page zero unmapped to allow for things like this. Overkill, of course, but it's easy to drop an entire page and it's also useful for catching most null pointer mishaps.
I don't think this holds. It is entirely valid for all four of these to point to valid functions. I don't think there's anything in the spec (C or POSIX) that says that these can't be valid objects, only that they do not have to be.
There are some other things where it's useful to have a range of definitely-invalid pointers. A couple of examples come to mind:
- Apple leaves (used to leave?) the bottom 64KB unmapped so that isa pointers for Objective-C objects will never end up there and CoreFoundation can use this address range to signify CF types.
- Lots of JavaScript implementations use the fact that the memory hole in the middle of a 64-bit address space lines up with the bits used to designate NaN values in IEEE floating point values to guarantee valid floating point values and pointers hidden in floating point values can be distinguished.
David
More information about the llvm-dev
mailing list