Remove duplicated info on what .text, .data and .bss look like.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 23 Jan 2014 22:49:25 +0000 (22:49 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 23 Jan 2014 22:49:25 +0000 (22:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199951 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCELFStreamer.h
lib/CodeGen/LLVMTargetMachine.cpp
lib/MC/MCELFStreamer.cpp
lib/MC/MCMachOStreamer.cpp
lib/MC/WinCOFFStreamer.cpp

index 4e24dcfacd507d9a07e2ad1c2ff211583dce2677..72b7075c6fc64e0b5be2a6b0b056af4cb8c0e464 100644 (file)
@@ -108,9 +108,6 @@ private:
 
   SmallPtrSet<MCSymbol *, 16> BindingExplicitlySet;
 
-
-  void SetSection(StringRef Section, unsigned Type, unsigned Flags,
-                  SectionKind Kind);
   void SetSectionData();
   void SetSectionText();
   void SetSectionBss();
index 27a4022ff71d9e6ed7ca117875fe66fcf973e154..2a92e2312a2b4fa99c26f00669f5e621545ec88b 100644 (file)
@@ -283,7 +283,6 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM,
                                                        *MAB, Out, MCE,
                                                        hasMCRelaxAll(),
                                                        hasMCNoExecStack()));
-  AsmStreamer.get()->InitSections();
 
   // Create the AsmPrinter, which takes ownership of AsmStreamer if successful.
   FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer);
index 180a58cf6d144df6c268af98eed5730c12013766..5fbbdd4b3e936c8d0d7a8a79dd6066b2dce9fb79 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/MC/MCELFSymbolFlags.h"
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCObjectFileInfo.h"
 #include "llvm/MC/MCObjectStreamer.h"
 #include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCSectionELF.h"
 
 using namespace llvm;
 
-
-inline void MCELFStreamer::SetSection(StringRef Section, unsigned Type,
-                                      unsigned Flags, SectionKind Kind) {
-  SwitchSection(getContext().getELFSection(Section, Type, Flags, Kind));
-}
-
 inline void MCELFStreamer::SetSectionData() {
-  SetSection(".data",
-             ELF::SHT_PROGBITS,
-             ELF::SHF_WRITE | ELF::SHF_ALLOC,
-             SectionKind::getDataRel());
+  SwitchSection(getContext().getObjectFileInfo()->getDataSection());
   EmitCodeAlignment(4, 0);
 }
 
 inline void MCELFStreamer::SetSectionText() {
-  SetSection(".text",
-             ELF::SHT_PROGBITS,
-             ELF::SHF_EXECINSTR | ELF::SHF_ALLOC,
-             SectionKind::getText());
+  SwitchSection(getContext().getObjectFileInfo()->getTextSection());
   EmitCodeAlignment(4, 0);
 }
 
 inline void MCELFStreamer::SetSectionBss() {
-  SetSection(".bss",
-             ELF::SHT_NOBITS,
-             ELF::SHF_WRITE | ELF::SHF_ALLOC,
-             SectionKind::getBSS());
+  SwitchSection(getContext().getObjectFileInfo()->getBSSSection());
   EmitCodeAlignment(4, 0);
 }
 
index 2924dcd87630d724b7210ec47f155eb2b7da4c6e..6fe466376671d04ca97f1102bd18cf71c140f99a 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/MC/MCExpr.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCMachOSymbolFlags.h"
+#include "llvm/MC/MCObjectFileInfo.h"
 #include "llvm/MC/MCObjectStreamer.h"
 #include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCSectionMachO.h"
@@ -99,10 +100,7 @@ void MCMachOStreamer::InitSections() {
 }
 
 void MCMachOStreamer::InitToTextSection() {
-  SwitchSection(getContext().getMachOSection(
-                                    "__TEXT", "__text",
-                                    MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 0,
-                                    SectionKind::getText()));
+  SwitchSection(getContext().getObjectFileInfo()->getTextSection());
 }
 
 void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
@@ -335,9 +333,7 @@ void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
 void MCMachOStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
                                             unsigned ByteAlignment) {
   // '.lcomm' is equivalent to '.zerofill'.
-  return EmitZerofill(getContext().getMachOSection("__DATA", "__bss",
-                                                   MCSectionMachO::S_ZEROFILL,
-                                                   0, SectionKind::getBSS()),
+  return EmitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(),
                       Symbol, Size, ByteAlignment);
 }
 
index cb4e9b1c37b99c14618fe9d2fb158e797e8e4919..b7d55741456a20e73394b47bb58e5c374fe33c71 100644 (file)
@@ -20,6 +20,7 @@
 #include "llvm/MC/MCCodeEmitter.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCObjectFileInfo.h"
 #include "llvm/MC/MCObjectStreamer.h"
 #include "llvm/MC/MCSection.h"
 #include "llvm/MC/MCSectionCOFF.h"
@@ -95,25 +96,16 @@ private:
     DF->getContents().append(Code.begin(), Code.end());
   }
 
-  const MCSectionCOFF *getSectionText() {
-    return getContext().getCOFFSection(
-        ".text", COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE |
-                     COFF::IMAGE_SCN_MEM_READ,
-        SectionKind::getText());
+  const MCSection *getSectionText() {
+    return getContext().getObjectFileInfo()->getTextSection();
   }
 
-  const MCSectionCOFF *getSectionData() {
-    return getContext().getCOFFSection(
-        ".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
-                     COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
-        SectionKind::getDataRel());
+  const MCSection *getSectionData() {
+    return getContext().getObjectFileInfo()->getDataSection();
   }
 
-  const MCSectionCOFF *getSectionBSS() {
-    return getContext().getCOFFSection(
-        ".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
-                    COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
-        SectionKind::getBSS());
+  const MCSection *getSectionBSS() {
+    return getContext().getObjectFileInfo()->getBSSSection();
   }
 
   void SetSectionText() {
@@ -141,7 +133,7 @@ void WinCOFFStreamer::AddCommonSymbol(MCSymbol *Symbol, uint64_t Size,
                                       unsigned ByteAlignment, bool External) {
   assert(!Symbol->isInSection() && "Symbol must not already have a section!");
 
-  const MCSectionCOFF *Section = getSectionBSS();
+  const MCSection *Section = getSectionBSS();
   MCSectionData &SectionData = getAssembler().getOrCreateSectionData(*Section);
   if (SectionData.getAlignment() < ByteAlignment)
     SectionData.setAlignment(ByteAlignment);