diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-25 02:00:07 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-25 02:00:07 +0000 |
commit | 5d428511ca9607d52a09d3483d0738f483e09934 (patch) | |
tree | 8962b6cf6868e23e127512634022c006ce0cf3ff /lib/MC/MCAssembler.cpp | |
parent | 432cd5fd9b4c97f1e4a53fcf45e16f7dd6bc085e (diff) |
MC: Route access to SectionData offset and file size through MCAsmLayout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99474 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r-- | lib/MC/MCAssembler.cpp | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index c8d3c845f2..8efc78c1f9 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -82,6 +82,24 @@ void MCAsmLayout::setSectionAddress(MCSectionData *SD, uint64_t Value) { SD->Address = Value; } +uint64_t MCAsmLayout::getSectionSize(const MCSectionData *SD) const { + assert(SD->Size != ~UINT64_C(0) && "File size not set!"); + return SD->Size; +} +void MCAsmLayout::setSectionSize(MCSectionData *SD, uint64_t Value) { + SD->Size = Value; +} + +uint64_t MCAsmLayout::getSectionFileSize(const MCSectionData *SD) const { + assert(SD->FileSize != ~UINT64_C(0) && "File size not set!"); + return SD->FileSize; +} +void MCAsmLayout::setSectionFileSize(MCSectionData *SD, uint64_t Value) { + SD->FileSize = Value; +} + + /// @} + /* *** */ MCFragment::MCFragment() : Kind(FragmentType(~0)) { @@ -419,11 +437,11 @@ void MCAssembler::LayoutSection(MCSectionData &SD, } // Set the section sizes. - SD.setSize(Address - StartAddress); + Layout.setSectionSize(&SD, Address - StartAddress); if (getBackend().isVirtualSection(SD.getSection())) - SD.setFileSize(0); + Layout.setSectionFileSize(&SD, 0); else - SD.setFileSize(Address - StartAddress); + Layout.setSectionFileSize(&SD, Address - StartAddress); } /// WriteFragmentData - Write the \arg F data to the output file. @@ -522,9 +540,12 @@ static void WriteFragmentData(const MCAssembler &Asm, const MCAsmLayout &Layout, void MCAssembler::WriteSectionData(const MCSectionData *SD, const MCAsmLayout &Layout, MCObjectWriter *OW) const { + uint64_t SectionSize = Layout.getSectionSize(SD); + uint64_t SectionFileSize = Layout.getSectionFileSize(SD); + // Ignore virtual sections. if (getBackend().isVirtualSection(SD->getSection())) { - assert(SD->getFileSize() == 0); + assert(SectionFileSize == 0 && "Invalid size for section!"); return; } @@ -536,10 +557,10 @@ void MCAssembler::WriteSectionData(const MCSectionData *SD, WriteFragmentData(*this, Layout, *it, OW); // Add section padding. - assert(SD->getFileSize() >= SD->getSize() && "Invalid section sizes!"); - OW->WriteZeros(SD->getFileSize() - SD->getSize()); + assert(SectionFileSize >= SectionSize && "Invalid section sizes!"); + OW->WriteZeros(SectionFileSize - SectionSize); - assert(OW->getStream().tell() - Start == SD->getFileSize()); + assert(OW->getStream().tell() - Start == SectionFileSize); } void MCAssembler::Finish() { @@ -652,14 +673,14 @@ bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) { // section. if (uint64_t Pad = OffsetToAlignment(Address, it->getAlignment())) { assert(Prev && "Missing prev section!"); - Prev->setFileSize(Prev->getFileSize() + Pad); + Layout.setSectionFileSize(Prev, Layout.getSectionFileSize(Prev) + Pad); Address += Pad; } // Layout the section fragments and its size. Layout.setSectionAddress(&SD, Address); LayoutSection(SD, Layout); - Address += SD.getFileSize(); + Address += Layout.getSectionFileSize(&SD); Prev = &SD; } @@ -678,7 +699,7 @@ bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) { Layout.setSectionAddress(&SD, Address); LayoutSection(SD, Layout); - Address += SD.getSize(); + Address += Layout.getSectionSize(&SD); } // Scan for fragments that need relaxation. |