MCSection &getSection() const { return *Section; }
- unsigned getAlignment() const;
- void setAlignment(unsigned Value);
-
bool hasInstructions() const { return HasInstructions; }
void setHasInstructions(bool Value) { HasInstructions = Value; }
for (const MCSectionData &SD : Asm) {
MCSectionELF &Section = static_cast<MCSectionELF &>(SD.getSection());
- uint64_t Padding = OffsetToAlignment(OS.tell(), SD.getAlignment());
+ uint64_t Padding = OffsetToAlignment(OS.tell(), Section.getAlignment());
WriteZeros(Padding);
// Remember the offset into the file for this section.
A->getSectionList().push_back(this);
}
-unsigned MCSectionData::getAlignment() const { return Section->getAlignment(); }
-
-void MCSectionData::setAlignment(unsigned Value) {
- Section->setAlignment(Value);
-}
-
MCSectionData::iterator
MCSectionData::getSubsectionInsertionPoint(unsigned Subsection) {
if (Subsection == 0 && SubsectionFragmentMap.empty())
raw_ostream &OS = llvm::errs();
OS << "<MCSectionData";
- OS << " Alignment:" << getAlignment()
- << " Fragments:[\n ";
+ OS << " Fragments:[\n ";
for (iterator it = begin(), ie = end(); it != ie; ++it) {
if (it != begin()) OS << ",\n ";
it->dump();
// needs to be aligned to at least the bundle size.
static void setSectionAlignmentForBundling(
const MCAssembler &Assembler, MCSectionData *Section) {
- if (Assembler.isBundlingEnabled() && Section &&
- Section->hasInstructions() &&
- Section->getAlignment() < Assembler.getBundleAlignSize())
- Section->setAlignment(Assembler.getBundleAlignSize());
+ if (Assembler.isBundlingEnabled() && Section && Section->hasInstructions() &&
+ Section->getSection().getAlignment() < Assembler.getBundleAlignSize())
+ Section->getSection().setAlignment(Assembler.getBundleAlignSize());
}
void MCELFStreamer::ChangeSection(MCSection *Section,
Symbol.getData().setFragment(F);
// Update the maximum alignment of the section if necessary.
- if (ByteAlignment > SectData.getAlignment())
- SectData.setAlignment(ByteAlignment);
+ if (ByteAlignment > Section.getAlignment())
+ Section.setAlignment(ByteAlignment);
}
LocalCommons.clear();
AssignSection(Symbol, Section);
// Update the maximum alignment on the zero fill section if necessary.
- if (ByteAlignment > SectData.getAlignment())
- SectData.setAlignment(ByteAlignment);
+ if (ByteAlignment > Section->getAlignment())
+ Section->setAlignment(ByteAlignment);
}
// This should always be called with the thread local bss section. Like the
insert(new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit));
// Update the maximum alignment on the current section if necessary.
- if (ByteAlignment > getCurrentSectionData()->getAlignment())
- getCurrentSectionData()->setAlignment(ByteAlignment);
+ MCSection *CurSec = getCurrentSection().first;
+ if (ByteAlignment > CurSec->getAlignment())
+ CurSec->setAlignment(ByteAlignment);
}
void MCObjectStreamer::EmitCodeAlignment(unsigned ByteAlignment,
const MCSectionData &NextSD = *Layout.getSectionOrder()[Next];
if (NextSD.getSection().isVirtualSection())
return 0;
- return OffsetToAlignment(EndAddr, NextSD.getAlignment());
+ return OffsetToAlignment(EndAddr, NextSD.getSection().getAlignment());
}
void MachObjectWriter::WriteHeader(unsigned NumLoadCommands,
uint64_t RelocationsStart,
unsigned NumRelocations) {
uint64_t SectionSize = Layout.getSectionAddressSize(&SD);
+ const MCSectionMachO &Section = cast<MCSectionMachO>(SD.getSection());
// The offset is unused for virtual sections.
- if (SD.getSection().isVirtualSection()) {
+ if (Section.isVirtualSection()) {
assert(Layout.getSectionFileSize(&SD) == 0 && "Invalid file size!");
FileOffset = 0;
}
uint64_t Start = OS.tell();
(void) Start;
- const MCSectionMachO &Section = cast<MCSectionMachO>(SD.getSection());
WriteBytes(Section.getSectionName(), 16);
WriteBytes(Section.getSegmentName(), 16);
if (is64Bit()) {
if (SD.hasInstructions())
Flags |= MachO::S_ATTR_SOME_INSTRUCTIONS;
- assert(isPowerOf2_32(SD.getAlignment()) && "Invalid alignment!");
- Write32(Log2_32(SD.getAlignment()));
+ assert(isPowerOf2_32(Section.getAlignment()) && "Invalid alignment!");
+ Write32(Log2_32(Section.getAlignment()));
Write32(NumRelocations ? RelocationsStart : 0);
Write32(NumRelocations);
Write32(Flags);
const SmallVectorImpl<MCSectionData*> &Order = Layout.getSectionOrder();
for (int i = 0, n = Order.size(); i != n ; ++i) {
const MCSectionData *SD = Order[i];
- StartAddress = RoundUpToAlignment(StartAddress, SD->getAlignment());
+ StartAddress =
+ RoundUpToAlignment(StartAddress, SD->getSection().getAlignment());
SectionAddress[SD] = StartAddress;
StartAddress += Layout.getSectionAddressSize(SD);
coff_section->Header.Characteristics = Sec.getCharacteristics();
uint32_t &Characteristics = coff_section->Header.Characteristics;
- switch (SectionData.getAlignment()) {
+ switch (Sec.getAlignment()) {
case 1: Characteristics |= COFF::IMAGE_SCN_ALIGN_1BYTES; break;
case 2: Characteristics |= COFF::IMAGE_SCN_ALIGN_2BYTES; break;
case 4: Characteristics |= COFF::IMAGE_SCN_ALIGN_4BYTES; break;
MCSection *Section = getContext().getObjectFileInfo()->getBSSSection();
MCSectionData &SectionData = getAssembler().getOrCreateSectionData(*Section);
- if (SectionData.getAlignment() < ByteAlignment)
- SectionData.setAlignment(ByteAlignment);
+ if (Section->getAlignment() < ByteAlignment)
+ Section->setAlignment(ByteAlignment);
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
SD.setExternal(false);
MCSectionELF *Sec =
Context.getELFSection(".MIPS.options", ELF::SHT_MIPS_OPTIONS,
ELF::SHF_ALLOC | ELF::SHF_MIPS_NOSTRIP, 1, "");
- MCA.getOrCreateSectionData(*Sec).setAlignment(8);
+ MCA.getOrCreateSectionData(*Sec);
+ Sec->setAlignment(8);
Streamer->SwitchSection(Sec);
Streamer->EmitIntValue(ELF::ODK_REGINFO, 1); // kind
} else {
MCSectionELF *Sec = Context.getELFSection(".reginfo", ELF::SHT_MIPS_REGINFO,
ELF::SHF_ALLOC, 24, "");
- MCA.getOrCreateSectionData(*Sec)
- .setAlignment(MTS->getABI().IsN32() ? 8 : 4);
+ MCA.getOrCreateSectionData(*Sec);
+ Sec->setAlignment(MTS->getABI().IsN32() ? 8 : 4);
Streamer->SwitchSection(Sec);
Streamer->EmitIntValue(ri_gprmask, 4);
const MCObjectFileInfo &OFI = *MCA.getContext().getObjectFileInfo();
// .bss, .text and .data are always at least 16-byte aligned.
- MCSectionData &TextSectionData =
- MCA.getOrCreateSectionData(*OFI.getTextSection());
- MCSectionData &DataSectionData =
- MCA.getOrCreateSectionData(*OFI.getDataSection());
- MCSectionData &BSSSectionData =
- MCA.getOrCreateSectionData(*OFI.getBSSSection());
+ MCSection &TextSection = *OFI.getTextSection();
+ MCA.getOrCreateSectionData(TextSection);
+ MCSection &DataSection = *OFI.getDataSection();
+ MCA.getOrCreateSectionData(DataSection);
+ MCSection &BSSSection = *OFI.getBSSSection();
+ MCA.getOrCreateSectionData(BSSSection);
- TextSectionData.setAlignment(std::max(16u, TextSectionData.getAlignment()));
- DataSectionData.setAlignment(std::max(16u, DataSectionData.getAlignment()));
- BSSSectionData.setAlignment(std::max(16u, BSSSectionData.getAlignment()));
+ TextSection.setAlignment(std::max(16u, TextSection.getAlignment()));
+ DataSection.setAlignment(std::max(16u, DataSection.getAlignment()));
+ BSSSection.setAlignment(std::max(16u, BSSSection.getAlignment()));
uint64_t Features = STI.getFeatureBits();
const MCSymbolRefExpr *ExprRef =
MCSymbolRefExpr::Create(Name, MCSymbolRefExpr::VK_None, Context);
- MCSectionData &SecData = MCA.getOrCreateSectionData(*Sec);
- SecData.setAlignment(4);
+ MCA.getOrCreateSectionData(*Sec);
+ Sec->setAlignment(4);
OS.PushSection();
MCStreamer &OS = getStreamer();
MCSectionELF *Sec = Context.getELFSection(
".MIPS.abiflags", ELF::SHT_MIPS_ABIFLAGS, ELF::SHF_ALLOC, 24, "");
- MCSectionData &ABIShndxSD = MCA.getOrCreateSectionData(*Sec);
- ABIShndxSD.setAlignment(8);
+ MCA.getOrCreateSectionData(*Sec);
+ Sec->setAlignment(8);
OS.SwitchSection(Sec);
OS << ABIFlagsSection;