Re: [clang] stack protector and f1f029c7bf
From: Nick Desaulniers
Date: Fri May 25 2018 - 13:49:46 EST
On Fri, May 25, 2018 at 10:35 AM Tom Stellard <tstellar@xxxxxxxxxx> wrote:
> On 05/25/2018 10:31 AM, Nick Desaulniers wrote:
> > On Fri, May 25, 2018 at 9:53 AM <hpa@xxxxxxxxx> wrote:
> >> On May 25, 2018 9:46:42 AM PDT, Nick Desaulniers <
ndesaulniers@xxxxxxxxxx>
> > wrote:
> >>> On Fri, May 25, 2018 at 9:33 AM <hpa@xxxxxxxxx> wrote:
> >>>> On May 25, 2018 9:27:40 AM PDT, Nick Desaulniers
> >>> <ndesaulniers@xxxxxxxxxx> wrote:
> >>> When you say
> >>>
> >>>> It still should be available as as inline, however, but now "extern
> >>> inline".
> >>>
> >>> Am I understanding correctly that native_save_fl should be inlined
into
> >>> all
> >>> call sites (modulo the problematic pv_irq_ops.save_fl case)? Because
> >>> for
> >>> these two assembly implementations, it's not, but maybe there's
> >>> something
> >>> missing in my implementation?
> >
> >> Yes, that's what "extern inline" means. Maybe it needs a must inline
> > annotation, but that's really messed up.
> >
> What about doing something like suggested here:
> https://bugs.llvm.org/show_bug.cgi?id=37512#c17
> This would keep the definition in C and make it easier for compilers
> to inline.
The GCC docs for __attribute__((naked)) seem to imply this is a machine
specific constraint (of which x86 is not listed):
https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Function-Attributes.html
But let's try with source:
https://godbolt.org/g/aJ4gZB
Clang errors:
<source>:3:3: error: non-ASM statement in naked function is not supported
unsigned long flags;
^
Is it valid to use assembly to place the results in %rax and mark the c
function somehow?
gcc doesn't support this attribute until 4.9 (but we can add a feature test
for attributes with gcc (unlike builtins)), but warns that:
warning: ânakedâ attribute directive ignored [-Wattributes]
gcc 8.1 and trunk inserts a `ud2` instruction (what?!) (let me see if I can
repro outside of godbolt, and will file a bug report).
--
Thanks,
~Nick Desaulniers