From 99e53cb4139eda491f97cb33ee42ea424d352200 Mon Sep 17 00:00:00 2001 From: PiJoules <6019989+PiJoules@users.noreply.github.com> Date: Mon, 16 Jun 2025 15:47:43 -0700 Subject: [llvm][StackProtector] Add noreturn to __stack_chk_fail call (#143976) It's possible for __stack_chk_fail to be an alias when using CrossDSOCFI since it will make a jump table entry for this function and replace it with an alias. StackProtector can crash since it always expects this to be a regular function. Instead add the noreturn attribute to the call. --- llvm/lib/CodeGen/StackProtector.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen/StackProtector.cpp') diff --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp index 5f866ee..dda392d 100644 --- a/llvm/lib/CodeGen/StackProtector.cpp +++ b/llvm/lib/CodeGen/StackProtector.cpp @@ -725,8 +725,8 @@ BasicBlock *CreateFailBB(Function *F, const Triple &Trip) { StackChkFail = M->getOrInsertFunction("__stack_chk_fail", Type::getVoidTy(Context)); } - cast(StackChkFail.getCallee())->addFnAttr(Attribute::NoReturn); - B.CreateCall(StackChkFail, Args); + CallInst *Call = B.CreateCall(StackChkFail, Args); + Call->addFnAttr(Attribute::NoReturn); B.CreateUnreachable(); return FailBB; } -- cgit v1.1