Remove the GroupMapTy DenseMap. NFC.

Instead use the Group symbol of MCSectionELF.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236033 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-04-28 21:07:28 +00:00
parent 959b276771
commit 923bffd675
3 changed files with 13 additions and 21 deletions

View File

@@ -352,7 +352,7 @@ namespace llvm {
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, const MCSectionCOFF *getCOFFSection(StringRef Section,
unsigned Characteristics, unsigned Characteristics,

View File

@@ -217,8 +217,6 @@ class ELFObjectWriter : public MCObjectWriter {
uint64_t getSymbolIndexInSymbolTable(const MCAssembler &Asm, uint64_t getSymbolIndexInSymbolTable(const MCAssembler &Asm,
const MCSymbol *S); 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 // Map from a signature symbol to the group section
typedef DenseMap<const MCSymbol*, const MCSectionELF*> RevGroupMapTy; typedef DenseMap<const MCSymbol*, const MCSectionELF*> RevGroupMapTy;
// Start and end offset of each section // Start and end offset of each section
@@ -248,15 +246,14 @@ class ELFObjectWriter : public MCObjectWriter {
// Create the sections that show up in the symbol table. Currently // Create the sections that show up in the symbol table. Currently
// those are the .note.GNU-stack section and the group sections. // those are the .note.GNU-stack section and the group sections.
void createIndexedSections(MCAssembler &Asm, MCAsmLayout &Layout, void createIndexedSections(MCAssembler &Asm, MCAsmLayout &Layout,
GroupMapTy &GroupMap, RevGroupMapTy &RevGroupMap, RevGroupMapTy &RevGroupMap,
SectionIndexMapTy &SectionIndexMap); SectionIndexMapTy &SectionIndexMap);
void ExecutePostLayoutBinding(MCAssembler &Asm, void ExecutePostLayoutBinding(MCAssembler &Asm,
const MCAsmLayout &Layout) override; const MCAsmLayout &Layout) override;
void writeSectionHeader(ArrayRef<const MCSectionELF *> Sections, void writeSectionHeader(ArrayRef<const MCSectionELF *> Sections,
MCAssembler &Asm, const GroupMapTy &GroupMap, MCAssembler &Asm, const MCAsmLayout &Layout,
const MCAsmLayout &Layout,
const SectionIndexMapTy &SectionIndexMap, const SectionIndexMapTy &SectionIndexMap,
const SectionOffsetsTy &SectionOffsets); const SectionOffsetsTy &SectionOffsets);
@@ -1422,8 +1419,8 @@ void ELFObjectWriter::CreateMetadataSections(
} }
void ELFObjectWriter::createIndexedSections( void ELFObjectWriter::createIndexedSections(
MCAssembler &Asm, MCAsmLayout &Layout, GroupMapTy &GroupMap, MCAssembler &Asm, MCAsmLayout &Layout, RevGroupMapTy &RevGroupMap,
RevGroupMapTy &RevGroupMap, SectionIndexMapTy &SectionIndexMap) { SectionIndexMapTy &SectionIndexMap) {
MCContext &Ctx = Asm.getContext(); MCContext &Ctx = Asm.getContext();
// Build the groups // Build the groups
@@ -1438,13 +1435,12 @@ void ELFObjectWriter::createIndexedSections(
Asm.getOrCreateSymbolData(*SignatureSymbol); Asm.getOrCreateSymbolData(*SignatureSymbol);
const MCSectionELF *&Group = RevGroupMap[SignatureSymbol]; const MCSectionELF *&Group = RevGroupMap[SignatureSymbol];
if (!Group) { if (!Group) {
Group = Ctx.CreateELFGroupSection(); Group = Ctx.createELFGroupSection(SignatureSymbol);
MCSectionData &Data = Asm.getOrCreateSectionData(*Group); MCSectionData &Data = Asm.getOrCreateSectionData(*Group);
Data.setAlignment(4); Data.setAlignment(4);
MCDataFragment *F = new MCDataFragment(&Data); MCDataFragment *F = new MCDataFragment(&Data);
write(*F, uint32_t(ELF::GRP_COMDAT)); write(*F, uint32_t(ELF::GRP_COMDAT));
} }
GroupMap[Group] = SignatureSymbol;
} }
computeIndexMap(Asm, SectionIndexMap); computeIndexMap(Asm, SectionIndexMap);
@@ -1540,8 +1536,7 @@ void ELFObjectWriter::writeDataSectionData(MCAssembler &Asm,
void ELFObjectWriter::writeSectionHeader( void ELFObjectWriter::writeSectionHeader(
ArrayRef<const MCSectionELF *> Sections, MCAssembler &Asm, ArrayRef<const MCSectionELF *> Sections, MCAssembler &Asm,
const GroupMapTy &GroupMap, const MCAsmLayout &Layout, const MCAsmLayout &Layout, const SectionIndexMapTy &SectionIndexMap,
const SectionIndexMapTy &SectionIndexMap,
const SectionOffsetsTy &SectionOffsets) { const SectionOffsetsTy &SectionOffsets) {
const unsigned NumSections = Asm.size(); const unsigned NumSections = Asm.size();
@@ -1559,8 +1554,7 @@ void ELFObjectWriter::writeSectionHeader(
if (Section.getType() != ELF::SHT_GROUP) if (Section.getType() != ELF::SHT_GROUP)
GroupSymbolIndex = 0; GroupSymbolIndex = 0;
else else
GroupSymbolIndex = getSymbolIndexInSymbolTable(Asm, GroupSymbolIndex = getSymbolIndexInSymbolTable(Asm, Section.getGroup());
GroupMap.lookup(&Section));
const std::pair<uint64_t, uint64_t> &Offsets = SectionOffsets[i]; const std::pair<uint64_t, uint64_t> &Offsets = SectionOffsets[i];
uint64_t Size = Section.getType() == ELF::SHT_NOBITS uint64_t Size = Section.getType() == ELF::SHT_NOBITS
@@ -1574,13 +1568,12 @@ void ELFObjectWriter::writeSectionHeader(
void ELFObjectWriter::WriteObject(MCAssembler &Asm, void ELFObjectWriter::WriteObject(MCAssembler &Asm,
const MCAsmLayout &Layout) { const MCAsmLayout &Layout) {
GroupMapTy GroupMap;
RevGroupMapTy RevGroupMap; RevGroupMapTy RevGroupMap;
SectionIndexMapTy SectionIndexMap; SectionIndexMapTy SectionIndexMap;
CompressDebugSections(Asm, const_cast<MCAsmLayout &>(Layout)); CompressDebugSections(Asm, const_cast<MCAsmLayout &>(Layout));
createIndexedSections(Asm, const_cast<MCAsmLayout &>(Layout), GroupMap, createIndexedSections(Asm, const_cast<MCAsmLayout &>(Layout), RevGroupMap,
RevGroupMap, SectionIndexMap); SectionIndexMap);
// Compute symbol table information. // Compute symbol table information.
computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap); computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap);
@@ -1621,8 +1614,7 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
const unsigned SectionHeaderOffset = OS.tell(); const unsigned SectionHeaderOffset = OS.tell();
// ... then the section header table ... // ... then the section header table ...
writeSectionHeader(Sections, Asm, GroupMap, Layout, SectionIndexMap, writeSectionHeader(Sections, Asm, Layout, SectionIndexMap, SectionOffsets);
SectionOffsets);
if (is64Bit()) { if (is64Bit()) {
uint64_t Val = SectionHeaderOffset; uint64_t Val = SectionHeaderOffset;

View File

@@ -337,10 +337,10 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
return Result; return Result;
} }
const MCSectionELF *MCContext::CreateELFGroupSection() { const MCSectionELF *MCContext::createELFGroupSection(const MCSymbol *Group) {
MCSectionELF *Result = new (*this) MCSectionELF *Result = new (*this)
MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4, MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4,
nullptr, ~0, nullptr, nullptr); Group, ~0, nullptr, nullptr);
return Result; return Result;
} }