[PATCH v2] Replace __strcpy_chk with __builtin___strcpy_chk

Sam James sam@gentoo.org
Wed Dec 18 01:53:00 GMT 2024


Siddhesh Poyarekar <siddhesh@gotplt.org> writes:

> On 2024-12-17 19:46, Siddhesh Poyarekar wrote:
>> On 2024-12-17 19:44, Sam James wrote:
>>>> So... __builtin___strcpy_chk is not strictly equivalent to
>>>> __strcpy_chk; sorry I should have pointed that out when Sam mentioned
>>>> it. __builtin___strcpy_chk results in a full evaluation of the object
>>>> size argument and consequent replacement with either a strcpy call or
>>>> a __strcpy_chk call depending on whether the access is safe.
>>>> __strcpy_chk is, well, just __strcpy_chk.
>>>>
>>>> That said though, gcc has a gimple_fold_builtin_stxcpy_chk which folds
>>>> __strcpy_chk calls into a strcpy if the access is known to be safe, so
>>>> from that perspective, it doesn't actually make a difference as far as
>>>> gcc is concerned.  I don't know if clang has similar optimizations.
>>>
>>> Ouch, thanks (and sorry). Let's do the v1 one version given I don't know
>>> Clang's behaviour there.
>> I just acked the v2 given that it's not really that much of a
>> problem as far as the test itself is concerned.  Sorry for the
>> confusion :)
>
> (there I go hitting send again before I've finished my thought)
>
> Also, I figured v2 is a teenie-weenie bit better because it isolates
> the change to just that test and not the internal headers.

Thanks Sid. I admit I panicked a little bit :)

H.J., I think either is okay now I've read up a bit more and with Sid's
input. I still prefer the builtin because it has more limited scope.

>
> Sid


More information about the Libc-alpha mailing list