aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectFileInfo.cpp
diff options
context:
space:
mode:
authorPetr Hosek <phosek@google.com>2021-01-31 22:42:35 -0800
committerPetr Hosek <phosek@google.com>2021-02-16 14:23:40 -0800
commit16af97393346ad636298605930a8b503a55eb40a (patch)
tree335d13493c66fe7bf73914ec5707e29024fd3a8e /llvm/lib/MC/MCObjectFileInfo.cpp
parent76609f17ced61f031a1fc77b2e0ed4aa9833917b (diff)
downloadllvm-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/MCObjectFileInfo.cpp')
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 0a682fb..9690eaf 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -371,19 +371,19 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
MergeableConst4Section =
Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
- ELF::SHF_ALLOC | ELF::SHF_MERGE, 4, "");
+ ELF::SHF_ALLOC | ELF::SHF_MERGE, 4);
MergeableConst8Section =
Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
- ELF::SHF_ALLOC | ELF::SHF_MERGE, 8, "");
+ ELF::SHF_ALLOC | ELF::SHF_MERGE, 8);
MergeableConst16Section =
Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
- ELF::SHF_ALLOC | ELF::SHF_MERGE, 16, "");
+ ELF::SHF_ALLOC | ELF::SHF_MERGE, 16);
MergeableConst32Section =
Ctx->getELFSection(".rodata.cst32", ELF::SHT_PROGBITS,
- ELF::SHF_ALLOC | ELF::SHF_MERGE, 32, "");
+ ELF::SHF_ALLOC | ELF::SHF_MERGE, 32);
// Exception Handling Sections.
@@ -412,7 +412,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
DwarfLineSection = Ctx->getELFSection(".debug_line", DebugSecType, 0);
DwarfLineStrSection =
Ctx->getELFSection(".debug_line_str", DebugSecType,
- ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
+ ELF::SHF_MERGE | ELF::SHF_STRINGS, 1);
DwarfFrameSection = Ctx->getELFSection(".debug_frame", DebugSecType, 0);
DwarfPubNamesSection =
Ctx->getELFSection(".debug_pubnames", DebugSecType, 0);
@@ -424,7 +424,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
Ctx->getELFSection(".debug_gnu_pubtypes", DebugSecType, 0);
DwarfStrSection =
Ctx->getELFSection(".debug_str", DebugSecType,
- ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
+ ELF::SHF_MERGE | ELF::SHF_STRINGS, 1);
DwarfLocSection = Ctx->getELFSection(".debug_loc", DebugSecType, 0);
DwarfARangesSection =
Ctx->getELFSection(".debug_aranges", DebugSecType, 0);
@@ -464,7 +464,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
Ctx->getELFSection(".debug_abbrev.dwo", DebugSecType, ELF::SHF_EXCLUDE);
DwarfStrDWOSection = Ctx->getELFSection(
".debug_str.dwo", DebugSecType,
- ELF::SHF_MERGE | ELF::SHF_STRINGS | ELF::SHF_EXCLUDE, 1, "");
+ ELF::SHF_MERGE | ELF::SHF_STRINGS | ELF::SHF_EXCLUDE, 1);
DwarfLineDWOSection =
Ctx->getELFSection(".debug_line.dwo", DebugSecType, ELF::SHF_EXCLUDE);
DwarfLocDWOSection =
@@ -981,7 +981,7 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name,
switch (TT.getObjectFormat()) {
case Triple::ELF:
return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0,
- utostr(Hash));
+ utostr(Hash), /*IsComdat=*/true);
case Triple::Wasm:
return Ctx->getWasmSection(Name, SectionKind::getMetadata(), utostr(Hash),
MCContext::GenericSectionID);
@@ -1011,7 +1011,7 @@ MCObjectFileInfo::getStackSizesSection(const MCSection &TextSec) const {
}
return Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, Flags, 0,
- GroupName, ElfSec.getUniqueID(),
+ GroupName, true, ElfSec.getUniqueID(),
cast<MCSymbolELF>(TextSec.getBeginSymbol()));
}
@@ -1031,7 +1031,7 @@ MCObjectFileInfo::getBBAddrMapSection(const MCSection &TextSec) const {
// Use the text section's begin symbol and unique ID to create a separate
// .llvm_bb_addr_map section associated with every unique text section.
return Ctx->getELFSection(".llvm_bb_addr_map", ELF::SHT_LLVM_BB_ADDR_MAP,
- Flags, 0, GroupName, ElfSec.getUniqueID(),
+ Flags, 0, GroupName, true, ElfSec.getUniqueID(),
cast<MCSymbolELF>(TextSec.getBeginSymbol()));
}
@@ -1044,7 +1044,8 @@ MCObjectFileInfo::getPseudoProbeSection(const MCSection *TextSec) const {
auto *S = static_cast<MCSectionELF *>(PseudoProbeSection);
auto Flags = S->getFlags() | ELF::SHF_GROUP;
return Ctx->getELFSection(S->getName(), S->getType(), Flags,
- S->getEntrySize(), Group->getName());
+ S->getEntrySize(), Group->getName(),
+ /*IsComdat=*/true);
}
}
return PseudoProbeSection;
@@ -1067,7 +1068,8 @@ MCObjectFileInfo::getPseudoProbeDescSection(StringRef FuncName) const {
auto Flags = S->getFlags() | ELF::SHF_GROUP;
return Ctx->getELFSection(S->getName(), S->getType(), Flags,
S->getEntrySize(),
- S->getName() + "_" + FuncName);
+ S->getName() + "_" + FuncName,
+ /*IsComdat=*/true);
}
}
return PseudoProbeDescSection;