[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
Thu Aug 31 01:52:03 PDT 2023
ro updated this revision to Diff 554936.
ro marked an inline comment as done.
ro added a comment.
- Formatting fix.
- Add testcase.
I could add a SPARC testcase, too, but don't think there's much point.
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.554936.patch
Type: text/x-patch
Size: 1264 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230831/749a4917/attachment.bin>
More information about the llvm-commits
mailing list