diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-05-14 00:37:17 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-05-14 00:37:17 +0000 |
commit | 11c411151643e80b9da0acf16f8bb3ec9c6d2754 (patch) | |
tree | 913fe575cce85abe4a384f3fb0f3dcdc3346984e /lib/MC/MCAssembler.cpp | |
parent | 337718e09c99349939a53643984c04f5dc118bb7 (diff) |
MC: Implicitly assign section addresses when the previous fragment is layed out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103752 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r-- | lib/MC/MCAssembler.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 47c891534f..92bdc0c5eb 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -414,10 +414,13 @@ uint64_t MCAssembler::ComputeFragmentSize(MCAsmLayout &Layout, } void MCAsmLayout::LayoutFile() { + // Initialize the first section. + if (!getSectionOrder().empty()) + getSectionOrder().front()->Address = 0; + for (unsigned i = 0, e = getSectionOrder().size(); i != e; ++i) { MCSectionData *SD = getSectionOrder()[i]; - LayoutSection(SD); for (MCSectionData::iterator it = SD->begin(), ie = SD->end(); it != ie; ++it) LayoutFragment(it); @@ -440,6 +443,13 @@ void MCAsmLayout::LayoutFragment(MCFragment *F) { F->Offset = Address - StartAddress; F->EffectiveSize = getAssembler().ComputeFragmentSize(*this, *F, StartAddress, F->Offset); + + // If this is the last fragment in a section, update the next section address. + if (!F->getNextNode()) { + unsigned NextIndex = F->getParent()->getLayoutOrder() + 1; + if (NextIndex != getSectionOrder().size()) + LayoutSection(getSectionOrder()[NextIndex]); + } } void MCAsmLayout::LayoutSection(MCSectionData *SD) { |