[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,"",@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
This commit is contained in:
Fangrui Song 2021-11-17 18:15:24 -08:00
parent 254f9311fe
commit 062ef8f6b4
9 changed files with 3 additions and 38 deletions

View File

@ -487,9 +487,6 @@ public:
/// 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

View File

@ -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);

View File

@ -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 :

View File

@ -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;

View File

@ -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;

View File

@ -44,7 +44,6 @@ public:
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,

View File

@ -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"

View File

@ -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 \

View File

@ -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