summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2014-06-24 19:51:29 +0000
committerBrad Smith <brad@comstyle.com>2014-06-24 19:51:29 +0000
commit5b05db864b2fda23f54c751864c0d9a5accaf14d (patch)
tree112d9dace7c91939017c1889ceee56797543d20e /clang
parent740812bb9a4a47dce964f60f8e623a0386335296 (diff)
downloadbcm5719-llvm-5b05db864b2fda23f54c751864c0d9a5accaf14d.tar.gz
bcm5719-llvm-5b05db864b2fda23f54c751864c0d9a5accaf14d.zip
Use appropriate default PIE settings for OpenBSD.
llvm-svn: 211624
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Driver/Tools.cpp21
-rw-r--r--clang/test/Driver/pic.c10
2 files changed, 31 insertions, 0 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index cbc6f2dd859..1488dc69559 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -2432,6 +2432,27 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}
}
+ // OpenBSD-specific defaults for PIE
+ if (getToolChain().getTriple().getOS() == llvm::Triple::OpenBSD) {
+ switch (getToolChain().getTriple().getArch()) {
+ case llvm::Triple::mips64:
+ case llvm::Triple::mips64el:
+ case llvm::Triple::sparc:
+ case llvm::Triple::x86:
+ case llvm::Triple::x86_64:
+ IsPICLevelTwo = false; // "-fpie"
+ break;
+
+ case llvm::Triple::ppc:
+ case llvm::Triple::sparcv9:
+ IsPICLevelTwo = true; // "-fPIE"
+ break;
+
+ default:
+ break;
+ }
+ }
+
// For the PIC and PIE flag options, this logic is different from the
// legacy logic in very old versions of GCC, as that logic was just
// a bug no one had ever fixed. This logic is both more rational and
diff --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
index c3b2bbe32f5..3629cc47357 100644
--- a/clang/test/Driver/pic.c
+++ b/clang/test/Driver/pic.c
@@ -201,7 +201,17 @@
// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
//
// On OpenBSD, PIE is enabled by default, but can be disabled.
+// RUN: %clang -c %s -target amd64-pc-openbsd -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
// RUN: %clang -c %s -target i386-pc-openbsd -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target mips64-unknown-openbsd -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target mips64el-unknown-openbsd -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target powerpc-unknown-openbsd -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
+// RUN: %clang -c %s -target sparc64-unknown-openbsd -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
// RUN: %clang -c %s -target i386-pc-openbsd -fno-pie -### 2>&1 \
// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC
OpenPOWER on IntegriCloud