aboutsummaryrefslogtreecommitdiffstats
path: root/main/clang/0005-Enable-PIE-by-default-for-Alpine-Linux.patch
diff options
context:
space:
mode:
authorxentec <xentec@aix0.eu>2017-10-23 18:27:32 +0200
committerJakub Jirutka <jakub@jirutka.cz>2017-11-14 18:42:44 +0100
commit60c32c79a11ee7715f20aeebd381299120c43eb0 (patch)
tree22de0e87cb31a859622fce93eec1afca6440a348 /main/clang/0005-Enable-PIE-by-default-for-Alpine-Linux.patch
parentb4767fa4037857bb3393650e351e69d16a5d7e56 (diff)
downloadaports-60c32c79a11ee7715f20aeebd381299120c43eb0.tar.bz2
aports-60c32c79a11ee7715f20aeebd381299120c43eb0.tar.xz
main/clang: upgrade to 5.0.0
Diffstat (limited to 'main/clang/0005-Enable-PIE-by-default-for-Alpine-Linux.patch')
-rw-r--r--main/clang/0005-Enable-PIE-by-default-for-Alpine-Linux.patch69
1 files changed, 69 insertions, 0 deletions
diff --git a/main/clang/0005-Enable-PIE-by-default-for-Alpine-Linux.patch b/main/clang/0005-Enable-PIE-by-default-for-Alpine-Linux.patch
new file mode 100644
index 0000000000..782419ab44
--- /dev/null
+++ b/main/clang/0005-Enable-PIE-by-default-for-Alpine-Linux.patch
@@ -0,0 +1,69 @@
+From bb174d2f1fd3b936c1c8b75b83c6fb15b3dece2c Mon Sep 17 00:00:00 2001
+From: Jakub Jirutka <jakub@jirutka.cz>
+Date: Sun, 16 Apr 2017 16:49:00 +0100
+Subject: [PATCH 5/7] Enable PIE by default for Alpine Linux
+
+Alpine Linux uses PIE by default.
+---
+ lib/Driver/ToolChains/Gnu.cpp | 4 +++-
+ lib/Driver/ToolChains/Linux.cpp | 5 ++++-
+ test/Driver/pic.c | 12 ++++++++++++
+ 3 files changed, 19 insertions(+), 2 deletions(-)
+
+diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp
+index 40ad3f5..842afb9 100644
+--- a/lib/Driver/ToolChains/Gnu.cpp
++++ b/lib/Driver/ToolChains/Gnu.cpp
+@@ -443,7 +443,9 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
+ if (!D.SysRoot.empty())
+ CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
+
+- if (IsPIE)
++ if (Args.hasArg(options::OPT_nopie))
++ CmdArgs.push_back("-nopie");
++ else if (IsPIE)
+ CmdArgs.push_back("-pie");
+
+ if (Args.hasArg(options::OPT_rdynamic))
+diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp
+index 9eea3f0..ce9cf35 100644
+--- a/lib/Driver/ToolChains/Linux.cpp
++++ b/lib/Driver/ToolChains/Linux.cpp
+@@ -819,7 +819,10 @@ void Linux::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
+ }
+ }
+
+-bool Linux::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); }
++bool Linux::isPIEDefault() const {
++ return getSanitizerArgs().requiresPIE() ||
++ Linux::getTriple().getVendorName().compare("alpine") == 0;
++}
+
+ SanitizerMask Linux::getSupportedSanitizers() const {
+ const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+diff --git a/test/Driver/pic.c b/test/Driver/pic.c
+index 6b01c58..0643edd 100644
+--- a/test/Driver/pic.c
++++ b/test/Driver/pic.c
+@@ -251,6 +251,18 @@
+ // RUN: %clang %s -target i386-pc-openbsd -no-pie -### 2>&1 \
+ // RUN: | FileCheck %s --check-prefix=CHECK-NOPIE-LD
+ //
++// On Alpine Linux, we want similar PIE-by-default behavior
++// RUN: %clang -c %s -target x86_64-alpine-linux-musl -### 2>&1 \
++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
++// RUN: %clang -c %s -target i686-alpine-linux-musl -### 2>&1 \
++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
++// RUN: %clang -c %s -target armv6-alpine-linux-musleabihf -### 2>&1 \
++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
++// RUN: %clang -c %s -target armv7-alpine-linux-musleabihf -### 2>&1 \
++// RUN: | FileCheck %s --check-prefix=CHECK-PIE2
++// RUN: %clang %s -target x86_64-alpine-linux-musl -nopie -### 2>&1 \
++// RUN: | FileCheck %s --check-prefix=CHECK-NOPIE-LD
++//
+ // On Android PIC is enabled by default
+ // RUN: %clang -c %s -target i686-linux-android -### 2>&1 \
+ // RUN: | FileCheck %s --check-prefix=CHECK-PIC2
+--
+2.14.1
+