@@ -21,13 +21,20 @@ def isOSOpenBSD : RuntimeLibcallPredicate<"TT.isOSOpenBSD()">;
2121def isNotOSOpenBSD : RuntimeLibcallPredicate<"!TT.isOSOpenBSD()">;
2222def isOSWindows : RuntimeLibcallPredicate<"TT.isOSWindows()">;
2323def isNotOSWindows : RuntimeLibcallPredicate<"!TT.isOSWindows()">;
24+ def isNotOSLinux : RuntimeLibcallPredicate<[{!TT.isOSLinux()}]>;
2425def isNotOSMSVCRT : RuntimeLibcallPredicate<"!TT.isOSMSVCRT()">;
2526def isPS : RuntimeLibcallPredicate<"TT.isPS()">;
2627def isNotOSWindowsOrIsCygwinMinGW
2728 : RuntimeLibcallPredicate<"!TT.isOSWindows() || TT.isOSCygMing()">;
2829def isWindowsMSVCEnvironment : RuntimeLibcallPredicate<
2930 [{TT.isWindowsMSVCEnvironment()}]>;
3031
32+ def isNotOSLinuxAndNotOSOpenBSD : RuntimeLibcallPredicate<
33+ [{!TT.isOSLinux() && !TT.isOSOpenBSD()}]>;
34+
35+ def isWindowsMSVCOrItaniumEnvironment : RuntimeLibcallPredicate<
36+ [{TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()}]>;
37+
3138def isGNUEnvironment : RuntimeLibcallPredicate<"TT.isGNUEnvironment()">;
3239def darwinHasSinCosStret : RuntimeLibcallPredicate<"darwinHasSinCosStret(TT)">;
3340def darwinHasExp10 : RuntimeLibcallPredicate<"darwinHasExp10(TT)">;
@@ -471,6 +478,16 @@ def OBJC_RETAIN_AUTORELEASE : RuntimeLibcall;
471478def OBJC_SYNC_ENTER : RuntimeLibcall;
472479def OBJC_SYNC_EXIT : RuntimeLibcall;
473480
481+ //--------------------------------------------------------------------
482+ // Global variable references
483+ //--------------------------------------------------------------------
484+ //
485+ // TODO: These are not libcalls and probably should be distinguished
486+ // in some way from callable functions.
487+ // --------------------------------------------------------------------
488+
489+ def STACK_CHECK_GUARD : RuntimeLibcall;
490+
474491//--------------------------------------------------------------------
475492// Define implementation default libcalls
476493//--------------------------------------------------------------------
@@ -1103,6 +1120,21 @@ defset list<RuntimeLibcallImpl> LibmF128FiniteLibcalls = {
11031120 def __powf128_finite : RuntimeLibcallImpl<POW_FINITE_F128>;
11041121}
11051122
1123+ //--------------------------------------------------------------------
1124+ // Global variable references
1125+ //--------------------------------------------------------------------
1126+
1127+ def __stack_chk_guard : RuntimeLibcallImpl<STACK_CHECK_GUARD>;
1128+
1129+ // Name used on OpenBSD
1130+ def __guard_local : RuntimeLibcallImpl<STACK_CHECK_GUARD>;
1131+
1132+ // Name used with Windows MSVC
1133+ def __security_cookie : RuntimeLibcallImpl<STACK_CHECK_GUARD>;
1134+
1135+ // Name used on AIX
1136+ def __ssp_canary_word : RuntimeLibcallImpl<STACK_CHECK_GUARD>;
1137+
11061138//===----------------------------------------------------------------------===//
11071139// Common Libcall Sets
11081140//===----------------------------------------------------------------------===//
@@ -1159,7 +1191,8 @@ defvar DarwinSinCosStret = LibcallImpls<(add __sincosf_stret, __sincos_stret),
11591191defvar DarwinExp10 = LibcallImpls<(add __exp10f, __exp10), darwinHasExp10>;
11601192
11611193defvar SecurityCheckCookieIfWinMSVC =
1162- LibcallImpls<(add __security_check_cookie), isWindowsMSVCEnvironment>;
1194+ LibcallImpls<(add __security_check_cookie, __security_cookie),
1195+ isWindowsMSVCOrItaniumEnvironment>;
11631196
11641197defvar LibmHasSinCosF32 = LibcallImpls<(add sincosf), hasSinCos>;
11651198defvar LibmHasSinCosF64 = LibcallImpls<(add sincos), hasSinCos>;
@@ -1205,10 +1238,13 @@ defvar LibmHasFrexpF128 = LibcallImpls<(add frexp_f128), isNotOSWindowsOrIsCygwi
12051238defvar LibmHasLdexpF128 = LibcallImpls<(add ldexp_f128), isNotOSWindowsOrIsCygwinMinGW>;
12061239
12071240defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), isNotOSOpenBSD>;
1241+ defvar has__stack_chk_guard =
1242+ LibcallImpls<(add __stack_chk_guard), isNotOSOpenBSD>;
12081243defvar has__stack_smash_handler = LibcallImpls<(add __stack_smash_handler), isOSOpenBSD>;
1244+ defvar has___guard_local = LibcallImpls<(add __guard_local), isOSOpenBSD>;
12091245
1210- defvar DefaultStackProtector = (add has__stack_chk_fail,
1211- has__stack_smash_handler);
1246+ defvar DefaultStackProtector = (add has__stack_chk_fail, has__stack_chk_guard,
1247+ has__stack_smash_handler, has___guard_local );
12121248
12131249//===----------------------------------------------------------------------===//
12141250// Objective-C Runtime Libcalls
@@ -1357,7 +1393,9 @@ def WindowsARM64ECSystemLibrary
13571393 : SystemRuntimeLibrary<isWindowsArm64EC,
13581394 (add WinArm64ECDefaultRuntimeLibcallImpls,
13591395 arm64ec___stack_chk_fail,
1360- LibcallImpls<(add __security_check_cookie_arm64ec),
1396+ __stack_chk_guard,
1397+ LibcallImpls<(add __security_check_cookie_arm64ec,
1398+ __security_cookie),
13611399 isWindowsMSVCEnvironment>,
13621400 ExceptionModelCallsArm64EC)>;
13631401
@@ -1848,7 +1886,7 @@ def HexagonSystemLibrary
18481886 __umoddi3, __divdf3, __muldf3, __divsi3, __subdf3, sqrtf,
18491887 __divdi3, __umodsi3, __moddi3, __modsi3), HexagonLibcalls,
18501888 LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
1851- exp10f, exp10, exp10l_f128, __stack_chk_fail)>;
1889+ exp10f, exp10, exp10l_f128, __stack_chk_fail, __stack_chk_guard )>;
18521890
18531891//===----------------------------------------------------------------------===//
18541892// Lanai Runtime Libcalls
@@ -1859,7 +1897,7 @@ def isLanai : RuntimeLibcallPredicate<"TT.getArch() == Triple::lanai">;
18591897// Use fast calling convention for library functions.
18601898def LanaiSystemLibrary
18611899 : SystemRuntimeLibrary<isLanai, (add DefaultRuntimeLibcallImpls,
1862- __stack_chk_fail)> {
1900+ __stack_chk_fail, __stack_chk_guard )> {
18631901 let DefaultLibcallCallingConv = FASTCC;
18641902}
18651903
@@ -2157,7 +2195,8 @@ def MSP430SystemLibrary
21572195 __mspabi_slll,
21582196 // __mspabi_[srlll/srall/sllll/rlli/rlll] are NOT implemented in libgcc
21592197
2160- __stack_chk_fail
2198+ __stack_chk_fail,
2199+ __stack_chk_guard
21612200 )
21622201>;
21632202
@@ -2251,7 +2290,11 @@ def PPCSystemLibrary
22512290 LibmHasSinCosPPCF128,
22522291 AvailableIf<memcpy, isNotAIX>,
22532292 LibcallImpls<(add Int128RTLibcalls), isPPC64>,
2254- DefaultStackProtector)>;
2293+ has__stack_chk_fail,
2294+ has__stack_smash_handler,
2295+ has___guard_local,
2296+ AvailableIf<__ssp_canary_word, isAIX>,
2297+ AvailableIf<__stack_chk_guard, isNotAIX>)>;
22552298
22562299//===----------------------------------------------------------------------===//
22572300// RISCV Runtime Libcalls
@@ -2334,7 +2377,10 @@ def SPARCSystemLibrary
23342377 LibcallImpls<(add _Q_qtoll, _Q_qtoull, _Q_lltoq, _Q_ulltoq), isSPARC32>,
23352378 LibcallImpls<(add SPARC64_MulDivCalls, Int128RTLibcalls), isSPARC64>,
23362379 LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
2337- DefaultStackProtector)
2380+ has__stack_chk_fail,
2381+ has__stack_smash_handler,
2382+ has___guard_local,
2383+ AvailableIf<__stack_chk_guard, isNotOSLinuxAndNotOSOpenBSD>)
23382384>;
23392385
23402386//===----------------------------------------------------------------------===//
@@ -2544,7 +2590,7 @@ def WasmSystemLibrary
25442590 exp10f, exp10,
25452591 _Unwind_CallPersonality,
25462592 emscripten_return_address,
2547- __stack_chk_fail)>;
2593+ __stack_chk_fail, __stack_chk_guard )>;
25482594
25492595//===----------------------------------------------------------------------===//
25502596// Legacy Default Runtime Libcalls
0 commit comments