[PATCH v4 1/2] string: _FORTIFY_SOURCE=3 using __builtin_dynamic_object_size

Siddhesh Poyarekar siddhesh@sourceware.org
Tue Dec 15 19:01:02 GMT 2020


On 12/16/20 12:03 AM, Jakub Jelinek via Libc-alpha wrote:
> On Tue, Dec 15, 2020 at 11:52:37PM +0530, Siddhesh Poyarekar wrote:
>> -# elif _FORTIFY_SOURCE > 1
>> +# elif _FORTIFY_SOURCE == 3 && !__glibc_clang_prereq(9, 0)
>> +#  warning _FORTIFY_SOURCE > 2 requires LLVM 9.0 or later, falling back to 2
> 
> The == 3 above should be really > 2 instead.

I wrote it this way to maintain consistency with what the code has been 
doing so far, which is to silently lower the spurious high values (e.g. 
_FORTIFY_SOURCE=8) to the nearest supported one and only warn for ==3 
for non-clang.  Do you think we should change that?  If yes then we need 
a couple of levels of warnings, i.e.:

- Warn for too high values in general (i.e. > 3)
- Warn for too high value for specific compilers (i.e. > 2 for gcc)

Does that sound OK?

>>   # else
>> -#  define __USE_FORTIFY_LEVEL 1
>> +#  define __USE_FORTIFY_LEVEL _FORTIFY_SOURCE
> 
> Is it a good idea to define __USE_FORTIFY_LEVEL to _FORTIFY_SOURCE
> directly?  I mean, one can e.g. use -D_FORTIFY_SOURCE=2LL etc.
> and not sure if all the code that uses it will deal with 2LL properly.

OK, I'll fix it up.

Siddhesh


More information about the Libc-alpha mailing list