unsigned ShstrtabIndex;
// Sections in the order they are to be output in the section table.
- std::vector<const MCSectionELF *> SectionTable;
- unsigned addToSectionTable(const MCSectionELF *Sec);
+ std::vector<MCSectionELF *> SectionTable;
+ unsigned addToSectionTable(MCSectionELF *Sec);
// TargetObjectWriter wrappers.
bool is64Bit() const { return TargetObjectWriter->is64Bit(); }
const SectionIndexMapTy &SectionIndexMap,
const RevGroupMapTy &RevGroupMap);
- const MCSectionELF *createRelocationSection(MCAssembler &Asm,
- const MCSectionELF &Sec);
+ MCSectionELF *createRelocationSection(MCAssembler &Asm,
+ const MCSectionELF &Sec);
const MCSectionELF *createSectionHeaderStringTable();
const MCSectionELF *createStringTable(MCContext &Ctx);
void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
void writeSection(MCAssembler &Asm,
const SectionIndexMapTy &SectionIndexMap,
- uint32_t GroupSymbolIndex,
- uint64_t Offset, uint64_t Size, uint64_t Alignment,
+ uint32_t GroupSymbolIndex, uint64_t Offset, uint64_t Size,
const MCSectionELF &Section);
};
}
-unsigned ELFObjectWriter::addToSectionTable(const MCSectionELF *Sec) {
+unsigned ELFObjectWriter::addToSectionTable(MCSectionELF *Sec) {
SectionTable.push_back(Sec);
ShStrTabBuilder.add(Sec->getSectionName());
return SectionTable.size();
unsigned EntrySize = is64Bit() ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32;
// Symbol table
- const MCSectionELF *SymtabSection =
+ MCSectionELF *SymtabSection =
Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0, EntrySize, "");
MCSectionData &SymtabSD = Asm.getOrCreateSectionData(*SymtabSection);
SymtabSD.setAlignment(is64Bit() ? 8 : 4);
return;
SecStart = OS.tell();
- const MCSectionELF *SymtabShndxSection =
+ MCSectionELF *SymtabShndxSection =
Ctx.getELFSection(".symtab_shndxr", ELF::SHT_SYMTAB_SHNDX, 0, 4, "");
addToSectionTable(SymtabShndxSection);
MCSectionData *SymtabShndxSD =
UndefinedSymbolData[i].Symbol->getData().setIndex(Index++);
}
-const MCSectionELF *
+MCSectionELF *
ELFObjectWriter::createRelocationSection(MCAssembler &Asm,
const MCSectionELF &Sec) {
if (Relocations[&Sec].empty())
if (Sec.getFlags() & ELF::SHF_GROUP)
Flags = ELF::SHF_GROUP;
- const MCSectionELF *RelaSection = Ctx.createELFRelSection(
+ MCSectionELF *RelaSection = Ctx.createELFRelSection(
RelaSectionName, hasRelocationAddend() ? ELF::SHT_RELA : ELF::SHT_REL,
Flags, EntrySize, Sec.getGroup(), &Sec);
MCSectionData &RelSD = Asm.getOrCreateSectionData(*RelaSection);
void ELFObjectWriter::writeSectionData(const MCAssembler &Asm,
const MCSectionData &SD,
const MCAsmLayout &Layout) {
- const MCSectionELF &Section =
- static_cast<const MCSectionELF &>(SD.getSection());
+ MCSectionELF &Section = static_cast<MCSectionELF &>(SD.getSection());
StringRef SectionName = Section.getSectionName();
// Compressing debug_frame requires handling alignment fragments which is
}
const MCSectionELF *ELFObjectWriter::createStringTable(MCContext &Ctx) {
- const MCSectionELF *StrtabSection =
+ MCSectionELF *StrtabSection =
Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0);
StringTableIndex = addToSectionTable(StrtabSection);
OS << StrTabBuilder.data();
const SectionIndexMapTy &SectionIndexMap,
uint32_t GroupSymbolIndex,
uint64_t Offset, uint64_t Size,
- uint64_t Alignment,
const MCSectionELF &Section) {
uint64_t sh_link = 0;
uint64_t sh_info = 0;
sh_link = SectionIndexMap.lookup(Section.getAssociatedSection());
WriteSecHdrEntry(ShStrTabBuilder.getOffset(Section.getSectionName()),
- Section.getType(),
- Section.getFlags(), 0, Offset, Size, sh_link, sh_info,
- Alignment, Section.getEntrySize());
+ Section.getType(), Section.getFlags(), 0, Offset, Size,
+ sh_link, sh_info, Section.getAlignment(),
+ Section.getEntrySize());
}
void ELFObjectWriter::writeSectionHeader(
(NumSections + 1) >= ELF::SHN_LORESERVE ? NumSections + 1 : 0;
WriteSecHdrEntry(0, 0, 0, 0, 0, FirstSectionSize, 0, 0, 0, 0);
- for (const MCSectionELF *Section : SectionTable) {
+ for (MCSectionELF *Section : SectionTable) {
const MCSectionData &SD = Asm.getOrCreateSectionData(*Section);
uint32_t GroupSymbolIndex;
unsigned Type = Section->getType();
: Offsets.second - Offsets.first;
writeSection(Asm, SectionIndexMap, GroupSymbolIndex, Offsets.first, Size,
- SD.getAlignment(), *Section);
+ *Section);
}
}
void ELFObjectWriter::WriteObject(MCAssembler &Asm,
const MCAsmLayout &Layout) {
MCContext &Ctx = Asm.getContext();
- const MCSectionELF *ShstrtabSection =
+ MCSectionELF *ShstrtabSection =
Ctx.getELFSection(".shstrtab", ELF::SHT_STRTAB, 0);
ShstrtabIndex = addToSectionTable(ShstrtabSection);
SectionOffsetsTy SectionOffsets;
bool ComputedSymtab = false;
for (const MCSectionData &SD : Asm) {
- const MCSectionELF &Section =
- static_cast<const MCSectionELF &>(SD.getSection());
+ MCSectionELF &Section = static_cast<MCSectionELF &>(SD.getSection());
uint64_t Padding = OffsetToAlignment(OS.tell(), SD.getAlignment());
WriteZeros(Padding);
if (Type == ELF::SHT_GROUP || Type == ELF::SHT_REL || Type == ELF::SHT_RELA)
continue;
- const MCSectionELF *RelSection = createRelocationSection(Asm, Section);
+ MCSectionELF *RelSection = createRelocationSection(Asm, Section);
if (SignatureSymbol) {
Asm.getOrCreateSymbolData(*SignatureSymbol);
unsigned &GroupIdx = RevGroupMap[SignatureSymbol];
if (!GroupIdx) {
- const MCSectionELF *Group = Ctx.createELFGroupSection(SignatureSymbol);
+ MCSectionELF *Group = Ctx.createELFGroupSection(SignatureSymbol);
GroupIdx = addToSectionTable(Group);
MCSectionData *GroupD = &Asm.getOrCreateSectionData(*Group);
GroupD->setAlignment(4);