[llvm-commits] [llvm] r103648 - /llvm/trunk/lib/MC/MCAssembler.cpp
Daniel Dunbar
daniel at zuster.org
Wed May 12 14:35:22 PDT 2010
Author: ddunbar
Date: Wed May 12 16:35:22 2010
New Revision: 103648
URL: http://llvm.org/viewvc/llvm-project?rev=103648&view=rev
Log:
MC: Tweak section layout to not relying on accumulating address value.
Modified:
llvm/trunk/lib/MC/MCAssembler.cpp
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=103648&r1=103647&r2=103648&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Wed May 12 16:35:22 2010
@@ -396,10 +396,15 @@
// 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 @@
}
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.
More information about the llvm-commits
mailing list