r357296 - [Driver] Use --warn-shared-textrel for Android.
Dan Albert via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 29 11:34:25 PDT 2019
Author: danalbert
Date: Fri Mar 29 11:34:25 2019
New Revision: 357296
URL: http://llvm.org/viewvc/llvm-project?rev=357296&view=rev
Log:
[Driver] Use --warn-shared-textrel for Android.
Android does not allow shared text relocations. Enable the linker
warning to detect them by default.
Reviewers: srhines, pirama
Reviewed By: srhines
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D53344
Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/linux-ld.c
Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=357296&r1=357295&r2=357296&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Fri Mar 29 11:34:25 2019
@@ -387,6 +387,11 @@ void tools::gnutools::Linker::ConstructJ
CmdArgs.push_back("--fix-cortex-a53-843419");
}
+ // Android does not allow shared text relocations. Emit a warning if the
+ // user's code contains any.
+ if (isAndroid)
+ CmdArgs.push_back("--warn-shared-textrel");
+
for (const auto &Opt : ToolChain.ExtraOpts)
CmdArgs.push_back(Opt.c_str());
Modified: cfe/trunk/test/Driver/linux-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=357296&r1=357295&r2=357296&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Fri Mar 29 11:34:25 2019
@@ -1006,7 +1006,13 @@
// CHECK-ANDROID-NOEXECSTACK-NOT: "-z" "execstack"
// CHECK-ANDROID-NOEXECSTACK-NOT: "-z,execstack"
// CHECK-ANDROID-NOEXECSTACK-NOT: "-zexecstack"
-//
+
++// RUN: %clang %s -### -o %t.o 2>&1 \
++// RUN: --target=armv7-linux-android21 \
++// RUN: | FileCheck --check-prefix=CHECK-ANDROID-WARN-SHARED-TEXTREL %s
++// CHECK-ANDROID-WARN-SHARED-TEXTREL: "{{.*}}ld{{(.exe)?}}"
++// CHECK-ANDROID-WARN-SHARED-TEXTREL: "--warn-shared-textrel"
+
// RUN: %clang %s -### -o %t.o 2>&1 --target=mips64-linux-gnuabin32 \
// RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-GNUABIN32 %s
// CHECK-MIPS64EL-GNUABIN32: "{{.*}}ld{{(.exe)?}}"
More information about the cfe-commits
mailing list