return TargetObjectWriter->GetRelocType(Target, Fixup, IsPCRel);
}
+ void align(unsigned Alignment);
+
public:
ELFObjectWriter(MCELFObjectTargetWriter *MOTW, raw_pwrite_stream &OS,
bool IsLittleEndian)
};
}
+void ELFObjectWriter::align(unsigned Alignment) {
+ uint64_t Padding = OffsetToAlignment(OS.tell(), Alignment);
+ WriteZeros(Padding);
+}
+
unsigned ELFObjectWriter::addToSectionTable(const MCSectionELF *Sec) {
SectionTable.push_back(Sec);
StrTabBuilder.add(Sec->getSectionName());
SymtabSection->setAlignment(is64Bit() ? 8 : 4);
SymbolTableIndex = addToSectionTable(SymtabSection);
- uint64_t Padding =
- OffsetToAlignment(OS.tell(), SymtabSection->getAlignment());
- WriteZeros(Padding);
-
+ align(SymtabSection->getAlignment());
uint64_t SecStart = OS.tell();
// The first entry is the undefined symbol entry.
for (MCSection &Sec : Asm) {
MCSectionELF &Section = static_cast<MCSectionELF &>(Sec);
- uint64_t Padding = OffsetToAlignment(OS.tell(), Section.getAlignment());
- WriteZeros(Padding);
+ align(Section.getAlignment());
// Remember the offset into the file for this section.
uint64_t SecStart = OS.tell();
}
for (MCSectionELF *Group : Groups) {
- uint64_t Padding = OffsetToAlignment(OS.tell(), Group->getAlignment());
- WriteZeros(Padding);
+ align(Group->getAlignment());
// Remember the offset into the file for this section.
uint64_t SecStart = OS.tell();
computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap, SectionOffsets);
for (MCSectionELF *RelSection : Relocations) {
- uint64_t Padding = OffsetToAlignment(OS.tell(), RelSection->getAlignment());
- WriteZeros(Padding);
+ align(RelSection->getAlignment());
// Remember the offset into the file for this section.
uint64_t SecStart = OS.tell();
}
uint64_t NaturalAlignment = is64Bit() ? 8 : 4;
- uint64_t Padding = OffsetToAlignment(OS.tell(), NaturalAlignment);
- WriteZeros(Padding);
+ align(NaturalAlignment);
const unsigned SectionHeaderOffset = OS.tell();