//
// FIXME: This should probably just be merged with MCFixup.
class MCAsmFixup {
-public:
/// Offset - The offset inside the fragment which needs to be rewritten.
uint64_t Offset;
public:
MCAsmFixup(uint64_t _Offset, const MCExpr &_Value, MCFixupKind _Kind)
: Offset(_Offset), Value(&_Value), Kind(_Kind) {}
+
+ MCFixupKind getKind() const { return MCFixupKind(Kind); }
+
+ uint64_t getOffset() const { return Offset; }
+ void setOffset(uint64_t Value) { Offset = Value; }
+
+ const MCExpr *getValue() const { return Value; }
};
class MCFragment : public ilist_node<MCFragment> {
/// initialized.
uint64_t EffectiveSize;
- /// Ordinal - The global index of this fragment. This is the index across all
- /// sections, not just the parent section.
- unsigned Ordinal;
+ /// LayoutOrder - The global layout order of this fragment. This is the index
+ /// across all fragments in the file, not just within the section.
+ unsigned LayoutOrder;
/// @}
public:
// Only for sentinel.
MCFragment();
- virtual ~MCFragment();
FragmentType getKind() const { return Kind; }
MCSymbolData *getAtom() const { return Atom; }
void setAtom(MCSymbolData *Value) { Atom = Value; }
- unsigned getOrdinal() const { return Ordinal; }
- void setOrdinal(unsigned Value) { Ordinal = Value; }
+ unsigned getLayoutOrder() const { return LayoutOrder; }
+ void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
static bool classof(const MCFragment *O) { return true; }
- virtual void dump();
+ void dump();
};
class MCDataFragment : public MCFragment {
void addFixup(MCAsmFixup Fixup) {
// Enforce invariant that fixups are in offset order.
- assert((Fixups.empty() || Fixup.Offset > Fixups.back().Offset) &&
+ assert((Fixups.empty() || Fixup.getOffset() > Fixups.back().getOffset()) &&
"Fixups must be added in order!");
Fixups.push_back(Fixup);
}
return F->getKind() == MCFragment::FT_Data;
}
static bool classof(const MCDataFragment *) { return true; }
-
- virtual void dump();
};
// FIXME: This current incarnation of MCInstFragment doesn't make much sense, as
return F->getKind() == MCFragment::FT_Inst;
}
static bool classof(const MCInstFragment *) { return true; }
-
- virtual void dump();
};
class MCAlignFragment : public MCFragment {
return F->getKind() == MCFragment::FT_Align;
}
static bool classof(const MCAlignFragment *) { return true; }
-
- virtual void dump();
};
class MCFillFragment : public MCFragment {
return F->getKind() == MCFragment::FT_Fill;
}
static bool classof(const MCFillFragment *) { return true; }
-
- virtual void dump();
};
class MCOrgFragment : public MCFragment {
return F->getKind() == MCFragment::FT_Org;
}
static bool classof(const MCOrgFragment *) { return true; }
-
- virtual void dump();
};
// FIXME: Should this be a separate class, or just merged into MCSection? Since
/// Ordinal - The section index in the assemblers section list.
unsigned Ordinal;
+ /// LayoutOrder - The index of this section in the layout order.
+ unsigned LayoutOrder;
+
/// Alignment - The maximum alignment seen in this section.
unsigned Alignment;
/// initialized.
uint64_t Address;
- /// Size - The logical size of this section. This is ~0 until initialized.
- uint64_t Size;
-
- /// AddressSize - The address space size used by this section. This is ~0
- /// until initialized.
- uint64_t AddressSize;
-
- /// FileSize - The size of this section in the object file. This is ~0 until
- /// initialized.
- uint64_t FileSize;
-
/// HasInstructions - Whether this section has had instructions emitted into
/// it.
unsigned HasInstructions : 1;
unsigned getOrdinal() const { return Ordinal; }
void setOrdinal(unsigned Value) { Ordinal = Value; }
+ unsigned getLayoutOrder() const { return LayoutOrder; }
+ void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
+
/// @name Fragment Access
/// @{
bool FragmentNeedsRelaxation(const MCInstFragment *IF,
const MCAsmLayout &Layout) const;
- /// LayoutFragment - Performs layout of the given \arg Fragment; assuming that
- /// the previous fragment has already been layed out correctly, and the parent
- /// section has been initialized.
- void LayoutFragment(MCAsmLayout &Layout, MCFragment &Fragment);
-
- /// LayoutSection - Performs layout of the section referenced by the given
- /// \arg SectionOrderIndex. The layout assumes that the previous section has
- /// already been layed out correctly.
- void LayoutSection(MCAsmLayout &Layout, unsigned SectionOrderIndex);
+ /// Compute the effective fragment size assuming it is layed out at the given
+ /// \arg SectionAddress and \arg FragmentOffset.
+ uint64_t ComputeFragmentSize(MCAsmLayout &Layout, const MCFragment &F,
+ uint64_t SectionAddress,
+ uint64_t FragmentOffset) const;
/// LayoutOnce - Perform one layout iteration and return true if any offsets
/// were adjusted.