diff --git a/include/llvm/MC/MCAsmLayout.h b/include/llvm/MC/MCAsmLayout.h index 8a382470025..f866aab95b5 100644 --- a/include/llvm/MC/MCAsmLayout.h +++ b/include/llvm/MC/MCAsmLayout.h @@ -47,6 +47,9 @@ public: /// the delta from the old size. void UpdateForSlide(MCFragment *F, int SlideAmount); + /// \brief Update the layout because a fragment has been replaced. + void FragmentReplaced(MCFragment *Src, MCFragment *Dst); + /// @name Section Access (in layout order) /// @{ diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index e62296f35d1..de36c52c680 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -73,6 +73,11 @@ void MCAsmLayout::UpdateForSlide(MCFragment *F, int SlideAmount) { getAssembler().LayoutSection(*this, i); } +void MCAsmLayout::FragmentReplaced(MCFragment *Src, MCFragment *Dst) { + Dst->Offset = Src->Offset; + Dst->EffectiveSize = Src->EffectiveSize; +} + uint64_t MCAsmLayout::getFragmentAddress(const MCFragment *F) const { assert(F->getParent() && "Missing section()!"); return getSectionAddress(F->getParent()) + getFragmentOffset(F); @@ -818,13 +823,10 @@ void MCAssembler::FinishLayout(MCAsmLayout &Layout) { SD.getFragmentList().insert(it2, DF); // Update the data fragments layout data. - // - // FIXME: Add MCAsmLayout utility for this. DF->setParent(IF->getParent()); DF->setAtom(IF->getAtom()); DF->setOrdinal(IF->getOrdinal()); - Layout.setFragmentOffset(DF, Layout.getFragmentOffset(IF)); - Layout.setFragmentEffectiveSize(DF, Layout.getFragmentEffectiveSize(IF)); + Layout.FragmentReplaced(IF, DF); // Copy in the data and the fixups. DF->getContents().append(IF->getCode().begin(), IF->getCode().end());