[clang] 062ef8f - [Driver][Android] Remove unneeded isNoExecStackDefault
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 17 18:15:28 PST 2021
Author: Fangrui Song
Date: 2021-11-17T18:15:24-08:00
New Revision: 062ef8f6b472a71685941391ab93bfd68ce93d71
URL: https://github.com/llvm/llvm-project/commit/062ef8f6b472a71685941391ab93bfd68ce93d71
DIFF: https://github.com/llvm/llvm-project/commit/062ef8f6b472a71685941391ab93bfd68ce93d71.diff
LOG: [Driver][Android] Remove unneeded isNoExecStackDefault
ld.lld used by Android ignores .note.GNU-stack and defaults to noexecstack,
so the `-z noexecstack` linker option is unneeded.
The `--noexecstack` assembler option is unneeded because AsmPrinter.cpp
prints `.section .note.GNU-stack,"", at progbits` (when `llvm.init.trampoline` is unused),
so the assembler won't synthesize an executable .note.GNU-stack.
Reviewed By: danalbert
Differential Revision: https://reviews.llvm.org/D113840
Added:
Modified:
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/lib/Driver/ToolChains/Linux.h
clang/test/Driver/integrated-as.c
clang/test/Driver/linux-as.c
clang/test/Driver/linux-ld.c
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h
index abd87685f7c59..dad861d586cb5 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -487,9 +487,6 @@ class ToolChain {
/// Test whether this toolchain defaults to PIE.
virtual bool isPIEDefault(const llvm::opt::ArgList &Args) const = 0;
- /// Test whether this toolchaind defaults to non-executable stacks.
- virtual bool isNoExecStackDefault() const;
-
/// Tests whether this toolchain forces its default for PIC, PIE or
/// non-PIC. If this returns true, any PIC related flags should be ignored
/// and instead the results of \c isPICDefault() and \c isPIEDefault(const
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index d9fcff73213b6..6588cdf9fecd1 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -110,10 +110,6 @@ bool ToolChain::useRelaxRelocations() const {
return ENABLE_X86_RELAX_RELOCATIONS;
}
-bool ToolChain::isNoExecStackDefault() const {
- return false;
-}
-
SanitizerArgs
ToolChain::getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const {
SanitizerArgs SanArgs(*this, JobArgs, !SanitizerArgsChecked);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index bcf3d41b585fd..88e1764a9dadd 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2439,7 +2439,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
bool TakeNextArg = false;
bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
- bool UseNoExecStack = C.getDefaultToolChain().isNoExecStackDefault();
+ bool UseNoExecStack = false;
const char *MipsTargetFeature = nullptr;
StringRef ImplicitIt;
for (const Arg *A :
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index de74334f0166c..7aeadd84dfee8 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -429,11 +429,6 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("text");
}
- if (ToolChain.isNoExecStackDefault()) {
- CmdArgs.push_back("-z");
- CmdArgs.push_back("noexecstack");
- }
-
if (Args.hasArg(options::OPT_rdynamic))
CmdArgs.push_back("-export-dynamic");
@@ -707,10 +702,6 @@ void tools::gnutools::Assembler::ConstructJob(Compilation &C,
}
}
- if (getToolChain().isNoExecStackDefault()) {
- CmdArgs.push_back("--noexecstack");
- }
-
switch (getToolChain().getArch()) {
default:
break;
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 83b1e2b1df97a..0224383e63a1a 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -680,10 +680,6 @@ bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList &Args) const {
return true;
}
-bool Linux::isNoExecStackDefault() const {
- return getTriple().isAndroid();
-}
-
bool Linux::IsMathErrnoDefault() const {
if (getTriple().isAndroid())
return false;
diff --git a/clang/lib/Driver/ToolChains/Linux.h b/clang/lib/Driver/ToolChains/Linux.h
index 0f11b1a7faaff..a5ec33bd44f10 100644
--- a/clang/lib/Driver/ToolChains/Linux.h
+++ b/clang/lib/Driver/ToolChains/Linux.h
@@ -44,7 +44,6 @@ class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
bool
IsAArch64OutlineAtomicsDefault(const llvm::opt::ArgList &Args) const override;
bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
- bool isNoExecStackDefault() const override;
bool IsMathErrnoDefault() const override;
SanitizerMask getSupportedSanitizers() const override;
void addProfileRTLibs(const llvm::opt::ArgList &Args,
diff --git a/clang/test/Driver/integrated-as.c b/clang/test/Driver/integrated-as.c
index 170515579b1ac..dfd669a626bde 100644
--- a/clang/test/Driver/integrated-as.c
+++ b/clang/test/Driver/integrated-as.c
@@ -14,8 +14,3 @@
// NOFIAS: -cc1
// NOFIAS: "-fno-verbose-asm"
// NOFIAS: -no-integrated-as
-
-// RUN: %clang -target arm-linux-androideabi -### \
-// RUN: -integrated-as -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix=CHECK-ARM-ANDROID %s
-// CHECK-ARM-ANDROID: "-mnoexecstack"
diff --git a/clang/test/Driver/linux-as.c b/clang/test/Driver/linux-as.c
index 0959bd7ba0a11..8da1dbe595e86 100644
--- a/clang/test/Driver/linux-as.c
+++ b/clang/test/Driver/linux-as.c
@@ -108,12 +108,12 @@
// RUN: %clang -target arm-linux-androideabi -### \
// RUN: -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ARM-ANDROID %s
-// CHECK-ARM-ANDROID: as{{(.exe)?}}" "--noexecstack" "-EL" "-mfloat-abi=soft"
+// CHECK-ARM-ANDROID: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft"
//
// RUN: %clang -target arm-linux-androideabi -march=armv7-a -### \
// RUN: -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ARM-ANDROID-SOFTFP %s
-// CHECK-ARM-ANDROID-SOFTFP: as{{(.exe)?}}" "--noexecstack" "-EL" "-mfloat-abi=softfp" "-march=armv7-a"
+// CHECK-ARM-ANDROID-SOFTFP: as{{(.exe)?}}" "-EL" "-mfloat-abi=softfp" "-march=armv7-a"
//
// RUN: %clang -target arm-linux-eabi -mhard-float -### \
// RUN: -no-integrated-as -c %s 2>&1 \
diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index bbb54c76e6a4d..89fd22f7e8c60 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -989,15 +989,6 @@
// CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
// CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
-// RUN: %clang %s -### -o %t.o 2>&1 \
-// RUN: --target=armv7-linux-android21 \
-// RUN: | FileCheck --check-prefix=CHECK-ANDROID-NOEXECSTACK %s
-// CHECK-ANDROID-NOEXECSTACK: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ANDROID-NOEXECSTACK: "-z" "noexecstack"
-// 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
More information about the cfe-commits
mailing list