diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-05-12 21:35:22 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-05-12 21:35:22 +0000 |
commit | 2d891a20e665136a603cc0a076ed1ebbd4703f47 (patch) | |
tree | d8e09db370e67c9b4be060323e363c05593bb568 /lib/MC/MCAssembler.cpp | |
parent | aa81380353a27d9d216cafdd88df08a5eef43b74 (diff) |
MC: Tweak section layout to not relying on accumulating address value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103648 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r-- | lib/MC/MCAssembler.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index aefe2c4294..44e4cc9ea5 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -396,10 +396,15 @@ void MCAssembler::LayoutSection(MCAsmLayout &Layout, // Set the aligned section address. Layout.setSectionAddress(&SD, StartAddress); - uint64_t Address = StartAddress; for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) { MCFragment &F = *it; + // Compute the fragment start address. + uint64_t Address = StartAddress; + if (MCFragment *Prev = F.getPrevNode()) + Address = (Layout.getFragmentAddress(Prev) + + Layout.getFragmentEffectiveSize(Prev)); + ++stats::FragmentLayouts; uint64_t FragmentOffset = Address - StartAddress; @@ -464,15 +469,16 @@ void MCAssembler::LayoutSection(MCAsmLayout &Layout, } Layout.setFragmentEffectiveSize(&F, EffectiveSize); - Address += EffectiveSize; } // Set the section sizes. - Layout.setSectionSize(&SD, Address - StartAddress); - if (IsVirtual) - Layout.setSectionFileSize(&SD, 0); - else - Layout.setSectionFileSize(&SD, Address - StartAddress); + uint64_t Size = 0; + if (!SD.getFragmentList().empty()) { + MCFragment *F = &SD.getFragmentList().back(); + Size = Layout.getFragmentOffset(F) + Layout.getFragmentEffectiveSize(F); + } + Layout.setSectionSize(&SD, Size); + Layout.setSectionFileSize(&SD, IsVirtual ? 0 : Size); } /// WriteFragmentData - Write the \arg F data to the output file. |