llvm-mc/Mach-O: Add section padding where needed (to align the next section).

Also, simplify some of Mach-O writer code which can now use section addresses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80067 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h
index ce9dca1..0da729b 100644
--- a/include/llvm/MC/MCAssembler.h
+++ b/include/llvm/MC/MCAssembler.h
@@ -82,7 +82,7 @@
 
   uint64_t getAddress() const;
 
-  unsigned getFileSize() const { 
+  uint64_t getFileSize() const { 
     assert(FileSize != ~UINT64_C(0) && "File size not set!");
     return FileSize;
   }
@@ -267,6 +267,9 @@
   /// initialized.
   uint64_t Address;
 
+  /// Size - The content size of this section. This is ~0 until initialized.
+  uint64_t Size;
+
   /// FileSize - The size of this section in the object file. This is ~0 until
   /// initialized.
   uint64_t FileSize;
@@ -305,13 +308,19 @@
   //
   // FIXME: This could all be kept private to the assembler implementation.
 
-  unsigned getAddress() const { 
+  uint64_t getAddress() const { 
     assert(Address != ~UINT64_C(0) && "Address not set!");
     return Address;
   }
   void setAddress(uint64_t Value) { Address = Value; }
 
-  unsigned getFileSize() const { 
+  uint64_t getSize() const { 
+    assert(Size != ~UINT64_C(0) && "File size not set!");
+    return Size;
+  }
+  void setSize(uint64_t Value) { Size = Value; }
+
+  uint64_t getFileSize() const { 
     assert(FileSize != ~UINT64_C(0) && "File size not set!");
     return FileSize;
   }
@@ -414,7 +423,11 @@
   /// LayoutSection - Assign offsets and sizes to the fragments in the section
   /// \arg SD, and update the section size. The section file offset should
   /// already have been computed.
-  void LayoutSection(MCSectionData &SD);
+  ///
+  /// \param NextAlign - The alignment for the section end address, which may
+  /// add padding bytes to the section (these are included in the section "file"
+  /// size, but not its regular size).
+  void LayoutSection(MCSectionData &SD, unsigned NextAlign);
 
 public:
   /// Construct a new assembler instance.