diff options
author | Petr Hosek <phosek@google.com> | 2021-01-31 22:42:35 -0800 |
---|---|---|
committer | Petr Hosek <phosek@google.com> | 2021-02-16 14:23:40 -0800 |
commit | 16af97393346ad636298605930a8b503a55eb40a (patch) | |
tree | 335d13493c66fe7bf73914ec5707e29024fd3a8e /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | 76609f17ced61f031a1fc77b2e0ed4aa9833917b (diff) | |
download | llvm-16af97393346ad636298605930a8b503a55eb40a.zip llvm-16af97393346ad636298605930a8b503a55eb40a.tar.gz llvm-16af97393346ad636298605930a8b503a55eb40a.tar.bz2 |
[MC][ELF] Support for zero flag section groups
This change introduces support for zero flag ELF section groups to LLVM.
LLVM already supports COMDAT sections, which in ELF are a special type
of ELF section groups. These are generally useful to enable linker GC
where you want a group of sections to always travel together, that is to
be either retained or discarded as a whole, but without the COMDAT
semantics. Other ELF assemblers already support zero flag ELF section
groups and this change helps us reach feature parity.
Differential Revision: https://reviews.llvm.org/D95851
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 14556d3..b99fce3 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -601,7 +601,7 @@ void ELFWriter::computeSymbolTable( // Symbol table unsigned EntrySize = is64Bit() ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32; MCSectionELF *SymtabSection = - Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0, EntrySize, ""); + Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0, EntrySize); SymtabSection->setAlignment(is64Bit() ? Align(8) : Align(4)); SymbolTableIndex = addToSectionTable(SymtabSection); @@ -702,7 +702,7 @@ void ELFWriter::computeSymbolTable( if (HasLargeSectionIndex) { MCSectionELF *SymtabShndxSection = - Ctx.getELFSection(".symtab_shndx", ELF::SHT_SYMTAB_SHNDX, 0, 4, ""); + Ctx.getELFSection(".symtab_shndx", ELF::SHT_SYMTAB_SHNDX, 0, 4); SymtabShndxSectionIndex = addToSectionTable(SymtabShndxSection); SymtabShndxSection->setAlignment(Align(4)); } @@ -1098,7 +1098,8 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) { if (SignatureSymbol) { unsigned &GroupIdx = RevGroupMap[SignatureSymbol]; if (!GroupIdx) { - MCSectionELF *Group = Ctx.createELFGroupSection(SignatureSymbol); + MCSectionELF *Group = + Ctx.createELFGroupSection(SignatureSymbol, Section.isComdat()); GroupIdx = addToSectionTable(Group); Group->setAlignment(Align(4)); Groups.push_back(Group); @@ -1123,7 +1124,7 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) { if (!Asm.CGProfile.empty()) { CGProfileSection = Ctx.getELFSection(".llvm.call-graph-profile", ELF::SHT_LLVM_CALL_GRAPH_PROFILE, - ELF::SHF_EXCLUDE, 16, ""); + ELF::SHF_EXCLUDE, 16); SectionIndexMap[CGProfileSection] = addToSectionTable(CGProfileSection); } @@ -1133,7 +1134,7 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) { const MCSymbol *SignatureSymbol = Group->getGroup(); assert(SignatureSymbol); - write(uint32_t(ELF::GRP_COMDAT)); + write(uint32_t(Group->isComdat() ? ELF::GRP_COMDAT : 0)); for (const MCSectionELF *Member : GroupMembers[SignatureSymbol]) { uint32_t SecIndex = SectionIndexMap.lookup(Member); write(SecIndex); |