MC: Add MCSectionData::AddressSize, which is the size of the address space consumed...
authorDaniel Dunbar <daniel@zuster.org>
Thu, 13 May 2010 01:10:22 +0000 (01:10 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 13 May 2010 01:10:22 +0000 (01:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103689 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCAsmLayout.h
include/llvm/MC/MCAssembler.h
lib/MC/MCAssembler.cpp

index c4492a6299378f96a4b9fb7d6eb54742989d74b4..986610018dcb8152b88f09be81a2882c2349fd85 100644 (file)
@@ -91,10 +91,18 @@ public:
   /// \brief Set the data size of the given section.
   void setSectionFileSize(MCSectionData *SD, uint64_t Value);
 
-  /// \brief Get the actual data size of the given section.
+  /// \brief Get the address space size of the given section, as it effects
+  /// layout. This may differ from the size reported by \see getSectionSize() by
+  /// not including section tail padding.
+  uint64_t getSectionAddressSize(const MCSectionData *SD) const;
+
+  /// \brief Set the address space size of the given section.
+  void setSectionAddressSize(MCSectionData *SD, uint64_t Value);
+
+  /// \brief Get the logical data size of the given section.
   uint64_t getSectionSize(const MCSectionData *SD) const;
 
-  /// \brief Set the actual data size of the given section.
+  /// \brief Set the logical data size of the given section.
   void setSectionSize(MCSectionData *SD, uint64_t Value);
 
   /// @}
index e0e009526dd0700b88eba7a736e972460411a92e..b641b0241d80806d80feba5702dcb6498748b523 100644 (file)
@@ -394,9 +394,13 @@ private:
   /// initialized.
   uint64_t Address;
 
-  /// Size - The content size of this section. This is ~0 until initialized.
+  /// Size - The logical size of this section. This is ~0 until initialized.
   uint64_t Size;
 
+  /// AddressSize - The address space size used by this section. This is ~0
+  /// until initialized.
+  uint64_t AddressSize;
+
   /// FileSize - The size of this section in the object file. This is ~0 until
   /// initialized.
   uint64_t FileSize;
index 0bab34e4b21f4f1585f676c6c872474fb4991c8e..ced395c517094761b849dc37c9018319f1ea760d 100644 (file)
@@ -126,6 +126,14 @@ void MCAsmLayout::setSectionFileSize(MCSectionData *SD, uint64_t Value) {
   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 @@ MCSectionData::MCSectionData(const MCSection &_Section, MCAssembler *A)
     Alignment(1),
     Address(~UINT64_C(0)),
     Size(~UINT64_C(0)),
+    AddressSize(~UINT64_C(0)),
     FileSize(~UINT64_C(0)),
     HasInstructions(false)
 {
@@ -434,7 +443,8 @@ void MCAssembler::LayoutSection(MCAsmLayout &Layout,
   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 @@ void MCAssembler::LayoutSection(MCAsmLayout &Layout,
     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 @@ void MCFragment::dump() {
   raw_ostream &OS = llvm::errs();
 
   OS << "<MCFragment " << (void*) this << " Offset:" << Offset
-     << " EffectiveSize:" << EffectiveSize;
-
-  OS << ">";
+     << " EffectiveSize:" << EffectiveSize << ">";
 }
 
 void MCAlignFragment::dump() {
@@ -914,8 +923,8 @@ void MCSectionData::dump() {
 
   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();