Index: include/llvm/MC/MCAsmInfoELF.h =================================================================== --- include/llvm/MC/MCAsmInfoELF.h +++ include/llvm/MC/MCAsmInfoELF.h @@ -19,6 +19,12 @@ protected: MCAsmInfoELF(); + + /// Targets which have non-executable stacks by default can override this + /// to disable the special section which requests a non-executable stack. + virtual bool usesNonexecutableStackSection() const { + return true; + } }; } Index: lib/MC/MCAsmInfoELF.cpp =================================================================== --- lib/MC/MCAsmInfoELF.cpp +++ lib/MC/MCAsmInfoELF.cpp @@ -21,6 +21,8 @@ void MCAsmInfoELF::anchor() { } MCSection *MCAsmInfoELF::getNonexecutableStackSection(MCContext &Ctx) const { + if (!usesNonexecutableStackSection()) + return nullptr; return Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS, 0); } Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.h =================================================================== --- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.h +++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.h @@ -22,6 +22,8 @@ class Triple; class WebAssemblyMCAsmInfo final : public MCAsmInfoELF { + bool usesNonexecutableStackSection() const override; + public: explicit WebAssemblyMCAsmInfo(const Triple &T); ~WebAssemblyMCAsmInfo() override; Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp =================================================================== --- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp +++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp @@ -45,3 +45,10 @@ // TODO: UseIntegratedAssembler? } + +bool +WebAssemblyMCAsmInfo::usesNonexecutableStackSection() const { + // In WebAssembly the stack is never executable, so it isn't necessary to + // declare this in the object file. + return false; +}