summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-05-12 21:35:22 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-05-12 21:35:22 +0000
commit2abec791f19497cd1cc1cb3e3f8c42726ab6f36a (patch)
tree4f3ceb4a0444a77b49a8e6def83e1a0b620efded /llvm/lib/MC/MCAssembler.cpp
parent959ae59997ac1ec65819671f974e0ee6730323cf (diff)
downloadbcm5719-llvm-2abec791f19497cd1cc1cb3e3f8c42726ab6f36a.tar.gz
bcm5719-llvm-2abec791f19497cd1cc1cb3e3f8c42726ab6f36a.zip
MC: Tweak section layout to not relying on accumulating address value.
llvm-svn: 103648
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index aefe2c42946..44e4cc9ea5f 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/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.
OpenPOWER on IntegriCloud