1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

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

WebAssembly's stack will never be executable by default, so it isn't
necessary to declare .note.GNU-stack sections to request a non-executable
stack.

Differential Revision: http://reviews.llvm.org/D15969

llvm-svn: 257962
This commit is contained in:
Dan Gohman 2016-01-15 23:59:13 +00:00
parent b31d5d18b5
commit 62a2872518
4 changed files with 19 additions and 0 deletions

View File

@ -18,6 +18,10 @@ class MCAsmInfoELF : public MCAsmInfo {
MCSection *getNonexecutableStackSection(MCContext &Ctx) const final;
protected:
/// Targets which have non-executable stacks by default can set this to false
/// to disable the special section which requests a non-executable stack.
bool UsesNonexecutableStackSection;
MCAsmInfoELF();
};
}

View File

@ -21,6 +21,8 @@ using namespace llvm;
void MCAsmInfoELF::anchor() { }
MCSection *MCAsmInfoELF::getNonexecutableStackSection(MCContext &Ctx) const {
if (!UsesNonexecutableStackSection)
return nullptr;
return Ctx.getELFSection(".note.GNU-stack", ELF::SHT_PROGBITS, 0);
}
@ -29,4 +31,5 @@ MCAsmInfoELF::MCAsmInfoELF() {
WeakRefDirective = "\t.weak\t";
PrivateGlobalPrefix = ".L";
PrivateLabelPrefix = ".L";
UsesNonexecutableStackSection = true;
}

View File

@ -48,4 +48,7 @@ WebAssemblyMCAsmInfo::WebAssemblyMCAsmInfo(const Triple &T) {
ExceptionsType = ExceptionHandling::None;
// TODO: UseIntegratedAssembler?
// WebAssembly's stack is never executable.
UsesNonexecutableStackSection = false;
}

View File

@ -0,0 +1,9 @@
; RUN: llc < %s -asm-verbose=false | FileCheck %s
; Test that we don't emit anything declaring a non-executable stack,
; because wasm's stack is always non-executable.
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
; CHECK-NOT: .note.GNU-stack