@@ -21,13 +21,20 @@ def isOSOpenBSD : RuntimeLibcallPredicate<"TT.isOSOpenBSD()">;
21
21
def isNotOSOpenBSD : RuntimeLibcallPredicate<"!TT.isOSOpenBSD()">;
22
22
def isOSWindows : RuntimeLibcallPredicate<"TT.isOSWindows()">;
23
23
def isNotOSWindows : RuntimeLibcallPredicate<"!TT.isOSWindows()">;
24
+ def isNotOSLinux : RuntimeLibcallPredicate<[{!TT.isOSLinux()}]>;
24
25
def isNotOSMSVCRT : RuntimeLibcallPredicate<"!TT.isOSMSVCRT()">;
25
26
def isPS : RuntimeLibcallPredicate<"TT.isPS()">;
26
27
def isNotOSWindowsOrIsCygwinMinGW
27
28
: RuntimeLibcallPredicate<"!TT.isOSWindows() || TT.isOSCygMing()">;
28
29
def isWindowsMSVCEnvironment : RuntimeLibcallPredicate<
29
30
[{TT.isWindowsMSVCEnvironment()}]>;
30
31
32
+ def isNotOSLinuxAndNotOSOpenBSD : RuntimeLibcallPredicate<
33
+ [{!TT.isOSLinux() && !TT.isOSOpenBSD()}]>;
34
+
35
+ def isWindowsMSVCOrItaniumEnvironment : RuntimeLibcallPredicate<
36
+ [{TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()}]>;
37
+
31
38
def isGNUEnvironment : RuntimeLibcallPredicate<"TT.isGNUEnvironment()">;
32
39
def darwinHasSinCosStret : RuntimeLibcallPredicate<"darwinHasSinCosStret(TT)">;
33
40
def darwinHasExp10 : RuntimeLibcallPredicate<"darwinHasExp10(TT)">;
@@ -471,6 +478,16 @@ def OBJC_RETAIN_AUTORELEASE : RuntimeLibcall;
471
478
def OBJC_SYNC_ENTER : RuntimeLibcall;
472
479
def OBJC_SYNC_EXIT : RuntimeLibcall;
473
480
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
+
474
491
//--------------------------------------------------------------------
475
492
// Define implementation default libcalls
476
493
//--------------------------------------------------------------------
@@ -1103,6 +1120,21 @@ defset list<RuntimeLibcallImpl> LibmF128FiniteLibcalls = {
1103
1120
def __powf128_finite : RuntimeLibcallImpl<POW_FINITE_F128>;
1104
1121
}
1105
1122
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
+
1106
1138
//===----------------------------------------------------------------------===//
1107
1139
// Common Libcall Sets
1108
1140
//===----------------------------------------------------------------------===//
@@ -1159,7 +1191,8 @@ defvar DarwinSinCosStret = LibcallImpls<(add __sincosf_stret, __sincos_stret),
1159
1191
defvar DarwinExp10 = LibcallImpls<(add __exp10f, __exp10), darwinHasExp10>;
1160
1192
1161
1193
defvar SecurityCheckCookieIfWinMSVC =
1162
- LibcallImpls<(add __security_check_cookie), isWindowsMSVCEnvironment>;
1194
+ LibcallImpls<(add __security_check_cookie, __security_cookie),
1195
+ isWindowsMSVCOrItaniumEnvironment>;
1163
1196
1164
1197
defvar LibmHasSinCosF32 = LibcallImpls<(add sincosf), hasSinCos>;
1165
1198
defvar LibmHasSinCosF64 = LibcallImpls<(add sincos), hasSinCos>;
@@ -1205,10 +1238,13 @@ defvar LibmHasFrexpF128 = LibcallImpls<(add frexp_f128), isNotOSWindowsOrIsCygwi
1205
1238
defvar LibmHasLdexpF128 = LibcallImpls<(add ldexp_f128), isNotOSWindowsOrIsCygwinMinGW>;
1206
1239
1207
1240
defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), isNotOSOpenBSD>;
1241
+ defvar has__stack_chk_guard =
1242
+ LibcallImpls<(add __stack_chk_guard), isNotOSOpenBSD>;
1208
1243
defvar has__stack_smash_handler = LibcallImpls<(add __stack_smash_handler), isOSOpenBSD>;
1244
+ defvar has___guard_local = LibcallImpls<(add __guard_local), isOSOpenBSD>;
1209
1245
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 );
1212
1248
1213
1249
//===----------------------------------------------------------------------===//
1214
1250
// Objective-C Runtime Libcalls
@@ -1357,7 +1393,9 @@ def WindowsARM64ECSystemLibrary
1357
1393
: SystemRuntimeLibrary<isWindowsArm64EC,
1358
1394
(add WinArm64ECDefaultRuntimeLibcallImpls,
1359
1395
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),
1361
1399
isWindowsMSVCEnvironment>,
1362
1400
ExceptionModelCallsArm64EC)>;
1363
1401
@@ -1848,7 +1886,7 @@ def HexagonSystemLibrary
1848
1886
__umoddi3, __divdf3, __muldf3, __divsi3, __subdf3, sqrtf,
1849
1887
__divdi3, __umodsi3, __moddi3, __modsi3), HexagonLibcalls,
1850
1888
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
1851
- exp10f, exp10, exp10l_f128, __stack_chk_fail)>;
1889
+ exp10f, exp10, exp10l_f128, __stack_chk_fail, __stack_chk_guard )>;
1852
1890
1853
1891
//===----------------------------------------------------------------------===//
1854
1892
// Lanai Runtime Libcalls
@@ -1859,7 +1897,7 @@ def isLanai : RuntimeLibcallPredicate<"TT.getArch() == Triple::lanai">;
1859
1897
// Use fast calling convention for library functions.
1860
1898
def LanaiSystemLibrary
1861
1899
: SystemRuntimeLibrary<isLanai, (add DefaultRuntimeLibcallImpls,
1862
- __stack_chk_fail)> {
1900
+ __stack_chk_fail, __stack_chk_guard )> {
1863
1901
let DefaultLibcallCallingConv = FASTCC;
1864
1902
}
1865
1903
@@ -2157,7 +2195,8 @@ def MSP430SystemLibrary
2157
2195
__mspabi_slll,
2158
2196
// __mspabi_[srlll/srall/sllll/rlli/rlll] are NOT implemented in libgcc
2159
2197
2160
- __stack_chk_fail
2198
+ __stack_chk_fail,
2199
+ __stack_chk_guard
2161
2200
)
2162
2201
>;
2163
2202
@@ -2251,7 +2290,11 @@ def PPCSystemLibrary
2251
2290
LibmHasSinCosPPCF128,
2252
2291
AvailableIf<memcpy, isNotAIX>,
2253
2292
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>)>;
2255
2298
2256
2299
//===----------------------------------------------------------------------===//
2257
2300
// RISCV Runtime Libcalls
@@ -2334,7 +2377,10 @@ def SPARCSystemLibrary
2334
2377
LibcallImpls<(add _Q_qtoll, _Q_qtoull, _Q_lltoq, _Q_ulltoq), isSPARC32>,
2335
2378
LibcallImpls<(add SPARC64_MulDivCalls, Int128RTLibcalls), isSPARC64>,
2336
2379
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>)
2338
2384
>;
2339
2385
2340
2386
//===----------------------------------------------------------------------===//
@@ -2544,7 +2590,7 @@ def WasmSystemLibrary
2544
2590
exp10f, exp10,
2545
2591
_Unwind_CallPersonality,
2546
2592
emscripten_return_address,
2547
- __stack_chk_fail)>;
2593
+ __stack_chk_fail, __stack_chk_guard )>;
2548
2594
2549
2595
//===----------------------------------------------------------------------===//
2550
2596
// Legacy Default Runtime Libcalls
0 commit comments