On Thu, Jul 29, 2021 at 6:09 PM Joseph Myers <jos...@codesourcery.com> 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).
Thus flag_no_delete_null_pointer_checks checks should be replaced with sth that takes the address-space as argument. A good default implementation would be to only have the default address space covered by NULL pointer rules. Richard. > -- > Joseph S. Myers > jos...@codesourcery.com