diff options
author | Chris Lattner <sabre@nondot.org> | 2010-01-23 07:21:06 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-01-23 07:21:06 +0000 |
commit | 76bdea32900ab533b0c059ec8b71fff59c919632 (patch) | |
tree | 2251dacb7d096950344e3ac66269bf2b071110dd /llvm/lib | |
parent | e244ff35d851cbb3386e13274b80f3f01ebe2c45 (diff) | |
download | bcm5719-llvm-76bdea32900ab533b0c059ec8b71fff59c919632.tar.gz bcm5719-llvm-76bdea32900ab533b0c059ec8b71fff59c919632.zip |
resolve a fixme: the "nonexecutable stack directive" is actually
a .section. Switch to it with SwitchSection.
However, I think that this directive should be safe on any ELF target.
If so, we should hoist it up out of the X86 and SystemZ targets.
llvm-svn: 94298
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/MC/MCAsmInfo.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCAsmInfoDarwin.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZMCAsmInfo.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZMCAsmInfo.h | 3 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86MCAsmInfo.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86MCAsmInfo.h | 1 |
7 files changed, 17 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 7238a52f039..fc2c5a00dae 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -345,11 +345,8 @@ bool AsmPrinter::doFinalization(Module &M) { // to be executable. Some targets have a directive to declare this. Function *InitTrampolineIntrinsic = M.getFunction("llvm.init.trampoline"); if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->use_empty()) - // FIXME: This is actually a section switch on linux/x86 and systemz, use - // switch section. - if (MAI->getNonexecutableStackDirective()) - O << MAI->getNonexecutableStackDirective() << '\n'; - + if (MCSection *S = MAI->getNonexecutableStackSection(OutContext)) + OutStreamer.SwitchSection(S); // Allow the target to emit any magic that it wants at the end of the file, // after everything else has gone out. diff --git a/llvm/lib/MC/MCAsmInfo.cpp b/llvm/lib/MC/MCAsmInfo.cpp index debccaf4b16..b96b4e9156f 100644 --- a/llvm/lib/MC/MCAsmInfo.cpp +++ b/llvm/lib/MC/MCAsmInfo.cpp @@ -19,9 +19,9 @@ using namespace llvm; MCAsmInfo::MCAsmInfo() { + HasSubsectionsViaSymbols = false; HasMachoZeroFillDirective = false; HasStaticCtorDtorReferenceInStaticMode = false; - NonexecutableStackDirective = 0; NeedsSet = false; MaxInstLength = 4; PCSymbol = "$"; diff --git a/llvm/lib/MC/MCAsmInfoDarwin.cpp b/llvm/lib/MC/MCAsmInfoDarwin.cpp index 8495aa44eca..9902f501e47 100644 --- a/llvm/lib/MC/MCAsmInfoDarwin.cpp +++ b/llvm/lib/MC/MCAsmInfoDarwin.cpp @@ -24,6 +24,7 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() { NeedsSet = true; AllowQuotesInName = true; HasSingleParameterDotFile = false; + HasSubsectionsViaSymbols = true; AlignmentIsInBytes = false; InlineAsmStart = " InlineAsm Start"; diff --git a/llvm/lib/Target/SystemZ/SystemZMCAsmInfo.cpp b/llvm/lib/Target/SystemZ/SystemZMCAsmInfo.cpp index 8ea11c95b27..ba392bb4d55 100644 --- a/llvm/lib/Target/SystemZ/SystemZMCAsmInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZMCAsmInfo.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "SystemZMCAsmInfo.h" +#include "llvm/MC/MCSectionELF.h" using namespace llvm; SystemZMCAsmInfo::SystemZMCAsmInfo(const Target &T, const StringRef &TT) { @@ -21,6 +22,9 @@ SystemZMCAsmInfo::SystemZMCAsmInfo(const Target &T, const StringRef &TT) { WeakRefDirective = "\t.weak\t"; SetDirective = "\t.set\t"; PCSymbol = "."; +} - NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits"; +MCSection *SystemZMCAsmInfo::getNonexecutableStackSection(MCContext &Ctx) const{ + return MCSectionELF::Create(".note.GNU-stack", MCSectionELF::SHT_PROGBITS, + 0, SectionKind::getMetadata(), false, Ctx); } diff --git a/llvm/lib/Target/SystemZ/SystemZMCAsmInfo.h b/llvm/lib/Target/SystemZ/SystemZMCAsmInfo.h index 3bebcb74e37..00cb99b34c0 100644 --- a/llvm/lib/Target/SystemZ/SystemZMCAsmInfo.h +++ b/llvm/lib/Target/SystemZ/SystemZMCAsmInfo.h @@ -22,8 +22,9 @@ namespace llvm { struct SystemZMCAsmInfo : public MCAsmInfo { explicit SystemZMCAsmInfo(const Target &T, const StringRef &TT); + virtual MCSection *getNonexecutableStackSection(MCContext &Ctx) const; }; - + } // namespace llvm #endif diff --git a/llvm/lib/Target/X86/X86MCAsmInfo.cpp b/llvm/lib/Target/X86/X86MCAsmInfo.cpp index 001ce807286..1738d495842 100644 --- a/llvm/lib/Target/X86/X86MCAsmInfo.cpp +++ b/llvm/lib/Target/X86/X86MCAsmInfo.cpp @@ -14,6 +14,7 @@ #include "X86MCAsmInfo.h" #include "X86TargetMachine.h" #include "llvm/ADT/Triple.h" +#include "llvm/MC/MCSectionELF.h" #include "llvm/Support/CommandLine.h" using namespace llvm; @@ -87,10 +88,11 @@ X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &Triple) { // Exceptions handling ExceptionsType = ExceptionHandling::Dwarf; AbsoluteEHSectionOffsets = false; +} - // On Linux we must declare when we can use a non-executable stack. - if (Triple.getOS() == Triple::Linux) - NonexecutableStackDirective = "\t.section\t.note.GNU-stack,\"\",@progbits"; +MCSection *X86ELFMCAsmInfo::getNonexecutableStackSection(MCContext &Ctx) const { + return MCSectionELF::Create(".note.GNU-stack", MCSectionELF::SHT_PROGBITS, + 0, SectionKind::getMetadata(), false, Ctx); } X86MCAsmInfoCOFF::X86MCAsmInfoCOFF(const Triple &Triple) { diff --git a/llvm/lib/Target/X86/X86MCAsmInfo.h b/llvm/lib/Target/X86/X86MCAsmInfo.h index 18e2bdbcba9..ca227b7a0ba 100644 --- a/llvm/lib/Target/X86/X86MCAsmInfo.h +++ b/llvm/lib/Target/X86/X86MCAsmInfo.h @@ -27,6 +27,7 @@ namespace llvm { struct X86ELFMCAsmInfo : public MCAsmInfo { explicit X86ELFMCAsmInfo(const Triple &Triple); + virtual MCSection *getNonexecutableStackSection(MCContext &Ctx) const; }; struct X86MCAsmInfoCOFF : public MCAsmInfoCOFF { |