Index: include/llvm/MC/MCAsmInfoELF.h =================================================================== --- include/llvm/MC/MCAsmInfoELF.h +++ include/llvm/MC/MCAsmInfoELF.h @@ -18,6 +18,10 @@ MCSection *getNonexecutableStackSection(MCContext &Ctx) const final; protected: + /// Targets which have non-executable stacks by default can set this to false + /// to disable the special section which requests a non-executable stack. + bool UsesNonexecutableStackSection; + MCAsmInfoELF(); }; } 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); } @@ -29,4 +31,5 @@ WeakRefDirective = "\t.weak\t"; PrivateGlobalPrefix = ".L"; PrivateLabelPrefix = ".L"; + UsesNonexecutableStackSection = true; } Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp =================================================================== --- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp +++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp @@ -48,4 +48,7 @@ ExceptionsType = ExceptionHandling::None; // TODO: UseIntegratedAssembler? + + // WebAssembly's stack is never executable. + UsesNonexecutableStackSection = false; }