r327165 - Don't use -pie in relocatable link.
Evgeniy Stepanov via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 9 11:35:16 PST 2018
Author: eugenis
Date: Fri Mar 9 11:35:16 2018
New Revision: 327165
URL: http://llvm.org/viewvc/llvm-project?rev=327165&view=rev
Log:
Don't use -pie in relocatable link.
Summary:
Android, in particular, got PIE enabled by default in r316606. It resulted in
relocatable links passing both -r and -pie to the linker, which is not allowed.
Reviewers: srhines
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D44229
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/android-pie.c
Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=327165&r1=327164&r2=327165&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Fri Mar 9 11:35:16 2018
@@ -307,7 +307,8 @@ static const char *getLDMOption(const ll
}
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,
Modified: cfe/trunk/test/Driver/android-pie.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-pie.c?rev=327165&r1=327164&r2=327165&view=diff
==============================================================================
--- cfe/trunk/test/Driver/android-pie.c (original)
+++ cfe/trunk/test/Driver/android-pie.c Fri Mar 9 11:35:16 2018
@@ -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"
More information about the cfe-commits
mailing list