Skip to content

Commit 1ee9092

Browse files
committed
Merging r347179:
------------------------------------------------------------------------ r347179 | brad | 2018-11-18 16:21:06 -0800 (Sun, 18 Nov 2018) | 4 lines [PowerPC] Set the default PLT mode on OpenBSD/powerpc to Secure PLT. OpenBSD/powerpc only supports Secure PLT. ------------------------------------------------------------------------ llvm-svn: 347822
1 parent 9ad6d06 commit 1ee9092

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

clang/lib/Driver/ToolChains/Arch/PPC.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,19 @@ void ppc::getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,
107107
if (FloatABI == ppc::FloatABI::Soft)
108108
Features.push_back("-hard-float");
109109

110-
ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Args);
110+
ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Triple, Args);
111111
if (ReadGOT == ppc::ReadGOTPtrMode::SecurePlt)
112112
Features.push_back("+secure-plt");
113113
}
114114

115-
ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const ArgList &Args) {
115+
ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const llvm::Triple &Triple,
116+
const ArgList &Args) {
116117
if (Args.getLastArg(options::OPT_msecure_plt))
117118
return ppc::ReadGOTPtrMode::SecurePlt;
118-
return ppc::ReadGOTPtrMode::Bss;
119+
if (Triple.isOSOpenBSD())
120+
return ppc::ReadGOTPtrMode::SecurePlt;
121+
else
122+
return ppc::ReadGOTPtrMode::Bss;
119123
}
120124

121125
ppc::FloatABI ppc::getPPCFloatABI(const Driver &D, const ArgList &Args) {

clang/lib/Driver/ToolChains/Arch/PPC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
3838

3939
std::string getPPCTargetCPU(const llvm::opt::ArgList &Args);
4040
const char *getPPCAsmModeForCPU(StringRef Name);
41-
ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D,
41+
ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D, const llvm::Triple &Triple,
4242
const llvm::opt::ArgList &Args);
4343

4444
void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,

clang/test/Driver/openbsd.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,8 @@
112112
// RUN: | FileCheck -check-prefix=CHECK-ARM-FLOAT-ABI %s
113113
// CHECK-ARM-FLOAT-ABI-NOT: "-target-feature" "+soft-float"
114114
// CHECK-ARM-FLOAT-ABI: "-target-feature" "+soft-float-abi"
115+
116+
// Check PowerPC for Secure PLT
117+
// RUN: %clang -target powerpc-unknown-openbsd -### -c %s 2>&1 \
118+
// RUN: | FileCheck -check-prefix=CHECK-POWERPC-SECUREPLT %s
119+
// CHECK-POWERPC-SECUREPLT: "-target-feature" "+secure-plt"

0 commit comments

Comments
 (0)