]> granicus.if.org Git - clang/commitdiff
[Driver] Default to `-z now` and `-z relro` on Android.
authorDan Albert <danalbert@google.com>
Thu, 11 Oct 2018 20:57:54 +0000 (20:57 +0000)
committerDan Albert <danalbert@google.com>
Thu, 11 Oct 2018 20:57:54 +0000 (20:57 +0000)
Summary:
RTLD_LAZY is not supported on Android (though failing to use `-z now`
will work since it is assumed by the loader).

RelRO is required.

Reviewers: srhines, pirama

Reviewed By: srhines

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D53117

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344295 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains/Linux.cpp
test/Driver/linux-ld.c

index fc511013cd016fba4172a003b15a0e3a345bcc88..7df3da1c839fd1fa831e2140aa30880a0d73a5bc 100644 (file)
@@ -229,12 +229,13 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
 
   Distro Distro(D.getVFS());
 
-  if (Distro.IsAlpineLinux()) {
+  if (Distro.IsAlpineLinux() || Triple.isAndroid()) {
     ExtraOpts.push_back("-z");
     ExtraOpts.push_back("now");
   }
 
-  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux()) {
+  if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsAlpineLinux() ||
+      Triple.isAndroid()) {
     ExtraOpts.push_back("-z");
     ExtraOpts.push_back("relro");
   }
index cb530216fe646452e11bfea3df53419af0e5e9cc..6ecbd40af9880549969a5c197f64f55122f878ee 100644 (file)
 // RUN:     --sysroot=%S/Inputs/basic_android_tree/sysroot \
 // RUN:   | FileCheck --check-prefix=CHECK-ANDROID %s
 // CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-ANDROID: "-z" "now"
+// CHECK-ANDROID: "-z" "relro"
 // CHECK-ANDROID: "--enable-new-dtags"
 // CHECK-ANDROID: "{{.*}}{{/|\\\\}}crtbegin_dynamic.o"
 // CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib"