From c3deccbb4f91505e22464e6284d4194124c736c0 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad@comstyle.com>
Date: Fri, 31 Mar 2017 22:13:17 +0000
Subject: [PATCH] Add/update PIE defaults for OpenBSD.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299269 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Driver/ToolChains/CommonArgs.cpp | 4 +++-
 test/Driver/pic.c                    | 4 ++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/Driver/ToolChains/CommonArgs.cpp b/lib/Driver/ToolChains/CommonArgs.cpp
index afe6be773be..e5f4a3b8d60 100644
--- a/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/lib/Driver/ToolChains/CommonArgs.cpp
@@ -737,9 +737,10 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) {
   // OpenBSD-specific defaults for PIE
   if (Triple.getOS() == llvm::Triple::OpenBSD) {
     switch (ToolChain.getArch()) {
+    case llvm::Triple::arm:
+    case llvm::Triple::aarch64:
     case llvm::Triple::mips64:
     case llvm::Triple::mips64el:
-    case llvm::Triple::sparcel:
     case llvm::Triple::x86:
     case llvm::Triple::x86_64:
       IsPICLevelTwo = false; // "-fpie"
@@ -747,6 +748,7 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) {
 
     case llvm::Triple::ppc:
     case llvm::Triple::sparc:
+    case llvm::Triple::sparcel:
     case llvm::Triple::sparcv9:
       IsPICLevelTwo = true; // "-fPIE"
       break;
diff --git a/test/Driver/pic.c b/test/Driver/pic.c
index 9f9d09c54cf..61d752094f6 100644
--- a/test/Driver/pic.c
+++ b/test/Driver/pic.c
@@ -227,6 +227,10 @@
 // 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 aarch64-unknown-openbsd -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE1
+// RUN: %clang -c %s -target arm-unknown-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 \
-- 
GitLab