MC: Add TargetAsmBackend::isVirtualSection hook.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98950 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index ae8ca4b..f1847df 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -43,14 +43,6 @@
 // object file, which may truncate it. We should detect that truncation where
 // invalid and report errors back.
 
-/// isVirtualSection - Check if this is a section which does not actually exist
-/// in the object file.
-static bool isVirtualSection(const MCSection &Section) {
-  // FIXME: Lame.
-  const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section);
-  return (SMO.getType() == MCSectionMachO::S_ZEROFILL);
-}
-
 static unsigned getFixupKindLog2Size(unsigned Kind) {
   switch (Kind) {
   default: llvm_unreachable("invalid fixup kind!");
@@ -264,7 +256,7 @@
                     uint64_t FileOffset, uint64_t RelocationsStart,
                     unsigned NumRelocations) {
     // The offset is unused for virtual sections.
-    if (isVirtualSection(SD.getSection())) {
+    if (Asm.getBackend().isVirtualSection(SD.getSection())) {
       assert(SD.getFileSize() == 0 && "Invalid file size!");
       FileOffset = 0;
     }
@@ -748,7 +740,7 @@
 
       VMSize = std::max(VMSize, SD.getAddress() + SD.getSize());
 
-      if (isVirtualSection(SD.getSection()))
+      if (Asm.getBackend().isVirtualSection(SD.getSection()))
         continue;
 
       SectionDataSize = std::max(SectionDataSize,
@@ -776,7 +768,7 @@
       std::vector<MachRelocationEntry> &Relocs = Relocations[it];
       unsigned NumRelocs = Relocs.size();
       uint64_t SectionStart = SectionDataStart + it->getAddress();
-      WriteSection(*it, SectionStart, RelocTableEnd, NumRelocs);
+      WriteSection(Asm, *it, SectionStart, RelocTableEnd, NumRelocs);
       RelocTableEnd += NumRelocs * RelocationInfoSize;
     }
 
@@ -1194,7 +1186,7 @@
 
   // Set the section sizes.
   SD.setSize(Address - SD.getAddress());
-  if (isVirtualSection(SD.getSection()))
+  if (getBackend().isVirtualSection(SD.getSection()))
     SD.setFileSize(0);
   else
     SD.setFileSize(Address - SD.getAddress());
@@ -1342,7 +1334,7 @@
 void MCAssembler::WriteSectionData(const MCSectionData *SD,
                                    MCObjectWriter *OW) const {
   // Ignore virtual sections.
-  if (isVirtualSection(SD->getSection())) {
+  if (getBackend().isVirtualSection(SD->getSection())) {
     assert(SD->getFileSize() == 0);
     return;
   }
@@ -1444,7 +1436,7 @@
     MCSectionData &SD = *it;
 
     // Skip virtual sections.
-    if (isVirtualSection(SD.getSection()))
+    if (getBackend().isVirtualSection(SD.getSection()))
       continue;
 
     // Align this section if necessary by adding padding bytes to the previous
@@ -1467,7 +1459,7 @@
   for (iterator it = begin(), ie = end(); it != ie; ++it) {
     MCSectionData &SD = *it;
 
-    if (!isVirtualSection(SD.getSection()))
+    if (!getBackend().isVirtualSection(SD.getSection()))
       continue;
 
     // Align this section if necessary by adding padding bytes to the previous