[llvm-commits] [llvm] r103752 - /llvm/trunk/lib/MC/MCAssembler.cpp

Daniel Dunbar daniel at zuster.org
Thu May 13 17:37:18 PDT 2010


Author: ddunbar
Date: Thu May 13 19:37:17 2010
New Revision: 103752

URL: http://llvm.org/viewvc/llvm-project?rev=103752&view=rev
Log:
MC: Implicitly assign section addresses when the previous fragment is layed out.

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=103752&r1=103751&r2=103752&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Thu May 13 19:37:17 2010
@@ -414,10 +414,13 @@
 }
 
 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 @@
   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) {





More information about the llvm-commits mailing list