From 80ec6606b51bca1eae70002ac45057694e8e3166 Mon Sep 17 00:00:00 2001 From: David L Kreitzer Date: Fri, 14 Oct 2016 20:44:33 +0000 Subject: [PATCH] Define Contiki OS toolchain Patch by Michael LeMay Differential revision: http://reviews.llvm.org/D19854 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284278 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Driver.cpp | 3 +++ lib/Driver/ToolChains.cpp | 11 +++++++++++ lib/Driver/ToolChains.h | 8 ++++++++ test/Driver/fsanitize.c | 1 + 4 files changed, 23 insertions(+) diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 459f601814..f2ee1ca5c8 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -3120,6 +3120,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, case llvm::Triple::PS4: TC = new toolchains::PS4CPU(*this, Target, Args); break; + case llvm::Triple::Contiki: + TC = new toolchains::Contiki(*this, Target, Args); + break; default: // Of these targets, Hexagon is the only one that might have // an OS of Linux, in which case it got handled above already. diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index e71aaf36cf..93beab8361 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -5305,3 +5305,14 @@ SanitizerMask PS4CPU::getSupportedSanitizers() const { Res |= SanitizerKind::Vptr; return Res; } + +Contiki::Contiki(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + : Generic_ELF(D, Triple, Args) {} + +SanitizerMask Contiki::getSupportedSanitizers() const { + const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; + SanitizerMask Res = ToolChain::getSupportedSanitizers(); + if (IsX86) + Res |= SanitizerKind::SafeStack; + return Res; +} diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 36773b2181..0838208e3b 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -1249,6 +1249,14 @@ protected: Tool *buildLinker() const override; }; +class LLVM_LIBRARY_VISIBILITY Contiki : public Generic_ELF { +public: + Contiki(const Driver &D, const llvm::Triple &Triple, + const llvm::opt::ArgList &Args); + + SanitizerMask getSupportedSanitizers() const override; +}; + } // end namespace toolchains } // end namespace driver } // end namespace clang diff --git a/test/Driver/fsanitize.c b/test/Driver/fsanitize.c index 1f6664bb08..870a26268d 100644 --- a/test/Driver/fsanitize.c +++ b/test/Driver/fsanitize.c @@ -397,6 +397,7 @@ // 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 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: "-fsanitize=safe-stack" -- 2.40.0