[PATCH] D159179: [MC][ELF] Don't emit .note.GNU-stack sections on Solaris

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 1 02:21:33 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ef767c07585: [MC][ELF] Don't emit .note.GNU-stack sections on Solaris (authored by ro).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159179/new/

https://reviews.llvm.org/D159179

Files:
  llvm/lib/MC/MCAsmInfoELF.cpp
  llvm/test/CodeGen/X86/execstack.ll


Index: llvm/test/CodeGen/X86/execstack.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/execstack.ll
@@ -0,0 +1,9 @@
+;; Check that .note.GNU-stack sections are emitted on Linux, but not on Solaris.
+
+; RUN: llc < %s -mtriple=i686-linux | FileCheck %s -check-prefix=CHECK-GNUSTACK
+; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s -check-prefix=CHECK-GNUSTACK
+; RUN: llc < %s -mtriple=i386-solaris | FileCheck %s -check-prefix=CHECK-NOGNUSTACK
+; RUN: llc < %s -mtriple=amd64-solaris | FileCheck %s -check-prefix=CHECK-NOGNUSTACK
+
+; CHECK-GNUSTACK: .section	".note.GNU-stack","", at progbits
+; CHECK-NOGNUSTACK-NOT: .section	".note.GNU-stack","", at progbits
Index: llvm/lib/MC/MCAsmInfoELF.cpp
===================================================================
--- llvm/lib/MC/MCAsmInfoELF.cpp
+++ llvm/lib/MC/MCAsmInfoELF.cpp
@@ -21,6 +21,10 @@
 void MCAsmInfoELF::anchor() {}
 
 MCSection *MCAsmInfoELF::getNonexecutableStackSection(MCContext &Ctx) const {
+  // Solaris doesn't know/doesn't care about .note.GNU-stack sections, so
+  // don't emit them.
+  if (Ctx.getTargetTriple().isOSSolaris())
+    return nullptr;
   return Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS, 0);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159179.555311.patch
Type: text/x-patch
Size: 1264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230901/709332e1/attachment.bin>


More information about the llvm-commits mailing list