MC: Add MCSectionData::AddressSize, which is the size of the address space consumed by the section. This can differ from both the section logical size, and the section size on disk (although the current code handles this without making an explicit distinction).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103689 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 0bab34e..ced395c 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -126,6 +126,14 @@
   SD->FileSize = Value;
 }
 
+uint64_t MCAsmLayout::getSectionAddressSize(const MCSectionData *SD) const {
+  assert(SD->AddressSize != ~UINT64_C(0) && "Address size not set!");
+  return SD->AddressSize;
+}
+void MCAsmLayout::setSectionAddressSize(MCSectionData *SD, uint64_t Value) {
+  SD->AddressSize = Value;
+}
+
 /* *** */
 
 MCFragment::MCFragment() : Kind(FragmentType(~0)) {
@@ -150,6 +158,7 @@
     Alignment(1),
     Address(~UINT64_C(0)),
     Size(~UINT64_C(0)),
+    AddressSize(~UINT64_C(0)),
     FileSize(~UINT64_C(0)),
     HasInstructions(false)
 {
@@ -434,7 +443,8 @@
   uint64_t StartAddress = 0;
   if (SectionOrderIndex) {
     MCSectionData *Prev = Layout.getSectionOrder()[SectionOrderIndex - 1];
-    StartAddress = Layout.getSectionAddress(Prev) + Layout.getSectionSize(Prev);
+    StartAddress = (Layout.getSectionAddress(Prev) +
+                    Layout.getSectionAddressSize(Prev));
   }
 
   // Align this section if necessary by adding padding bytes to the previous
@@ -465,6 +475,7 @@
     Size = Layout.getFragmentOffset(F) + Layout.getFragmentEffectiveSize(F);
   }
   Layout.setSectionSize(&SD, Size);
+  Layout.setSectionAddressSize(&SD, Size);
   Layout.setSectionFileSize(&SD, IsVirtual ? 0 : Size);
 }
 
@@ -837,9 +848,7 @@
   raw_ostream &OS = llvm::errs();
 
   OS << "<MCFragment " << (void*) this << " Offset:" << Offset
-     << " EffectiveSize:" << EffectiveSize;
-
-  OS << ">";
+     << " EffectiveSize:" << EffectiveSize << ">";
 }
 
 void MCAlignFragment::dump() {
@@ -914,8 +923,8 @@
 
   OS << "<MCSectionData";
   OS << " Alignment:" << getAlignment() << " Address:" << Address
-     << " Size:" << Size << " FileSize:" << FileSize
-     << " Fragments:[\n      ";
+     << " Size:" << Size << " AddressSize:" << AddressSize
+     << " FileSize:" << FileSize << " Fragments:[\n      ";
   for (iterator it = begin(), ie = end(); it != ie; ++it) {
     if (it != begin()) OS << ",\n      ";
     it->dump();