$OpenBSD: patch-lib_MC_MCELFStreamer_cpp,v 1.4 2021/05/18 03:35:07 rsadowski Exp $

getNonexecutableStackSection() may return nullptr.

Index: lib/MC/MCELFStreamer.cpp
--- lib/MC/MCELFStreamer.cpp.orig
+++ lib/MC/MCELFStreamer.cpp
@@ -92,8 +92,11 @@ void MCELFStreamer::InitSections(bool NoExecStack) {
   SwitchSection(Ctx.getObjectFileInfo()->getTextSection());
   emitCodeAlignment(4);
 
-  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) {
