Instead use the Group symbol of MCSectionELF.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236033
91177308-0d34-0410-b5e6-
96231b3b80d8
void renameELFSection(const MCSectionELF *Section, StringRef Name);
void renameELFSection(const MCSectionELF *Section, StringRef Name);
- const MCSectionELF *CreateELFGroupSection();
+ const MCSectionELF *createELFGroupSection(const MCSymbol *Group);
const MCSectionCOFF *getCOFFSection(StringRef Section,
unsigned Characteristics,
const MCSectionCOFF *getCOFFSection(StringRef Section,
unsigned Characteristics,
uint64_t getSymbolIndexInSymbolTable(const MCAssembler &Asm,
const MCSymbol *S);
uint64_t getSymbolIndexInSymbolTable(const MCAssembler &Asm,
const MCSymbol *S);
- // Map from a group section to the signature symbol
- typedef DenseMap<const MCSectionELF*, const MCSymbol*> GroupMapTy;
// Map from a signature symbol to the group section
typedef DenseMap<const MCSymbol*, const MCSectionELF*> RevGroupMapTy;
// Start and end offset of each section
// Map from a signature symbol to the group section
typedef DenseMap<const MCSymbol*, const MCSectionELF*> RevGroupMapTy;
// Start and end offset of each section
// Create the sections that show up in the symbol table. Currently
// those are the .note.GNU-stack section and the group sections.
void createIndexedSections(MCAssembler &Asm, MCAsmLayout &Layout,
// Create the sections that show up in the symbol table. Currently
// those are the .note.GNU-stack section and the group sections.
void createIndexedSections(MCAssembler &Asm, MCAsmLayout &Layout,
- GroupMapTy &GroupMap, RevGroupMapTy &RevGroupMap,
+ RevGroupMapTy &RevGroupMap,
SectionIndexMapTy &SectionIndexMap);
void ExecutePostLayoutBinding(MCAssembler &Asm,
const MCAsmLayout &Layout) override;
void writeSectionHeader(ArrayRef<const MCSectionELF *> Sections,
SectionIndexMapTy &SectionIndexMap);
void ExecutePostLayoutBinding(MCAssembler &Asm,
const MCAsmLayout &Layout) override;
void writeSectionHeader(ArrayRef<const MCSectionELF *> Sections,
- MCAssembler &Asm, const GroupMapTy &GroupMap,
- const MCAsmLayout &Layout,
+ MCAssembler &Asm, const MCAsmLayout &Layout,
const SectionIndexMapTy &SectionIndexMap,
const SectionOffsetsTy &SectionOffsets);
const SectionIndexMapTy &SectionIndexMap,
const SectionOffsetsTy &SectionOffsets);
}
void ELFObjectWriter::createIndexedSections(
}
void ELFObjectWriter::createIndexedSections(
- MCAssembler &Asm, MCAsmLayout &Layout, GroupMapTy &GroupMap,
- RevGroupMapTy &RevGroupMap, SectionIndexMapTy &SectionIndexMap) {
+ MCAssembler &Asm, MCAsmLayout &Layout, RevGroupMapTy &RevGroupMap,
+ SectionIndexMapTy &SectionIndexMap) {
MCContext &Ctx = Asm.getContext();
// Build the groups
MCContext &Ctx = Asm.getContext();
// Build the groups
Asm.getOrCreateSymbolData(*SignatureSymbol);
const MCSectionELF *&Group = RevGroupMap[SignatureSymbol];
if (!Group) {
Asm.getOrCreateSymbolData(*SignatureSymbol);
const MCSectionELF *&Group = RevGroupMap[SignatureSymbol];
if (!Group) {
- Group = Ctx.CreateELFGroupSection();
+ Group = Ctx.createELFGroupSection(SignatureSymbol);
MCSectionData &Data = Asm.getOrCreateSectionData(*Group);
Data.setAlignment(4);
MCDataFragment *F = new MCDataFragment(&Data);
write(*F, uint32_t(ELF::GRP_COMDAT));
}
MCSectionData &Data = Asm.getOrCreateSectionData(*Group);
Data.setAlignment(4);
MCDataFragment *F = new MCDataFragment(&Data);
write(*F, uint32_t(ELF::GRP_COMDAT));
}
- GroupMap[Group] = SignatureSymbol;
}
computeIndexMap(Asm, SectionIndexMap);
}
computeIndexMap(Asm, SectionIndexMap);
void ELFObjectWriter::writeSectionHeader(
ArrayRef<const MCSectionELF *> Sections, MCAssembler &Asm,
void ELFObjectWriter::writeSectionHeader(
ArrayRef<const MCSectionELF *> Sections, MCAssembler &Asm,
- const GroupMapTy &GroupMap, const MCAsmLayout &Layout,
- const SectionIndexMapTy &SectionIndexMap,
+ const MCAsmLayout &Layout, const SectionIndexMapTy &SectionIndexMap,
const SectionOffsetsTy &SectionOffsets) {
const unsigned NumSections = Asm.size();
const SectionOffsetsTy &SectionOffsets) {
const unsigned NumSections = Asm.size();
if (Section.getType() != ELF::SHT_GROUP)
GroupSymbolIndex = 0;
else
if (Section.getType() != ELF::SHT_GROUP)
GroupSymbolIndex = 0;
else
- GroupSymbolIndex = getSymbolIndexInSymbolTable(Asm,
- GroupMap.lookup(&Section));
+ GroupSymbolIndex = getSymbolIndexInSymbolTable(Asm, Section.getGroup());
const std::pair<uint64_t, uint64_t> &Offsets = SectionOffsets[i];
uint64_t Size = Section.getType() == ELF::SHT_NOBITS
const std::pair<uint64_t, uint64_t> &Offsets = SectionOffsets[i];
uint64_t Size = Section.getType() == ELF::SHT_NOBITS
void ELFObjectWriter::WriteObject(MCAssembler &Asm,
const MCAsmLayout &Layout) {
void ELFObjectWriter::WriteObject(MCAssembler &Asm,
const MCAsmLayout &Layout) {
RevGroupMapTy RevGroupMap;
SectionIndexMapTy SectionIndexMap;
CompressDebugSections(Asm, const_cast<MCAsmLayout &>(Layout));
RevGroupMapTy RevGroupMap;
SectionIndexMapTy SectionIndexMap;
CompressDebugSections(Asm, const_cast<MCAsmLayout &>(Layout));
- createIndexedSections(Asm, const_cast<MCAsmLayout &>(Layout), GroupMap,
- RevGroupMap, SectionIndexMap);
+ createIndexedSections(Asm, const_cast<MCAsmLayout &>(Layout), RevGroupMap,
+ SectionIndexMap);
// Compute symbol table information.
computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap);
// Compute symbol table information.
computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap);
const unsigned SectionHeaderOffset = OS.tell();
// ... then the section header table ...
const unsigned SectionHeaderOffset = OS.tell();
// ... then the section header table ...
- writeSectionHeader(Sections, Asm, GroupMap, Layout, SectionIndexMap,
- SectionOffsets);
+ writeSectionHeader(Sections, Asm, Layout, SectionIndexMap, SectionOffsets);
if (is64Bit()) {
uint64_t Val = SectionHeaderOffset;
if (is64Bit()) {
uint64_t Val = SectionHeaderOffset;
-const MCSectionELF *MCContext::CreateELFGroupSection() {
+const MCSectionELF *MCContext::createELFGroupSection(const MCSymbol *Group) {
MCSectionELF *Result = new (*this)
MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4,
MCSectionELF *Result = new (*this)
MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4,
- nullptr, ~0, nullptr, nullptr);
+ Group, ~0, nullptr, nullptr);