blob: e08efbd64382717b21fb0d0d418cc6129580ca0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
diff --git i/lib/Driver/ToolChains.cpp w/lib/Driver/ToolChains.cpp
index e3ff0d7..68ed764 100644
--- i/lib/Driver/ToolChains.cpp
+++ w/lib/Driver/ToolChains.cpp
@@ -3408,6 +3408,13 @@ bool Linux::isPIEDefault() const {
return getSanitizerArgs().requiresPIE();
}
+unsigned Linux::GetDefaultStackProtectorLevel(bool KernelOrKext) const {
+ StringRef VendorName = Linux::getTriple().getVendorName();
+ if (VendorName.compare("alpine") == 0)
+ return 2;
+ return 1;
+}
+
/// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple, const ArgList &Args)
diff --git i/lib/Driver/ToolChains.h w/lib/Driver/ToolChains.h
index 47fb10d..3714a6f 100644
--- i/lib/Driver/ToolChains.h
+++ w/lib/Driver/ToolChains.h
@@ -641,6 +641,7 @@ public:
AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
bool isPIEDefault() const override;
+ unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override;
std::string Linker;
std::vector<std::string> ExtraOpts;
diff --git i/test/Driver/stack-protector.c w/test/Driver/stack-protector.c
index 7fecd1b..f29cee0 100644
--- i/test/Driver/stack-protector.c
+++ w/test/Driver/stack-protector.c
@@ -23,3 +23,18 @@
// RUN: %clang -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=SSP-ALL
// SSP-ALL: "-stack-protector" "3"
// SSP-ALL-NOT: "-stack-protector-buffer-size"
+
+// RUN: %clang -target x86_64-alpine-linux-musl -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE
+// ALPINE: "-stack-protector" "2"
+
+// RUN: %clang -target x86_64-alpine-linux-musl -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE_SPS
+// ALPINE_SPS: "-stack-protector" "2"
+
+// RUN: %clang -target x86_64-alpine-linux-musl -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE_ALL
+// ALPINE_ALL: "-stack-protector" "3"
+// ALPINE_ALL-NOT: "-stack-protector-buffer-size"
+
+// RUN: %clang -target x86_64-alpine-linux-musl -fno-stack-protector -### %s 2>&1 | FileCheck %s -check-prefix=ALPINE_NOSSP
+// ALPINE_NOSSP-NOT: "-stack-protector"
+// ALPINE_NOSSP-NOT: "-stack-protector-buffer-size"
+
|