diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2025-07-15 18:43:22 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-15 18:43:22 +0900 |
commit | d7dc5367eda08e9c688d0055df44156c9508487b (patch) | |
tree | 7529aefb42fe7d38af48f934e9f8c849604c9980 /llvm/lib/CodeGen/SafeStack.cpp | |
parent | e68ef116b3f0701d9a2bfc5fb96597cff4ac8e4a (diff) | |
download | llvm-d7dc5367eda08e9c688d0055df44156c9508487b.zip llvm-d7dc5367eda08e9c688d0055df44156c9508487b.tar.gz llvm-d7dc5367eda08e9c688d0055df44156c9508487b.tar.bz2 |
SafeStack: Emit call to __stack_chk_fail through RuntimeLibcalls (#147915)
Avoid hardcoding the function name, and query if it's really
supported or not.
Diffstat (limited to 'llvm/lib/CodeGen/SafeStack.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SafeStack.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp index da229f8..a6c1a76 100644 --- a/llvm/lib/CodeGen/SafeStack.cpp +++ b/llvm/lib/CodeGen/SafeStack.cpp @@ -475,8 +475,16 @@ void SafeStack::checkStackGuard(IRBuilder<> &IRB, Function &F, Instruction &RI, SplitBlockAndInsertIfThen(Cmp, &RI, /* Unreachable */ true, Weights, DTU); IRBuilder<> IRBFail(CheckTerm); // FIXME: respect -fsanitize-trap / -ftrap-function here? + const char *StackChkFailName = + TL.getLibcallName(RTLIB::STACKPROTECTOR_CHECK_FAIL); + if (!StackChkFailName) { + F.getContext().emitError( + "no libcall available for stackprotector check fail"); + return; + } + FunctionCallee StackChkFail = - F.getParent()->getOrInsertFunction("__stack_chk_fail", IRB.getVoidTy()); + F.getParent()->getOrInsertFunction(StackChkFailName, IRB.getVoidTy()); IRBFail.CreateCall(StackChkFail, {}); } |