MC/Macho-O: Align the zerofill section itself to the maximum alignment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97991 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 1ec1d81..4b78dc0 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -1279,9 +1279,19 @@
     if (!isVirtualSection(SD.getSection()))
       continue;
 
+    // Align this section if necessary by adding padding bytes to the previous
+    // section.
+    if (uint64_t Pad = OffsetToAlignment(Address, it->getAlignment())) {
+      assert(Prev && "Missing prev section!");
+      Prev->setFileSize(Prev->getFileSize() + Pad);
+      Address += Pad;
+    }
+
     SD.setAddress(Address);
     LayoutSection(SD);
     Address += SD.getSize();
+
+    Prev = &SD;
   }
 
   DEBUG_WITH_TYPE("mc-dump", {