On Thu, Jul 29, 2021 at 04:08:36PM +0000, Joseph Myers wrote:
> On Thu, 29 Jul 2021, Florian Weimer via Gcc wrote:
> > On GNU/Linux, SEGFS is used to implement the thread pointer, to avoid
> > dedicating a general-purpose register to it.  At address zero with the
> > SEGFS prefix, the offset itself is stored so that userspace can read it
> > without having to call into the kernel.  So the SEGFS null pointer is a
> > valid address, and so are some bytes after it (depending on TCB layout,
> > some of which is specified by the ABI or is part of the de-facto ABI
> > used by GCC).
> 
> That suggests that we need a target hook to describe null pointer 
> properties for a given address space.  In an address space where null 
> pointers are valid to dereference, there should be no diagnostics for 
> arithmetic on / dereferencing them - and more generally, 
> -fno-delete-null-pointer-checks should be in effect for pointers to such 
> an address space (so I don't think this is just a warning issue, you can 
> probably get wrong code from null pointer check deletion in such an 
> address space).

There already is TARGET_ADDR_SPACE_ZERO_ADDRESS_VALID?  So this just
isn't used everywhere it should?


Segher

Reply via email to