[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc
Subject:    Re: __builtin_dynamic_object_size
From:       Martin Sebor <msebor () gmail ! com>
Date:       2019-01-24 3:44:17
Message-ID: 2f977b2f-214e-a396-8e09-7c6cb3303ee9 () gmail ! com
[Download RAW message or body]

On 1/23/19 3:40 AM, Jonathan Wakely wrote:
> There's a patch to add __builtin_dynamic_object_size to clang:
> https://reviews.llvm.org/D56760
> 
> It was suggested that this could be done via a new flag bit for
> __builtin_object_size, but only if GCC would support that too
> (otherwise it would be done as a separate builtin).
> 
> Is there any interest in adding that as an option to __builtin_object_size?
> 
> I know Jakub is concerned about arbitrarily complex expressions, when
> __builtin_object_size is supposed to always be efficient and always
> evaluate at compile time (which would imply the dynamic behaviour
> should be a separate builtin, if it exists at all).

I am very interested in doing something like that and handling at
least the simple cases (with minimum runtime overhead).  I haven't
thought about it hard enough to have a clear idea whether it needs
a new built-in or whether the current one can be extended to handle
non-constant cases as well (perhaps by adding a new bit) but I would
certainly want the existing libc infrastructure to make use of
the non-constant sizes without having to change.  The overhead of
handling the more complex cases that Jakub is concerned about could
be controlled by some customizable parameter so I don't think that
should stand in the way.

Besides handling non-constant object sizes I would also like GCC to
get better about detecting and preventing subobject overflow (such
as in strcpy (s.m, "foobar") where GCC transforms the strcpy call
to memcpy which is allowed to overwrite whatever follows s.m).

Martin
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic