Index: llvm/lib/MC/MCELFStreamer.cpp
--- llvm/lib/MC/MCELFStreamer.cpp.orig
+++ llvm/lib/MC/MCELFStreamer.cpp
@@ -60,8 +60,11 @@ void MCELFStreamer::initSections(bool NoExecStack, con
   emitCodeAlignment(Align(Ctx.getObjectFileInfo()->getTextSectionAlignment()),
                     &STI);
 
-  if (NoExecStack)
-    switchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx));
+  if (NoExecStack) {
+    MCSection *s = Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx);
+    if (s)
+      switchSection(s);
+  }
 }
 
 void MCELFStreamer::emitLabel(MCSymbol *S, SMLoc Loc) {
