On Wed, Sep 16, 2020 at 10:30:42PM +0100, Daniel Kiss wrote:
> 
>     Thanks for the summary -- yeah, that was my suspicion, that some
>     attribute was being lost somewhere. And I think if we generalize this,
>     and don't just try to attach "frame-pointer" attr to the function, we
>     probably also solve the BTI issue that Mark still pointed out with
>     these module_ctor/dtors.
> 
>     I was trying to see if there was a generic way to attach all the
>     common attributes to the function generated here:
>     
> https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/Utils/
>     ModuleUtils.cpp#L122
>     -- but we probably can't attach all attributes, and need to remove a
>     bunch of them again like the sanitizers (or alternatively just select
>     the ones we need). But, I'm still digging for the function that
>     attaches all the common attributes…
> 
> 
> We had the problem with not just the sanitisers.  Same problem pops with
> functions 
> that created elsewhere in clang (e.g _clang_call_terminate ) or llvm.
> 
> In case of BTI the flag even controllable by function attributes which makes 
> it
> more trickier so
> the module flags found the only reliable way to pass this information down. 
> Scanning existing functions is fragile for data only compilation units for
> example.
> 
> Our solution, not generic enough but might help.
> https://reviews.llvm.org/D85649 

Thanks for the pointer -- I've subscribed to that now.

Just to check my understanding, is the issue that generated functions
don't implicitly get function attributes like
"branch-target-enforcement", and so the BTI insertion pass skips those?

I'm guessing that it's unlikely this'll be fixed for an LLVM 11 release?
On the kernel side I guess we'll have to guard affected features as
being incompatible with BTI until there's a viable fix on the compiler
side. :/

Thanks,
Mark.

Reply via email to