[llvm-dev] what are the rules about ssp function attributes?

Andrew Kelley via llvm-dev
Wed, 16 Dec 2020 21:43:07 -0000

Hello,

Zig is now tripping a new LLVM assert in recent main branch commits of LLVM:

Assertion failed: (!(!Caller.hasStackProtectorFnAttr() &&
Callee.hasStackProtectorFnAttr()) && "stack protected callee but
caller
requested no stack protector"), function adjustCallerSSPLevel, file
/Users/kubkon/dev/llvm-project/llvm/lib/IR/Attributes.cpp, line 1951.

Caller is

; Function Attrs: nobuiltin nounwind
define internal fastcc void @std.math.big.int.llshl(%"[]usize"*
nonnull
readonly align 8 %0, %"[]usize"* nonnull readonly align 8 %1, i64 %2)
unnamed_addr #2 !dbg !445894 {

Callee is

; Function Attrs: nobuiltin nounwind sspstrong
define internal fastcc i64 @std.math.shr.11603(i64 %0, i64 %1)
unnamed_addr #1 !dbg !445958 {

So that's indeed a sspstrong function calling a non-sspstrong function.
Why is that not allowed? The LLVM language reference makes it sound like
you can have some functions protected and some functions not protected:

 > sspstrong
 >
 > This attribute indicates that the function should emit a stack
smashing protector.
 > ...
 > If a function that has an sspstrong attribute is inlined into a
 > function that doesn’t have an sspstrong attribute, then the resulting
 > function will have an sspstrong attribute.

Can anyone shed some light on this?

Thanks in advance!
Andrew

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20201216/c697c214/attachment.sig>