[PATCH] D15969: [WebAssembly] Don't create a needless .note.GNU-stack section

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 15:04:39 PST 2016


sunfish updated this revision to Diff 44262.
sunfish added a comment.

As requested here:

http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160104/323230.html

changed to introduce and use a usesNonexecutableStackSection() hook instead.


Repository:
  rL LLVM

http://reviews.llvm.org/D15969

Files:
  include/llvm/MC/MCAsmInfoELF.h
  lib/MC/MCAsmInfoELF.cpp
  lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
  lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.h

Index: lib/MC/MCAsmInfoELF.cpp
===================================================================
--- lib/MC/MCAsmInfoELF.cpp
+++ 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);
 }
 
Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.h
===================================================================
--- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.h
+++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.h
@@ -22,6 +22,8 @@
 class Triple;
 
 class WebAssemblyMCAsmInfo final : public MCAsmInfoELF {
+  bool usesNonexecutableStackSection() const override;
+
 public:
   explicit WebAssemblyMCAsmInfo(const Triple &T);
   ~WebAssemblyMCAsmInfo() override;
Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
===================================================================
--- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
+++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp
@@ -45,3 +45,10 @@
 
   // TODO: UseIntegratedAssembler?
 }
+
+bool
+WebAssemblyMCAsmInfo::usesNonexecutableStackSection() const {
+  // In WebAssembly the stack is never executable, so it isn't necessary to
+  // declare this in the object file.
+  return false;
+}
Index: include/llvm/MC/MCAsmInfoELF.h
===================================================================
--- include/llvm/MC/MCAsmInfoELF.h
+++ include/llvm/MC/MCAsmInfoELF.h
@@ -19,6 +19,12 @@
 
 protected:
   MCAsmInfoELF();
+
+  /// Targets which have non-executable stacks by default can override this
+  /// to disable the special section which requests a non-executable stack.
+  virtual bool usesNonexecutableStackSection() const {
+    return true;
+  }
 };
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15969.44262.patch
Type: text/x-patch
Size: 1937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160107/d1a551fa/attachment.bin>


More information about the llvm-commits mailing list