From: Dan Albert Date: Thu, 11 Oct 2018 20:57:54 +0000 (+0000) Subject: [Driver] Default to `-z now` and `-z relro` on Android. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbf5b5d3fd496422c5b6e87830afd6c9ea9cd0fb;p=clang [Driver] Default to `-z now` and `-z relro` on Android. 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 --- diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp index fc511013cd..7df3da1c83 100644 --- a/lib/Driver/ToolChains/Linux.cpp +++ b/lib/Driver/ToolChains/Linux.cpp @@ -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"); } diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index cb530216fe..6ecbd40af9 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -1255,6 +1255,8 @@ // 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"