MC: Add MCAsmLayout::FragmentReplaced() helper function.

llvm-svn: 103709
This commit is contained in:
Daniel Dunbar 2010-05-13 08:43:31 +00:00
parent d37bcf5e2c
commit 5ef1bcbb97
2 changed files with 9 additions and 4 deletions

View File

@ -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)
/// @{

View File

@ -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());