Index: llvm/trunk/include/llvm/MC/MCAsmInfoELF.h =================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfoELF.h +++ llvm/trunk/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: llvm/trunk/lib/MC/MCAsmInfoELF.cpp =================================================================== --- llvm/trunk/lib/MC/MCAsmInfoELF.cpp +++ llvm/trunk/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: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp +++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp @@ -48,4 +48,7 @@ ExceptionsType = ExceptionHandling::None; // TODO: UseIntegratedAssembler? + + // WebAssembly's stack is never executable. + UsesNonexecutableStackSection = false; } Index: llvm/trunk/test/CodeGen/WebAssembly/non-executable-stack.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/non-executable-stack.ll +++ llvm/trunk/test/CodeGen/WebAssembly/non-executable-stack.ll @@ -0,0 +1,9 @@ +; RUN: llc < %s -asm-verbose=false | FileCheck %s + +; Test that we don't emit anything declaring a non-executable stack, +; because wasm's stack is always non-executable. + +target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" +target triple = "wasm32-unknown-unknown" + +; CHECK-NOT: .note.GNU-stack