/// target dependent.
bool EmitNops : 1;
+ /// OnlyAlignAddress - Flag to indicate that this align is only used to adjust
+ /// the address space size of a section and that it should not be included as
+ /// part of the section size. This flag can only be used on the last fragment
+ /// in a section.
+ bool OnlyAlignAddress : 1;
+
public:
MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize,
unsigned _MaxBytesToEmit, MCSectionData *SD = 0)
: MCFragment(FT_Align, SD), Alignment(_Alignment),
Value(_Value),ValueSize(_ValueSize),
- MaxBytesToEmit(_MaxBytesToEmit), EmitNops(false) {}
+ MaxBytesToEmit(_MaxBytesToEmit), EmitNops(false),
+ OnlyAlignAddress(false) {}
/// @name Accessors
/// @{
bool hasEmitNops() const { return EmitNops; }
void setEmitNops(bool Value) { EmitNops = Value; }
+ bool hasOnlyAlignAddress() const { return OnlyAlignAddress; }
+ void setOnlyAlignAddress(bool Value) { OnlyAlignAddress = Value; }
+
/// @}
static bool classof(const MCFragment *F) {
case MCFragment::FT_Align: {
MCAlignFragment &AF = cast<MCAlignFragment>(F);
+ assert((!AF.hasOnlyAlignAddress() || !AF.getNextNode()) &&
+ "Invalid OnlyAlignAddress bit, not the last fragment!");
+
EffectiveSize = OffsetToAlignment(Address, AF.getAlignment());
if (EffectiveSize > AF.getMaxBytesToEmit())
EffectiveSize = 0;
MCFragment *F = &SD.getFragmentList().back();
Size = Layout.getFragmentOffset(F) + Layout.getFragmentEffectiveSize(F);
}
- Layout.setSectionSize(&SD, Size);
Layout.setSectionAddressSize(&SD, Size);
Layout.setSectionFileSize(&SD, IsVirtual ? 0 : Size);
+
+ // Handle OnlyAlignAddress bit.
+ if (!SD.getFragmentList().empty()) {
+ MCAlignFragment *AF =
+ dyn_cast<MCAlignFragment>(&SD.getFragmentList().back());
+ if (AF && AF->hasOnlyAlignAddress())
+ Size -= Layout.getFragmentEffectiveSize(AF);
+ }
+
+ Layout.setSectionSize(&SD, Size);
}
/// WriteFragmentData - Write the \arg F data to the output file.
OS << "<MCAlignFragment ";
this->MCFragment::dump();
+ if (hasEmitNops())
+ OS << " (emit nops)";
+ if (hasOnlyAlignAddress())
+ OS << " (only align section)";
OS << "\n ";
OS << " Alignment:" << getAlignment()
<< " Value:" << getValue() << " ValueSize:" << getValueSize()