diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:39 +0300 |
commit | e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch) | |
tree | 64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/lib/MC/MCObjectFileInfo.cpp | |
parent | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff) | |
download | ydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/MC/MCObjectFileInfo.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/MC/MCObjectFileInfo.cpp | 248 |
1 files changed, 124 insertions, 124 deletions
diff --git a/contrib/libs/llvm12/lib/MC/MCObjectFileInfo.cpp b/contrib/libs/llvm12/lib/MC/MCObjectFileInfo.cpp index 23761956ca..398de873fe 100644 --- a/contrib/libs/llvm12/lib/MC/MCObjectFileInfo.cpp +++ b/contrib/libs/llvm12/lib/MC/MCObjectFileInfo.cpp @@ -497,10 +497,10 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) { Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags); StackSizesSection = Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, 0); - - PseudoProbeSection = Ctx->getELFSection(".pseudo_probe", DebugSecType, 0); - PseudoProbeDescSection = - Ctx->getELFSection(".pseudo_probe_desc", DebugSecType, 0); + + PseudoProbeSection = Ctx->getELFSection(".pseudo_probe", DebugSecType, 0); + PseudoProbeDescSection = + Ctx->getELFSection(".pseudo_probe_desc", DebugSecType, 0); } void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) { @@ -758,11 +758,11 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) { COFF::IMAGE_SCN_MEM_READ, SectionKind::getMetadata()); - GIATsSection = Ctx->getCOFFSection(".giats$y", - COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | - COFF::IMAGE_SCN_MEM_READ, - SectionKind::getMetadata()); - + GIATsSection = Ctx->getCOFFSection(".giats$y", + COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | + COFF::IMAGE_SCN_MEM_READ, + SectionKind::getMetadata()); + GLJMPSection = Ctx->getCOFFSection(".gljmp$y", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ, @@ -807,10 +807,10 @@ void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) { DwarfFrameSection = Ctx->getWasmSection(".debug_frame", SectionKind::getMetadata()); DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", SectionKind::getMetadata()); DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", SectionKind::getMetadata()); - DwarfGnuPubNamesSection = - Ctx->getWasmSection(".debug_gnu_pubnames", SectionKind::getMetadata()); - DwarfGnuPubTypesSection = - Ctx->getWasmSection(".debug_gnu_pubtypes", SectionKind::getMetadata()); + DwarfGnuPubNamesSection = + Ctx->getWasmSection(".debug_gnu_pubnames", SectionKind::getMetadata()); + DwarfGnuPubTypesSection = + Ctx->getWasmSection(".debug_gnu_pubtypes", SectionKind::getMetadata()); DwarfDebugNamesSection = Ctx->getWasmSection(".debug_names", SectionKind::getMetadata()); @@ -823,37 +823,37 @@ void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) { DwarfLoclistsSection = Ctx->getWasmSection(".debug_loclists", SectionKind::getMetadata()); - // Fission Sections - DwarfInfoDWOSection = - Ctx->getWasmSection(".debug_info.dwo", SectionKind::getMetadata()); - DwarfTypesDWOSection = - Ctx->getWasmSection(".debug_types.dwo", SectionKind::getMetadata()); - DwarfAbbrevDWOSection = - Ctx->getWasmSection(".debug_abbrev.dwo", SectionKind::getMetadata()); - DwarfStrDWOSection = - Ctx->getWasmSection(".debug_str.dwo", SectionKind::getMetadata()); - DwarfLineDWOSection = - Ctx->getWasmSection(".debug_line.dwo", SectionKind::getMetadata()); - DwarfLocDWOSection = - Ctx->getWasmSection(".debug_loc.dwo", SectionKind::getMetadata()); - DwarfStrOffDWOSection = - Ctx->getWasmSection(".debug_str_offsets.dwo", SectionKind::getMetadata()); - DwarfRnglistsDWOSection = - Ctx->getWasmSection(".debug_rnglists.dwo", SectionKind::getMetadata()); - DwarfMacinfoDWOSection = - Ctx->getWasmSection(".debug_macinfo.dwo", SectionKind::getMetadata()); - DwarfMacroDWOSection = - Ctx->getWasmSection(".debug_macro.dwo", SectionKind::getMetadata()); - - DwarfLoclistsDWOSection = - Ctx->getWasmSection(".debug_loclists.dwo", SectionKind::getMetadata()); - - // DWP Sections - DwarfCUIndexSection = - Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata(), 0); - DwarfTUIndexSection = - Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata(), 0); - + // Fission Sections + DwarfInfoDWOSection = + Ctx->getWasmSection(".debug_info.dwo", SectionKind::getMetadata()); + DwarfTypesDWOSection = + Ctx->getWasmSection(".debug_types.dwo", SectionKind::getMetadata()); + DwarfAbbrevDWOSection = + Ctx->getWasmSection(".debug_abbrev.dwo", SectionKind::getMetadata()); + DwarfStrDWOSection = + Ctx->getWasmSection(".debug_str.dwo", SectionKind::getMetadata()); + DwarfLineDWOSection = + Ctx->getWasmSection(".debug_line.dwo", SectionKind::getMetadata()); + DwarfLocDWOSection = + Ctx->getWasmSection(".debug_loc.dwo", SectionKind::getMetadata()); + DwarfStrOffDWOSection = + Ctx->getWasmSection(".debug_str_offsets.dwo", SectionKind::getMetadata()); + DwarfRnglistsDWOSection = + Ctx->getWasmSection(".debug_rnglists.dwo", SectionKind::getMetadata()); + DwarfMacinfoDWOSection = + Ctx->getWasmSection(".debug_macinfo.dwo", SectionKind::getMetadata()); + DwarfMacroDWOSection = + Ctx->getWasmSection(".debug_macro.dwo", SectionKind::getMetadata()); + + DwarfLoclistsDWOSection = + Ctx->getWasmSection(".debug_loclists.dwo", SectionKind::getMetadata()); + + // DWP Sections + DwarfCUIndexSection = + Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata(), 0); + DwarfTUIndexSection = + Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata(), 0); + // Wasm use data section for LSDA. // TODO Consider putting each function's exception table in a separate // section, as in -function-sections, to facilitate lld's --gc-section. @@ -870,31 +870,31 @@ void MCObjectFileInfo::initXCOFFMCObjectFileInfo(const Triple &T) { // csect for program code. TextSection = Ctx->getXCOFFSection( ".text", XCOFF::StorageMappingClass::XMC_PR, XCOFF::XTY_SD, - SectionKind::getText(), /* MultiSymbolsAllowed*/ true); + SectionKind::getText(), /* MultiSymbolsAllowed*/ true); DataSection = Ctx->getXCOFFSection( ".data", XCOFF::StorageMappingClass::XMC_RW, XCOFF::XTY_SD, - SectionKind::getData(), /* MultiSymbolsAllowed*/ true); + SectionKind::getData(), /* MultiSymbolsAllowed*/ true); ReadOnlySection = Ctx->getXCOFFSection( ".rodata", XCOFF::StorageMappingClass::XMC_RO, XCOFF::XTY_SD, - SectionKind::getReadOnly(), /* MultiSymbolsAllowed*/ true); + SectionKind::getReadOnly(), /* MultiSymbolsAllowed*/ true); - TOCBaseSection = - Ctx->getXCOFFSection("TOC", XCOFF::StorageMappingClass::XMC_TC0, - XCOFF::XTY_SD, SectionKind::getData()); + TOCBaseSection = + Ctx->getXCOFFSection("TOC", XCOFF::StorageMappingClass::XMC_TC0, + XCOFF::XTY_SD, SectionKind::getData()); // The TOC-base always has 0 size, but 4 byte alignment. TOCBaseSection->setAlignment(Align(4)); - LSDASection = Ctx->getXCOFFSection(".gcc_except_table", - XCOFF::StorageMappingClass::XMC_RO, - XCOFF::XTY_SD, SectionKind::getReadOnly()); - - CompactUnwindSection = - Ctx->getXCOFFSection(".eh_info_table", XCOFF::StorageMappingClass::XMC_RW, - XCOFF::XTY_SD, SectionKind::getData()); - + LSDASection = Ctx->getXCOFFSection(".gcc_except_table", + XCOFF::StorageMappingClass::XMC_RO, + XCOFF::XTY_SD, SectionKind::getReadOnly()); + + CompactUnwindSection = + Ctx->getXCOFFSection(".eh_info_table", XCOFF::StorageMappingClass::XMC_RW, + XCOFF::XTY_SD, SectionKind::getData()); + // DWARF sections for XCOFF are not csects. They are special STYP_DWARF // sections, and the individual DWARF sections are distinguished by their // section subtype. @@ -958,9 +958,9 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC, Env = IsWasm; initWasmMCObjectFileInfo(TT); break; - case Triple::GOFF: - report_fatal_error("Cannot initialize MC for GOFF object file format"); - break; + case Triple::GOFF: + report_fatal_error("Cannot initialize MC for GOFF object file format"); + break; case Triple::XCOFF: Env = IsXCOFF; initXCOFFMCObjectFileInfo(TT); @@ -977,12 +977,12 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name, case Triple::ELF: return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0, utostr(Hash)); - case Triple::Wasm: - return Ctx->getWasmSection(Name, SectionKind::getMetadata(), utostr(Hash), - MCContext::GenericSectionID); + case Triple::Wasm: + return Ctx->getWasmSection(Name, SectionKind::getMetadata(), utostr(Hash), + MCContext::GenericSectionID); case Triple::MachO: case Triple::COFF: - case Triple::GOFF: + case Triple::GOFF: case Triple::XCOFF: case Triple::UnknownObjectFormat: report_fatal_error("Cannot get DWARF comdat section for this object file " @@ -1006,64 +1006,64 @@ MCObjectFileInfo::getStackSizesSection(const MCSection &TextSec) const { } return Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, Flags, 0, - GroupName, ElfSec.getUniqueID(), + GroupName, ElfSec.getUniqueID(), + cast<MCSymbolELF>(TextSec.getBeginSymbol())); +} + +MCSection * +MCObjectFileInfo::getBBAddrMapSection(const MCSection &TextSec) const { + if (Env != IsELF) + return nullptr; + + const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec); + unsigned Flags = ELF::SHF_LINK_ORDER; + StringRef GroupName; + if (const MCSymbol *Group = ElfSec.getGroup()) { + GroupName = Group->getName(); + Flags |= ELF::SHF_GROUP; + } + + // 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(), cast<MCSymbolELF>(TextSec.getBeginSymbol())); } - -MCSection * -MCObjectFileInfo::getBBAddrMapSection(const MCSection &TextSec) const { - if (Env != IsELF) - return nullptr; - - const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec); - unsigned Flags = ELF::SHF_LINK_ORDER; - StringRef GroupName; - if (const MCSymbol *Group = ElfSec.getGroup()) { - GroupName = Group->getName(); - Flags |= ELF::SHF_GROUP; - } - - // 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(), - cast<MCSymbolELF>(TextSec.getBeginSymbol())); -} - -MCSection * -MCObjectFileInfo::getPseudoProbeSection(const MCSection *TextSec) const { - if (Env == IsELF) { - const auto *ElfSec = static_cast<const MCSectionELF *>(TextSec); - // Create a separate section for probes that comes with a comdat function. - if (const MCSymbol *Group = ElfSec->getGroup()) { - 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()); - } - } - return PseudoProbeSection; -} - -MCSection * -MCObjectFileInfo::getPseudoProbeDescSection(StringRef FuncName) const { - if (Env == IsELF) { - // Create a separate comdat group for each function's descriptor in order - // for the linker to deduplicate. The duplication, must be from different - // tranlation unit, can come from: - // 1. Inline functions defined in header files; - // 2. ThinLTO imported funcions; - // 3. Weak-linkage definitions. - // Use a concatenation of the section name and the function name as the - // group name so that descriptor-only groups won't be folded with groups of - // code. - if (TT.supportsCOMDAT() && !FuncName.empty()) { - auto *S = static_cast<MCSectionELF *>(PseudoProbeDescSection); - auto Flags = S->getFlags() | ELF::SHF_GROUP; - return Ctx->getELFSection(S->getName(), S->getType(), Flags, - S->getEntrySize(), - S->getName() + "_" + FuncName); - } - } - return PseudoProbeDescSection; -} + +MCSection * +MCObjectFileInfo::getPseudoProbeSection(const MCSection *TextSec) const { + if (Env == IsELF) { + const auto *ElfSec = static_cast<const MCSectionELF *>(TextSec); + // Create a separate section for probes that comes with a comdat function. + if (const MCSymbol *Group = ElfSec->getGroup()) { + 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()); + } + } + return PseudoProbeSection; +} + +MCSection * +MCObjectFileInfo::getPseudoProbeDescSection(StringRef FuncName) const { + if (Env == IsELF) { + // Create a separate comdat group for each function's descriptor in order + // for the linker to deduplicate. The duplication, must be from different + // tranlation unit, can come from: + // 1. Inline functions defined in header files; + // 2. ThinLTO imported funcions; + // 3. Weak-linkage definitions. + // Use a concatenation of the section name and the function name as the + // group name so that descriptor-only groups won't be folded with groups of + // code. + if (TT.supportsCOMDAT() && !FuncName.empty()) { + auto *S = static_cast<MCSectionELF *>(PseudoProbeDescSection); + auto Flags = S->getFlags() | ELF::SHF_GROUP; + return Ctx->getELFSection(S->getName(), S->getType(), Flags, + S->getEntrySize(), + S->getName() + "_" + FuncName); + } + } + return PseudoProbeDescSection; +} |