Skip to content

Commit 1862e3c

Browse files
authored
RuntimeLibcalls: Move __stack_smash_handler config to tablegen (#150870)
1 parent 0cfe9f7 commit 1862e3c

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,10 @@ defvar LibmHasFrexpF128 = LibcallImpls<(add frexp_f128), isNotOSWindowsOrIsCygwi
11511151
defvar LibmHasLdexpF128 = LibcallImpls<(add ldexp_f128), isNotOSWindowsOrIsCygwinMinGW>;
11521152

11531153
defvar has__stack_chk_fail = LibcallImpls<(add __stack_chk_fail), isNotOSOpenBSD>;
1154+
defvar has__stack_smash_handler = LibcallImpls<(add __stack_smash_handler), isOSOpenBSD>;
1155+
1156+
defvar DefaultStackProtector = (add has__stack_chk_fail,
1157+
has__stack_smash_handler);
11541158

11551159
//===----------------------------------------------------------------------===//
11561160
// Objective-C Runtime Libcalls
@@ -1229,7 +1233,7 @@ def AArch64SystemLibrary : SystemRuntimeLibrary<
12291233
DarwinExp10, DarwinSinCosStret,
12301234
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
12311235
DefaultLibmExp10,
1232-
has__stack_chk_fail)
1236+
DefaultStackProtector)
12331237
>;
12341238

12351239
// Prepend a # to every name
@@ -1506,7 +1510,7 @@ def ARMSystemLibrary
15061510
LibcallImpls<(add __divmodsi4, __udivmodsi4),
15071511
RuntimeLibcallPredicate<[{TT.isOSBinFormatMachO() &&
15081512
(!TT.isiOS() || !TT.isOSVersionLT(5, 0))}]>>,
1509-
has__stack_chk_fail)> {
1513+
DefaultStackProtector)> {
15101514
let DefaultLibcallCallingConv = LibcallCallingConv<[{
15111515
(!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) ?
15121516
(FloatABI == FloatABI::Hard ? CallingConv::ARM_AAPCS_VFP
@@ -2015,7 +2019,7 @@ def PPCSystemLibrary
20152019
LibmHasSinCosPPCF128,
20162020
AvailableIf<memcpy, isNotAIX>,
20172021
LibcallImpls<(add Int128RTLibcalls), isPPC64>,
2018-
has__stack_chk_fail)>;
2022+
DefaultStackProtector)>;
20192023

20202024
//===----------------------------------------------------------------------===//
20212025
// RISCV Runtime Libcalls
@@ -2030,7 +2034,7 @@ def RISCVSystemLibrary
20302034
exp10f, exp10, exp10l_f128,
20312035
__riscv_flush_icache,
20322036
LibcallImpls<(add Int128RTLibcalls), isRISCV64>,
2033-
has__stack_chk_fail)>;
2037+
DefaultStackProtector)>;
20342038

20352039
//===----------------------------------------------------------------------===//
20362040
// SPARC Runtime Libcalls
@@ -2098,7 +2102,7 @@ def SPARCSystemLibrary
20982102
LibcallImpls<(add _Q_qtoll, _Q_qtoull, _Q_lltoq, _Q_ulltoq), isSPARC32>,
20992103
LibcallImpls<(add SPARC64_MulDivCalls, Int128RTLibcalls), isSPARC64>,
21002104
LibmHasSinCosF32, LibmHasSinCosF64, LibmHasSinCosF128,
2101-
has__stack_chk_fail)
2105+
DefaultStackProtector)
21022106
>;
21032107

21042108
//===----------------------------------------------------------------------===//
@@ -2159,7 +2163,7 @@ defvar X86CommonLibcalls =
21592163
// FIXME: MSVCRT doesn't have powi. The f128 case is added as a
21602164
// hack for one test relying on it.
21612165
__powitf2_f128,
2162-
has__stack_chk_fail
2166+
DefaultStackProtector
21632167
);
21642168

21652169
defvar Windows32DivRemMulCalls =
@@ -2328,5 +2332,5 @@ def LegacyDefaultSystemLibrary
23282332
exp10f, exp10, exp10l_f128,
23292333
__powisf2, __powidf2, __powitf2_f128,
23302334
LibcallImpls<(add Int128RTLibcalls), isArch64Bit>,
2331-
has__stack_chk_fail
2335+
DefaultStackProtector
23322336
)>;

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
7676
if (ExceptionModel == ExceptionHandling::SjLj)
7777
setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
7878

79-
if (TT.isOSOpenBSD())
80-
setLibcallImpl(RTLIB::STACK_SMASH_HANDLER, RTLIB::__stack_smash_handler);
81-
8279
if (TT.isARM() || TT.isThumb()) {
8380
setARMLibcallNames(*this, TT, FloatABI, EABIVersion);
8481
return;

0 commit comments

Comments
 (0)