From: Strahinja Petrovic Date: Wed, 11 Apr 2018 12:24:44 +0000 (+0000) Subject: [PowerPC] Option for secure plt mode X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=269a6e7952fcf76a1442b36c76729d2b554c6663;p=platform%2Fupstream%2Fllvm.git [PowerPC] Option for secure plt mode This patch enables option for secure plt mode in clang (-msecure-plt). Differential Revision: https://reviews.llvm.org/D44921 llvm-svn: 329795 --- diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index e2c503b..ab9335a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1957,6 +1957,7 @@ def maltivec : Flag<["-"], "maltivec">, Group; def mno_altivec : Flag<["-"], "mno-altivec">, Group; def mvsx : Flag<["-"], "mvsx">, Group; def mno_vsx : Flag<["-"], "mno-vsx">, Group; +def msecure_plt : Flag<["-"], "msecure-plt">, Group; def mpower8_vector : Flag<["-"], "mpower8-vector">, Group; def mno_power8_vector : Flag<["-"], "mno-power8-vector">, diff --git a/clang/lib/Driver/ToolChains/Arch/PPC.cpp b/clang/lib/Driver/ToolChains/Arch/PPC.cpp index 7c7e1c7..f6a9596 100644 --- a/clang/lib/Driver/ToolChains/Arch/PPC.cpp +++ b/clang/lib/Driver/ToolChains/Arch/PPC.cpp @@ -106,6 +106,16 @@ void ppc::getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple, ppc::FloatABI FloatABI = ppc::getPPCFloatABI(D, Args); if (FloatABI == ppc::FloatABI::Soft) Features.push_back("-hard-float"); + + ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Args); + if (ReadGOT == ppc::ReadGOTPtrMode::SecurePlt) + Features.push_back("+secure-plt"); +} + +ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const ArgList &Args) { + if (Args.getLastArg(options::OPT_msecure_plt)) + return ppc::ReadGOTPtrMode::SecurePlt; + return ppc::ReadGOTPtrMode::Bss; } ppc::FloatABI ppc::getPPCFloatABI(const Driver &D, const ArgList &Args) { diff --git a/clang/lib/Driver/ToolChains/Arch/PPC.h b/clang/lib/Driver/ToolChains/Arch/PPC.h index 7d7c681..7eb675c 100644 --- a/clang/lib/Driver/ToolChains/Arch/PPC.h +++ b/clang/lib/Driver/ToolChains/Arch/PPC.h @@ -29,10 +29,17 @@ enum class FloatABI { Hard, }; +enum class ReadGOTPtrMode { + Bss, + SecurePlt, +}; + FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args); std::string getPPCTargetCPU(const llvm::opt::ArgList &Args); const char *getPPCAsmModeForCPU(StringRef Name); +ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D, + const llvm::opt::ArgList &Args); void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args, diff --git a/clang/test/Driver/ppc-features.cpp b/clang/test/Driver/ppc-features.cpp index 621c407..1cb6cee 100644 --- a/clang/test/Driver/ppc-features.cpp +++ b/clang/test/Driver/ppc-features.cpp @@ -22,6 +22,10 @@ // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -mhard-float -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTHARD %s // CHECK-SOFTHARD-NOT: "-target-feature" "-hard-float" +// check -msecure-plt option for ppc32 +// RUN: %clang -target powerpc-unknown-linux-gnu -msecure-plt %s -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SECUREPLT %s +// CHECK-SECUREPLT: "-target-feature" "+secure-plt" + // check -mfloat-abi=x option // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'