diff options
author | davidovski <david@davidovski.xyz> | 2022-03-05 23:51:45 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-03-05 23:51:45 +0000 |
commit | 80220d777d783fc0b11c491f0c93eb712d38e427 (patch) | |
tree | e7d84e50f6a3c41c25d8808fa6aa746a24a3a88f /extra/patches/clang/30-Enable-stack-protector-by-default-for-Alpine-Linux.patch | |
parent | 5bbf53467cd7b68557d8e37332968081c64e9908 (diff) |
fixed up js78
Diffstat (limited to 'extra/patches/clang/30-Enable-stack-protector-by-default-for-Alpine-Linux.patch')
-rw-r--r-- | extra/patches/clang/30-Enable-stack-protector-by-default-for-Alpine-Linux.patch | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/extra/patches/clang/30-Enable-stack-protector-by-default-for-Alpine-Linux.patch b/extra/patches/clang/30-Enable-stack-protector-by-default-for-Alpine-Linux.patch new file mode 100644 index 0000000..f2895ce --- /dev/null +++ b/extra/patches/clang/30-Enable-stack-protector-by-default-for-Alpine-Linux.patch @@ -0,0 +1,81 @@ +Based on original patchset from Jakub Jirutka <jakub@jirutka.cz> +Updated by Eric Molitor <eric@molitor.org> +Updated by Natanael Copa <ncopa@alpinelinux.org> +Updated by omni <omni+alpine@hack.org> + +--- a/lib/Driver/ToolChains/Linux.h ++++ b/lib/Driver/ToolChains/Linux.h +@@ -11,6 +11,7 @@ + + #include "Gnu.h" + #include "clang/Driver/ToolChain.h" ++#include "clang/Basic/LangOptions.h" + + namespace clang { + namespace driver { +@@ -38,6 +39,18 @@ + CXXStdlibType GetDefaultCXXStdlibType() const override; + bool isPIEDefault() const override; + bool isNoExecStackDefault() const override; ++ ++ LangOptions::StackProtectorMode ++ GetDefaultStackProtectorLevel(bool KernelOrKext) const override { ++ StringRef VendorName = Linux::getTriple().getVendorName(); ++ if (VendorName.compare("alpine") == 0) ++ return LangOptions::SSPStrong; ++ ++ return LangOptions::SSPOff; ++ } ++ ++ ++ + bool IsMathErrnoDefault() const override; + SanitizerMask getSupportedSanitizers() const override; + void addProfileRTLibs(const llvm::opt::ArgList &Args, +--- a/test/Driver/fsanitize.c ++++ b/test/Driver/fsanitize.c +@@ -667,18 +667,17 @@ + // RUN: %clang -fno-sanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NOSP + // NOSP-NOT: "-fsanitize=safe-stack" + +-// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP ++// RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP + // RUN: %clang -target x86_64-linux-gnu -fsanitize=address,safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP-ASAN + // RUN: %clang -target x86_64-linux-gnu -fstack-protector -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP + // RUN: %clang -target x86_64-linux-gnu -fsanitize=safe-stack -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=SP +-// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP +-// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP ++// RUN: %clang -target arm-linux-androideabi -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP ++// RUN: %clang -target aarch64-linux-android -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=SP + // RUN: %clang -target i386-contiki-unknown -fsanitize=safe-stack -### %s 2>&1 | FileCheck %s -check-prefix=NO-SP + // NO-SP-NOT: stack-protector + // NO-SP: "-fsanitize=safe-stack" + // SP-ASAN: error: invalid argument '-fsanitize=safe-stack' not allowed with '-fsanitize=address' + // SP: "-fsanitize=safe-stack" +-// SP: -stack-protector + // NO-SP-NOT: stack-protector + + // RUN: %clang -target powerpc64-unknown-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-SANM +--- a/test/Driver/stack-protector.c ++++ b/test/Driver/stack-protector.c +@@ -35,6 +35,20 @@ + + // Test default stack protector values for Darwin platforms + ++// 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" ++ + // RUN: %clang -target armv7k-apple-watchos2.0 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_WATCHOS + // RUN: %clang -ffreestanding -target armv7k-apple-watchos2.0 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_WATCHOS + // SSP_WATCHOS: "-stack-protector" "1" |