summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-05-14 00:37:17 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-05-14 00:37:17 +0000
commit3eedc26e18263a27c21b5c0791d6dc264a965ec1 (patch)
treedc6f9550829e8a7df14eabadaff1f5eeb5729be3 /llvm/lib/MC/MCAssembler.cpp
parent8f9d2266e66ab9464a63a0d239135d139cd705a3 (diff)
downloadbcm5719-llvm-3eedc26e18263a27c21b5c0791d6dc264a965ec1.tar.gz
bcm5719-llvm-3eedc26e18263a27c21b5c0791d6dc264a965ec1.zip
MC: Implicitly assign section addresses when the previous fragment is layed out.
llvm-svn: 103752
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 47c891534f5..92bdc0c5eb2 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/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) {
OpenPOWER on IntegriCloud