[PATCH] D44229: Don't use -pie in relocatable link.

Evgenii Stepanov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 9 11:37:40 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC327165: Don't use -pie in relocatable link. (authored by eugenis, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44229?vs=137493&id=137809#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44229

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/android-pie.c


Index: test/Driver/android-pie.c
===================================================================
--- test/Driver/android-pie.c
+++ test/Driver/android-pie.c
@@ -64,3 +64,20 @@
 // RUN:   | FileCheck --check-prefix=NO-PIE %s
 // RUN: %clang %s -### -o %t.o 2>&1 -pie -no-pie --target=arm-linux-androideabi24 \
 // RUN:   | FileCheck --check-prefix=NO-PIE %s
+
+// Static/shared/relocatable disable -pie
+
+// RUN: %clang %s -### --target=aarch64-linux-android -static 2>&1 \
+// RUN:     | FileCheck %s -check-prefix=CHECK-STATIC
+// CHECK-STATIC-NOT: "-pie"
+// CHECK-STATIC: -static
+
+// RUN: %clang %s -### --target=aarch64-linux-android -shared 2>&1 \
+// RUN:     | FileCheck %s -check-prefix=CHECK-SHARED
+// CHECK-SHARED-NOT: "-pie"
+// CHECK-SHARED: "-shared"
+
+// RUN: %clang %s -### --target=aarch64-linux-android -r 2>&1 \
+// RUN:     | FileCheck %s -check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE-NOT: "-pie"
+// CHECK-RELOCATABLE: "-r"
Index: lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -307,7 +307,8 @@
 }
 
 static bool getPIE(const ArgList &Args, const toolchains::Linux &ToolChain) {
-  if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static))
+  if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static) ||
+      Args.hasArg(options::OPT_r))
     return false;
 
   Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44229.137809.patch
Type: text/x-patch
Size: 1518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180309/c2bcb9ae/attachment.bin>


More information about the cfe-commits mailing list