This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix unsafe function attributes for special functions (PR 71876)
- From: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- To: Richard Biener <rguenther at suse dot de>
- Cc: "jakub at redhat dot com" <jakub at redhat dot com>, Jeff Law <law at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "ebotcazou at adacore dot com" <ebotcazou at adacore dot com>
- Date: Wed, 20 Jul 2016 12:13:10 +0000
- Subject: Re: [PATCH] Fix unsafe function attributes for special functions (PR 71876)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=softfail (sender IP is 10.152.4.54) smtp.mailfrom=hotmail.de; suse.de; dkim=none (message not signed) header.d=none;suse.de; dmarc=none action=none header.from=hotmail.de;
- References: <AM4PR0701MB216226C00439A01515A3AA5FE4370@AM4PR0701MB2162.eurprd07.prod.outlook.com> <alpine.LSU.2.11.1607201243320.30444@t29.fhfr.qr> <alpine.LSU.2.11.1607201245310.30444@t29.fhfr.qr> <AM4PR0701MB2162F941CAB008360282B6B5E4080@AM4PR0701MB2162.eurprd07.prod.outlook.com> <alpine.LSU.2.11.1607201351490.30444@t29.fhfr.qr>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On 07/20/16 13:53, Richard Biener wrote:
> On Wed, 20 Jul 2016, Bernd Edlinger wrote:
>
>> On 07/20/16 12:46, Richard Biener wrote:
>>> On Wed, 20 Jul 2016, Richard Biener wrote:
>>>
>>>> On Tue, 19 Jul 2016, Bernd Edlinger wrote:
>>>>
>>>>> Hi!
>>>>>
>>>>> As discussed at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71876,
>>>>> we have a _very_ old hack in gcc, that recognizes certain functions by
>>>>> name, and inserts in some cases unsafe attributes, that don't work for
>>>>> a freestanding environment.
>>>>>
>>>>> It is unsafe to return ECF_MAY_BE_ALLOCA, ECF_LEAF and ECF_NORETURN
>>>>> from special_function_p, just by the name of the function, especially
>>>>> for less well known functions, like "getcontext" or "savectx", which
>>>>> could easily used for something completely different.
>>>>
>>>> Returning ECF_MAY_BE_ALLOCA is safe. Just wanted to mention this,
>>>> regardless of the followups you already received.
>>>
>>> Oh, and maybe you can factor out the less controversical parts,
>>> namely ignoring the __builtin_ prefix. I don't think that
>>> calling __builtin_setjmp in an environment where setjmp is not a
>>> builtin should beave like setjmp (it will call a function named
>>> '__builtin_setjmp').
>>
>>
>> I wonder how I manage to dig out such contriversical things ;)
>>
>> But you are right, that would at least be a start.
>>
>> So this patch is what you requested:
>>
>> Remove the handling of the __builtin_ prefix from special_function_p
>> and add the returns_twice attribute to the __builtin_setjmp declaration
>> instead.
>>
>> Is it OK after boot-strap and regression-testing?
>
> I think the __builtin_setjmp change is wrong - __builtin_setjmp is
> _not_ 'setjmp' it is part of the GCC internal machinery (using setjmp
> and longjmp in the end) for SJLJ exception handing.
>
I do think that part is correct.
DEF_GCC_BUILTIN adds the __builtin_ prefix, but does not overload the
standard setjmp function.
/* A GCC builtin (like __builtin_saveregs) is provided by the
compiler, but does not correspond to a function in the standard
library. */
#undef DEF_GCC_BUILTIN
#define DEF_GCC_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, BT_LAST, \
false, false, false, ATTRS, true, true)
And to define a builtin without __builtin_, there is a DEF_SYNC_BUILTIN
macro. And DEF_LIB_BUILTIN defines both ways.
However, there is no simple way to define setjmp and __builtin_setjmp
to different builtin functions.
Thanks
Bernd.
> Am I correct Eric?
>
> Thanks,
> Richard.
>
>>
>> Thanks
>> Bernd.
>>
>