[Driver] Make --execute-only the default for aarch64-fuchsia
authorAlex Brachet <abrachet@google.com>
Tue, 20 Sep 2022 18:25:16 +0000 (18:25 +0000)
committerAlex Brachet <abrachet@google.com>
Tue, 20 Sep 2022 18:25:16 +0000 (18:25 +0000)
Clang already generates code that doesn't use writeable data in executable
sections so the linker flag is all that is necessary.

-Wl,--no-execute-only can be used to turn this default off.

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

clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c

index d63c69c..6f4fa2c 100644 (file)
@@ -87,6 +87,8 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   }
 
   if (ToolChain.getArch() == llvm::Triple::aarch64) {
+    CmdArgs.push_back("--execute-only");
+
     std::string CPU = getCPUName(D, Args, Triple);
     if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
       CmdArgs.push_back("--fix-cortex-a53-843419");
index ce356a4..099a88c 100644 (file)
@@ -41,7 +41,7 @@
 // CHECK: "-pie"
 // CHECK: "--build-id"
 // CHECK: "--hash-style=gnu"
-// CHECK-AARCH64: "--fix-cortex-a53-843419"
+// CHECK-AARCH64: "--execute-only" "--fix-cortex-a53-843419"
 // CHECK: "-dynamic-linker" "ld.so.1"
 // CHECK-RISCV64: "-X"
 // CHECK: Scrt1.o