LCOV - code coverage report
Current view: top level - lib/MC - MCObjectFileInfo.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 347 354 98.0 %
Date: 2018-10-20 13:21:21 Functions: 8 8 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- MCObjectFileInfo.cpp - Object File Information --------------------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #include "llvm/MC/MCObjectFileInfo.h"
      11             : #include "llvm/ADT/StringExtras.h"
      12             : #include "llvm/ADT/Triple.h"
      13             : #include "llvm/BinaryFormat/COFF.h"
      14             : #include "llvm/BinaryFormat/ELF.h"
      15             : #include "llvm/MC/MCAsmInfo.h"
      16             : #include "llvm/MC/MCContext.h"
      17             : #include "llvm/MC/MCSection.h"
      18             : #include "llvm/MC/MCSectionCOFF.h"
      19             : #include "llvm/MC/MCSectionELF.h"
      20             : #include "llvm/MC/MCSectionMachO.h"
      21             : #include "llvm/MC/MCSectionWasm.h"
      22             : 
      23             : using namespace llvm;
      24             : 
      25        3279 : static bool useCompactUnwind(const Triple &T) {
      26             :   // Only on darwin.
      27             :   if (!T.isOSDarwin())
      28             :     return false;
      29             : 
      30             :   // aarch64 always has it.
      31        3190 :   if (T.getArch() == Triple::aarch64)
      32             :     return true;
      33             : 
      34             :   // armv7k always has it.
      35        2825 :   if (T.isWatchABI())
      36             :     return true;
      37             : 
      38             :   // Use it on newer version of OS X.
      39        2422 :   if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6))
      40             :     return true;
      41             : 
      42             :   // And the iOS simulator.
      43         372 :   if (T.isiOS() &&
      44         372 :       (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86))
      45          18 :     return true;
      46             : 
      47             :   return false;
      48             : }
      49             : 
      50        3279 : void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
      51             :   // MachO
      52        3279 :   SupportsWeakOmittedEHFrame = false;
      53             : 
      54        3279 :   EHFrameSection = Ctx->getMachOSection(
      55             :       "__TEXT", "__eh_frame",
      56             :       MachO::S_COALESCED | MachO::S_ATTR_NO_TOC |
      57             :           MachO::S_ATTR_STRIP_STATIC_SYMS | MachO::S_ATTR_LIVE_SUPPORT,
      58             :       SectionKind::getReadOnly());
      59             : 
      60        3190 :   if (T.isOSDarwin() && T.getArch() == Triple::aarch64)
      61         365 :     SupportsCompactUnwindWithoutEHFrame = true;
      62             : 
      63        3279 :   if (T.isWatchABI())
      64          25 :     OmitDwarfIfHaveCompactUnwind = true;
      65             : 
      66        3279 :   FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
      67             : 
      68             :   // .comm doesn't support alignment before Leopard.
      69        2602 :   if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5))
      70        1647 :     CommDirectiveSupportsAlignment = false;
      71             : 
      72             :   TextSection // .text
      73        3279 :     = Ctx->getMachOSection("__TEXT", "__text",
      74             :                            MachO::S_ATTR_PURE_INSTRUCTIONS,
      75             :                            SectionKind::getText());
      76             :   DataSection // .data
      77        3279 :       = Ctx->getMachOSection("__DATA", "__data", 0, SectionKind::getData());
      78             : 
      79             :   // BSSSection might not be expected initialized on msvc.
      80        3279 :   BSSSection = nullptr;
      81             : 
      82             :   TLSDataSection // .tdata
      83        3279 :       = Ctx->getMachOSection("__DATA", "__thread_data",
      84             :                              MachO::S_THREAD_LOCAL_REGULAR,
      85             :                              SectionKind::getData());
      86             :   TLSBSSSection // .tbss
      87        3279 :     = Ctx->getMachOSection("__DATA", "__thread_bss",
      88             :                            MachO::S_THREAD_LOCAL_ZEROFILL,
      89             :                            SectionKind::getThreadBSS());
      90             : 
      91             :   // TODO: Verify datarel below.
      92             :   TLSTLVSection // .tlv
      93        3279 :       = Ctx->getMachOSection("__DATA", "__thread_vars",
      94             :                              MachO::S_THREAD_LOCAL_VARIABLES,
      95             :                              SectionKind::getData());
      96             : 
      97        3279 :   TLSThreadInitSection = Ctx->getMachOSection(
      98             :       "__DATA", "__thread_init", MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
      99             :       SectionKind::getData());
     100             : 
     101             :   CStringSection // .cstring
     102        3279 :     = Ctx->getMachOSection("__TEXT", "__cstring",
     103             :                            MachO::S_CSTRING_LITERALS,
     104             :                            SectionKind::getMergeable1ByteCString());
     105             :   UStringSection
     106        3279 :     = Ctx->getMachOSection("__TEXT","__ustring", 0,
     107             :                            SectionKind::getMergeable2ByteCString());
     108             :   FourByteConstantSection // .literal4
     109        3279 :     = Ctx->getMachOSection("__TEXT", "__literal4",
     110             :                            MachO::S_4BYTE_LITERALS,
     111             :                            SectionKind::getMergeableConst4());
     112             :   EightByteConstantSection // .literal8
     113        3279 :     = Ctx->getMachOSection("__TEXT", "__literal8",
     114             :                            MachO::S_8BYTE_LITERALS,
     115             :                            SectionKind::getMergeableConst8());
     116             : 
     117             :   SixteenByteConstantSection // .literal16
     118        3279 :       = Ctx->getMachOSection("__TEXT", "__literal16",
     119             :                              MachO::S_16BYTE_LITERALS,
     120             :                              SectionKind::getMergeableConst16());
     121             : 
     122             :   ReadOnlySection  // .const
     123        3279 :     = Ctx->getMachOSection("__TEXT", "__const", 0,
     124             :                            SectionKind::getReadOnly());
     125             : 
     126             :   // If the target is not powerpc, map the coal sections to the non-coal
     127             :   // sections.
     128             :   //
     129             :   // "__TEXT/__textcoal_nt" => section "__TEXT/__text"
     130             :   // "__TEXT/__const_coal"  => section "__TEXT/__const"
     131             :   // "__DATA/__datacoal_nt" => section "__DATA/__data"
     132        3279 :   Triple::ArchType ArchTy = T.getArch();
     133             : 
     134             :   ConstDataSection  // .const_data
     135        3279 :     = Ctx->getMachOSection("__DATA", "__const", 0,
     136             :                            SectionKind::getReadOnlyWithRel());
     137             : 
     138        3279 :   if (ArchTy == Triple::ppc || ArchTy == Triple::ppc64) {
     139             :     TextCoalSection
     140           4 :       = Ctx->getMachOSection("__TEXT", "__textcoal_nt",
     141             :                              MachO::S_COALESCED |
     142             :                              MachO::S_ATTR_PURE_INSTRUCTIONS,
     143             :                              SectionKind::getText());
     144             :     ConstTextCoalSection
     145           4 :       = Ctx->getMachOSection("__TEXT", "__const_coal",
     146             :                              MachO::S_COALESCED,
     147             :                              SectionKind::getReadOnly());
     148           4 :     DataCoalSection = Ctx->getMachOSection(
     149             :         "__DATA", "__datacoal_nt", MachO::S_COALESCED, SectionKind::getData());
     150           4 :     ConstDataCoalSection = DataCoalSection;
     151             :   } else {
     152        3275 :     TextCoalSection = TextSection;
     153        3275 :     ConstTextCoalSection = ReadOnlySection;
     154        3275 :     DataCoalSection = DataSection;
     155        3275 :     ConstDataCoalSection = ConstDataSection;
     156             :   }
     157             : 
     158             :   DataCommonSection
     159        3279 :     = Ctx->getMachOSection("__DATA","__common",
     160             :                            MachO::S_ZEROFILL,
     161             :                            SectionKind::getBSS());
     162             :   DataBSSSection
     163        3279 :     = Ctx->getMachOSection("__DATA","__bss", MachO::S_ZEROFILL,
     164             :                            SectionKind::getBSS());
     165             : 
     166             : 
     167             :   LazySymbolPointerSection
     168        3279 :     = Ctx->getMachOSection("__DATA", "__la_symbol_ptr",
     169             :                            MachO::S_LAZY_SYMBOL_POINTERS,
     170             :                            SectionKind::getMetadata());
     171             :   NonLazySymbolPointerSection
     172        3279 :     = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr",
     173             :                            MachO::S_NON_LAZY_SYMBOL_POINTERS,
     174             :                            SectionKind::getMetadata());
     175             : 
     176             :   ThreadLocalPointerSection
     177        3279 :     = Ctx->getMachOSection("__DATA", "__thread_ptr",
     178             :                            MachO::S_THREAD_LOCAL_VARIABLE_POINTERS,
     179             :                            SectionKind::getMetadata());
     180             : 
     181             :   // Exception Handling.
     182        3279 :   LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0,
     183             :                                      SectionKind::getReadOnlyWithRel());
     184             : 
     185        3279 :   COFFDebugSymbolsSection = nullptr;
     186        3279 :   COFFDebugTypesSection = nullptr;
     187        3279 :   COFFGlobalTypeHashesSection = nullptr;
     188             : 
     189        3279 :   if (useCompactUnwind(T)) {
     190        1142 :     CompactUnwindSection =
     191        1142 :         Ctx->getMachOSection("__LD", "__compact_unwind", MachO::S_ATTR_DEBUG,
     192             :                              SectionKind::getReadOnly());
     193             : 
     194        1142 :     if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)
     195         679 :       CompactUnwindDwarfEHFrameOnly = 0x04000000;  // UNWIND_X86_64_MODE_DWARF
     196         463 :     else if (T.getArch() == Triple::aarch64)
     197         365 :       CompactUnwindDwarfEHFrameOnly = 0x03000000;  // UNWIND_ARM64_MODE_DWARF
     198          98 :     else if (T.getArch() == Triple::arm || T.getArch() == Triple::thumb)
     199          98 :       CompactUnwindDwarfEHFrameOnly = 0x04000000;  // UNWIND_ARM_MODE_DWARF
     200             :   }
     201             : 
     202             :   // Debug Information.
     203        3279 :   DwarfDebugNamesSection =
     204        3279 :       Ctx->getMachOSection("__DWARF", "__debug_names", MachO::S_ATTR_DEBUG,
     205             :                            SectionKind::getMetadata(), "debug_names_begin");
     206        3279 :   DwarfAccelNamesSection =
     207        3279 :       Ctx->getMachOSection("__DWARF", "__apple_names", MachO::S_ATTR_DEBUG,
     208             :                            SectionKind::getMetadata(), "names_begin");
     209        3279 :   DwarfAccelObjCSection =
     210        3279 :       Ctx->getMachOSection("__DWARF", "__apple_objc", MachO::S_ATTR_DEBUG,
     211             :                            SectionKind::getMetadata(), "objc_begin");
     212             :   // 16 character section limit...
     213        3279 :   DwarfAccelNamespaceSection =
     214        3279 :       Ctx->getMachOSection("__DWARF", "__apple_namespac", MachO::S_ATTR_DEBUG,
     215             :                            SectionKind::getMetadata(), "namespac_begin");
     216        3279 :   DwarfAccelTypesSection =
     217        3279 :       Ctx->getMachOSection("__DWARF", "__apple_types", MachO::S_ATTR_DEBUG,
     218             :                            SectionKind::getMetadata(), "types_begin");
     219             : 
     220        3279 :   DwarfSwiftASTSection =
     221        3279 :       Ctx->getMachOSection("__DWARF", "__swift_ast", MachO::S_ATTR_DEBUG,
     222             :                            SectionKind::getMetadata());
     223             : 
     224        3279 :   DwarfAbbrevSection =
     225        3279 :       Ctx->getMachOSection("__DWARF", "__debug_abbrev", MachO::S_ATTR_DEBUG,
     226             :                            SectionKind::getMetadata(), "section_abbrev");
     227        3279 :   DwarfInfoSection =
     228        3279 :       Ctx->getMachOSection("__DWARF", "__debug_info", MachO::S_ATTR_DEBUG,
     229             :                            SectionKind::getMetadata(), "section_info");
     230        3279 :   DwarfLineSection =
     231        3279 :       Ctx->getMachOSection("__DWARF", "__debug_line", MachO::S_ATTR_DEBUG,
     232             :                            SectionKind::getMetadata(), "section_line");
     233        3279 :   DwarfLineStrSection =
     234        3279 :       Ctx->getMachOSection("__DWARF", "__debug_line_str", MachO::S_ATTR_DEBUG,
     235             :                            SectionKind::getMetadata(), "section_line_str");
     236        3279 :   DwarfFrameSection =
     237        3279 :       Ctx->getMachOSection("__DWARF", "__debug_frame", MachO::S_ATTR_DEBUG,
     238             :                            SectionKind::getMetadata());
     239        3279 :   DwarfPubNamesSection =
     240        3279 :       Ctx->getMachOSection("__DWARF", "__debug_pubnames", MachO::S_ATTR_DEBUG,
     241             :                            SectionKind::getMetadata());
     242        3279 :   DwarfPubTypesSection =
     243        3279 :       Ctx->getMachOSection("__DWARF", "__debug_pubtypes", MachO::S_ATTR_DEBUG,
     244             :                            SectionKind::getMetadata());
     245        3279 :   DwarfGnuPubNamesSection =
     246        3279 :       Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn", MachO::S_ATTR_DEBUG,
     247             :                            SectionKind::getMetadata());
     248        3279 :   DwarfGnuPubTypesSection =
     249        3279 :       Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt", MachO::S_ATTR_DEBUG,
     250             :                            SectionKind::getMetadata());
     251        3279 :   DwarfStrSection =
     252        3279 :       Ctx->getMachOSection("__DWARF", "__debug_str", MachO::S_ATTR_DEBUG,
     253             :                            SectionKind::getMetadata(), "info_string");
     254        3279 :   DwarfStrOffSection =
     255        3279 :       Ctx->getMachOSection("__DWARF", "__debug_str_offs", MachO::S_ATTR_DEBUG,
     256             :                            SectionKind::getMetadata(), "section_str_off");
     257        3279 :   DwarfLocSection =
     258        3279 :       Ctx->getMachOSection("__DWARF", "__debug_loc", MachO::S_ATTR_DEBUG,
     259             :                            SectionKind::getMetadata(), "section_debug_loc");
     260        3279 :   DwarfARangesSection =
     261        3279 :       Ctx->getMachOSection("__DWARF", "__debug_aranges", MachO::S_ATTR_DEBUG,
     262             :                            SectionKind::getMetadata());
     263        3279 :   DwarfRangesSection =
     264        3279 :       Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG,
     265             :                            SectionKind::getMetadata(), "debug_range");
     266        3279 :   DwarfRnglistsSection =
     267        3279 :       Ctx->getMachOSection("__DWARF", "__debug_rnglists", MachO::S_ATTR_DEBUG,
     268             :                            SectionKind::getMetadata(), "debug_range");
     269        3279 :   DwarfMacinfoSection =
     270        3279 :       Ctx->getMachOSection("__DWARF", "__debug_macinfo", MachO::S_ATTR_DEBUG,
     271             :                            SectionKind::getMetadata(), "debug_macinfo");
     272        3279 :   DwarfDebugInlineSection =
     273        3279 :       Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG,
     274             :                            SectionKind::getMetadata());
     275        3279 :   DwarfCUIndexSection =
     276        3279 :       Ctx->getMachOSection("__DWARF", "__debug_cu_index", MachO::S_ATTR_DEBUG,
     277             :                            SectionKind::getMetadata());
     278        3279 :   DwarfTUIndexSection =
     279        3279 :       Ctx->getMachOSection("__DWARF", "__debug_tu_index", MachO::S_ATTR_DEBUG,
     280             :                            SectionKind::getMetadata());
     281        3279 :   StackMapSection = Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps",
     282             :                                          0, SectionKind::getMetadata());
     283             : 
     284        3279 :   FaultMapSection = Ctx->getMachOSection("__LLVM_FAULTMAPS", "__llvm_faultmaps",
     285             :                                          0, SectionKind::getMetadata());
     286             : 
     287        3279 :   TLSExtraDataSection = TLSTLVSection;
     288        3279 : }
     289             : 
     290       33169 : void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
     291       33169 :   switch (T.getArch()) {
     292        3147 :   case Triple::mips:
     293             :   case Triple::mipsel:
     294             :   case Triple::mips64:
     295             :   case Triple::mips64el:
     296        6294 :     FDECFIEncoding = Ctx->getAsmInfo()->getCodePointerSize() == 4
     297        3147 :                          ? dwarf::DW_EH_PE_sdata4
     298             :                          : dwarf::DW_EH_PE_sdata8;
     299        3147 :     break;
     300       15066 :   case Triple::ppc64:
     301             :   case Triple::ppc64le:
     302             :   case Triple::x86_64:
     303       15066 :     FDECFIEncoding = dwarf::DW_EH_PE_pcrel |
     304             :                      (Large ? dwarf::DW_EH_PE_sdata8 : dwarf::DW_EH_PE_sdata4);
     305       15066 :     break;
     306          84 :   case Triple::bpfel:
     307             :   case Triple::bpfeb:
     308          84 :     FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
     309          84 :     break;
     310        1127 :   case Triple::hexagon:
     311        1127 :     FDECFIEncoding =
     312        1127 :         PositionIndependent ? dwarf::DW_EH_PE_pcrel : dwarf::DW_EH_PE_absptr;
     313        1127 :     break;
     314       13745 :   default:
     315       13745 :     FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
     316       13745 :     break;
     317             :   }
     318             : 
     319             :   unsigned EHSectionType = T.getArch() == Triple::x86_64
     320       33169 :                                ? ELF::SHT_X86_64_UNWIND
     321             :                                : ELF::SHT_PROGBITS;
     322             : 
     323             :   // Solaris requires different flags for .eh_frame to seemingly every other
     324             :   // platform.
     325             :   unsigned EHSectionFlags = ELF::SHF_ALLOC;
     326       33169 :   if (T.isOSSolaris() && T.getArch() != Triple::x86_64)
     327             :     EHSectionFlags |= ELF::SHF_WRITE;
     328             : 
     329             :   // ELF
     330       33169 :   BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
     331             :                                   ELF::SHF_WRITE | ELF::SHF_ALLOC);
     332             : 
     333       33169 :   TextSection = Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
     334             :                                    ELF::SHF_EXECINSTR | ELF::SHF_ALLOC);
     335             : 
     336       33169 :   DataSection = Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
     337             :                                    ELF::SHF_WRITE | ELF::SHF_ALLOC);
     338             : 
     339       33169 :   ReadOnlySection =
     340       33169 :       Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
     341             : 
     342       33169 :   TLSDataSection =
     343       33169 :       Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
     344             :                          ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
     345             : 
     346       33169 :   TLSBSSSection = Ctx->getELFSection(
     347             :       ".tbss", ELF::SHT_NOBITS, ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
     348             : 
     349       33169 :   DataRelROSection = Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
     350             :                                         ELF::SHF_ALLOC | ELF::SHF_WRITE);
     351             : 
     352       33169 :   MergeableConst4Section =
     353       33169 :       Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
     354             :                          ELF::SHF_ALLOC | ELF::SHF_MERGE, 4, "");
     355             : 
     356       33169 :   MergeableConst8Section =
     357       33169 :       Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
     358             :                          ELF::SHF_ALLOC | ELF::SHF_MERGE, 8, "");
     359             : 
     360       33169 :   MergeableConst16Section =
     361       33169 :       Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
     362             :                          ELF::SHF_ALLOC | ELF::SHF_MERGE, 16, "");
     363             : 
     364       33169 :   MergeableConst32Section =
     365       33169 :       Ctx->getELFSection(".rodata.cst32", ELF::SHT_PROGBITS,
     366             :                          ELF::SHF_ALLOC | ELF::SHF_MERGE, 32, "");
     367             : 
     368             :   // Exception Handling Sections.
     369             : 
     370             :   // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
     371             :   // it contains relocatable pointers.  In PIC mode, this is probably a big
     372             :   // runtime hit for C++ apps.  Either the contents of the LSDA need to be
     373             :   // adjusted or this should be a data section.
     374       33169 :   LSDASection = Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
     375             :                                    ELF::SHF_ALLOC);
     376             : 
     377       33169 :   COFFDebugSymbolsSection = nullptr;
     378       33169 :   COFFDebugTypesSection = nullptr;
     379             : 
     380             :   unsigned DebugSecType = ELF::SHT_PROGBITS;
     381             : 
     382             :   // MIPS .debug_* sections should have SHT_MIPS_DWARF section type
     383             :   // to distinguish among sections contain DWARF and ECOFF debug formats.
     384             :   // Sections with ECOFF debug format are obsoleted and marked by SHT_PROGBITS.
     385             :   if (T.isMIPS())
     386             :     DebugSecType = ELF::SHT_MIPS_DWARF;
     387             : 
     388             :   // Debug Info Sections.
     389       33169 :   DwarfAbbrevSection =
     390       33169 :       Ctx->getELFSection(".debug_abbrev", DebugSecType, 0);
     391       33169 :   DwarfInfoSection = Ctx->getELFSection(".debug_info", DebugSecType, 0);
     392       33169 :   DwarfLineSection = Ctx->getELFSection(".debug_line", DebugSecType, 0);
     393       33169 :   DwarfLineStrSection =
     394       33169 :       Ctx->getELFSection(".debug_line_str", DebugSecType,
     395             :                          ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
     396       33169 :   DwarfFrameSection = Ctx->getELFSection(".debug_frame", DebugSecType, 0);
     397       33169 :   DwarfPubNamesSection =
     398       33169 :       Ctx->getELFSection(".debug_pubnames", DebugSecType, 0);
     399       33169 :   DwarfPubTypesSection =
     400       33169 :       Ctx->getELFSection(".debug_pubtypes", DebugSecType, 0);
     401       33169 :   DwarfGnuPubNamesSection =
     402       33169 :       Ctx->getELFSection(".debug_gnu_pubnames", DebugSecType, 0);
     403       33169 :   DwarfGnuPubTypesSection =
     404       33169 :       Ctx->getELFSection(".debug_gnu_pubtypes", DebugSecType, 0);
     405       33169 :   DwarfStrSection =
     406       33169 :       Ctx->getELFSection(".debug_str", DebugSecType,
     407             :                          ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
     408       33169 :   DwarfLocSection = Ctx->getELFSection(".debug_loc", DebugSecType, 0);
     409       33169 :   DwarfARangesSection =
     410       33169 :       Ctx->getELFSection(".debug_aranges", DebugSecType, 0);
     411       33169 :   DwarfRangesSection =
     412       33169 :       Ctx->getELFSection(".debug_ranges", DebugSecType, 0);
     413       33169 :   DwarfMacinfoSection =
     414       33169 :       Ctx->getELFSection(".debug_macinfo", DebugSecType, 0);
     415             : 
     416             :   // DWARF5 Experimental Debug Info
     417             : 
     418             :   // Accelerator Tables
     419       33169 :   DwarfDebugNamesSection =
     420       33169 :       Ctx->getELFSection(".debug_names", ELF::SHT_PROGBITS, 0);
     421       33169 :   DwarfAccelNamesSection =
     422       33169 :       Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0);
     423       33169 :   DwarfAccelObjCSection =
     424       33169 :       Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0);
     425       33169 :   DwarfAccelNamespaceSection =
     426       33169 :       Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0);
     427       33169 :   DwarfAccelTypesSection =
     428       33169 :       Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0);
     429             : 
     430             :   // String Offset and Address Sections
     431       33169 :   DwarfStrOffSection =
     432       33169 :       Ctx->getELFSection(".debug_str_offsets", DebugSecType, 0);
     433       33169 :   DwarfAddrSection = Ctx->getELFSection(".debug_addr", DebugSecType, 0);
     434       33169 :   DwarfRnglistsSection = Ctx->getELFSection(".debug_rnglists", DebugSecType, 0);
     435             : 
     436             :   // Fission Sections
     437       33169 :   DwarfInfoDWOSection =
     438       33169 :       Ctx->getELFSection(".debug_info.dwo", DebugSecType, ELF::SHF_EXCLUDE);
     439       33169 :   DwarfTypesDWOSection =
     440       33169 :       Ctx->getELFSection(".debug_types.dwo", DebugSecType, ELF::SHF_EXCLUDE);
     441       33169 :   DwarfAbbrevDWOSection =
     442       33169 :       Ctx->getELFSection(".debug_abbrev.dwo", DebugSecType, ELF::SHF_EXCLUDE);
     443       33169 :   DwarfStrDWOSection = Ctx->getELFSection(
     444             :       ".debug_str.dwo", DebugSecType,
     445             :       ELF::SHF_MERGE | ELF::SHF_STRINGS | ELF::SHF_EXCLUDE, 1, "");
     446       33169 :   DwarfLineDWOSection =
     447       33169 :       Ctx->getELFSection(".debug_line.dwo", DebugSecType, ELF::SHF_EXCLUDE);
     448       33169 :   DwarfLocDWOSection =
     449       33169 :       Ctx->getELFSection(".debug_loc.dwo", DebugSecType, ELF::SHF_EXCLUDE);
     450       33169 :   DwarfStrOffDWOSection = Ctx->getELFSection(".debug_str_offsets.dwo",
     451             :                                              DebugSecType, ELF::SHF_EXCLUDE);
     452       33169 :   DwarfRnglistsDWOSection =
     453       33169 :       Ctx->getELFSection(".debug_rnglists.dwo", DebugSecType, ELF::SHF_EXCLUDE);
     454             : 
     455             :   // DWP Sections
     456       33169 :   DwarfCUIndexSection =
     457       33169 :       Ctx->getELFSection(".debug_cu_index", DebugSecType, 0);
     458       33169 :   DwarfTUIndexSection =
     459       33169 :       Ctx->getELFSection(".debug_tu_index", DebugSecType, 0);
     460             : 
     461       33169 :   StackMapSection =
     462       33169 :       Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
     463             : 
     464       33169 :   FaultMapSection =
     465       33169 :       Ctx->getELFSection(".llvm_faultmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
     466             : 
     467       33169 :   EHFrameSection =
     468       33169 :       Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
     469             : 
     470       33169 :   StackSizesSection = Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, 0);
     471       33169 : }
     472             : 
     473        1058 : void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
     474        2116 :   EHFrameSection = Ctx->getCOFFSection(
     475             :       ".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     476             :                        COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
     477             :       SectionKind::getData());
     478             : 
     479             :   // Set the `IMAGE_SCN_MEM_16BIT` flag when compiling for thumb mode.  This is
     480             :   // used to indicate to the linker that the text segment contains thumb instructions
     481             :   // and to set the ISA selection bit for calls accordingly.
     482        1058 :   const bool IsThumb = T.getArch() == Triple::thumb;
     483             : 
     484        1058 :   CommDirectiveSupportsAlignment = true;
     485             : 
     486             :   // COFF
     487        2116 :   BSSSection = Ctx->getCOFFSection(
     488             :       ".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
     489             :                   COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
     490             :       SectionKind::getBSS());
     491        2027 :   TextSection = Ctx->getCOFFSection(
     492             :       ".text",
     493             :       (IsThumb ? COFF::IMAGE_SCN_MEM_16BIT : (COFF::SectionCharacteristics)0) |
     494             :           COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE |
     495             :           COFF::IMAGE_SCN_MEM_READ,
     496             :       SectionKind::getText());
     497        2116 :   DataSection = Ctx->getCOFFSection(
     498             :       ".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
     499             :                    COFF::IMAGE_SCN_MEM_WRITE,
     500             :       SectionKind::getData());
     501        2116 :   ReadOnlySection = Ctx->getCOFFSection(
     502             :       ".rdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
     503             :       SectionKind::getReadOnly());
     504             : 
     505             :   // FIXME: We're emitting LSDA info into a readonly section on COFF, even
     506             :   // though it contains relocatable pointers.  In PIC mode, this is probably a
     507             :   // big runtime hit for C++ apps.  Either the contents of the LSDA need to be
     508             :   // adjusted or this should be a data section.
     509        1058 :   if (T.getArch() == Triple::x86_64) {
     510             :     // On Windows 64 with SEH, the LSDA is emitted into the .xdata section
     511         529 :     LSDASection = nullptr;
     512             :   } else {
     513        1058 :     LSDASection = Ctx->getCOFFSection(".gcc_except_table",
     514             :                                       COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     515             :                                           COFF::IMAGE_SCN_MEM_READ,
     516             :                                       SectionKind::getReadOnly());
     517             :   }
     518             : 
     519             :   // Debug info.
     520        1058 :   COFFDebugSymbolsSection =
     521        2116 :       Ctx->getCOFFSection(".debug$S", (COFF::IMAGE_SCN_MEM_DISCARDABLE |
     522             :                                        COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     523             :                                        COFF::IMAGE_SCN_MEM_READ),
     524             :                           SectionKind::getMetadata());
     525        1058 :   COFFDebugTypesSection =
     526        2116 :       Ctx->getCOFFSection(".debug$T", (COFF::IMAGE_SCN_MEM_DISCARDABLE |
     527             :                                        COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     528             :                                        COFF::IMAGE_SCN_MEM_READ),
     529             :                           SectionKind::getMetadata());
     530        2116 :   COFFGlobalTypeHashesSection = Ctx->getCOFFSection(
     531             :       ".debug$H",
     532             :       (COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     533             :        COFF::IMAGE_SCN_MEM_READ),
     534             :       SectionKind::getMetadata());
     535             : 
     536        2116 :   DwarfAbbrevSection = Ctx->getCOFFSection(
     537             :       ".debug_abbrev",
     538             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     539             :           COFF::IMAGE_SCN_MEM_READ,
     540             :       SectionKind::getMetadata(), "section_abbrev");
     541        2116 :   DwarfInfoSection = Ctx->getCOFFSection(
     542             :       ".debug_info",
     543             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     544             :           COFF::IMAGE_SCN_MEM_READ,
     545             :       SectionKind::getMetadata(), "section_info");
     546        2116 :   DwarfLineSection = Ctx->getCOFFSection(
     547             :       ".debug_line",
     548             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     549             :           COFF::IMAGE_SCN_MEM_READ,
     550             :       SectionKind::getMetadata(), "section_line");
     551        2116 :   DwarfLineStrSection = Ctx->getCOFFSection(
     552             :       ".debug_line_str",
     553             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     554             :           COFF::IMAGE_SCN_MEM_READ,
     555             :       SectionKind::getMetadata(), "section_line_str");
     556        2116 :   DwarfFrameSection = Ctx->getCOFFSection(
     557             :       ".debug_frame",
     558             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     559             :           COFF::IMAGE_SCN_MEM_READ,
     560             :       SectionKind::getMetadata());
     561        2116 :   DwarfPubNamesSection = Ctx->getCOFFSection(
     562             :       ".debug_pubnames",
     563             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     564             :           COFF::IMAGE_SCN_MEM_READ,
     565             :       SectionKind::getMetadata());
     566        2116 :   DwarfPubTypesSection = Ctx->getCOFFSection(
     567             :       ".debug_pubtypes",
     568             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     569             :           COFF::IMAGE_SCN_MEM_READ,
     570             :       SectionKind::getMetadata());
     571        2116 :   DwarfGnuPubNamesSection = Ctx->getCOFFSection(
     572             :       ".debug_gnu_pubnames",
     573             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     574             :           COFF::IMAGE_SCN_MEM_READ,
     575             :       SectionKind::getMetadata());
     576        2116 :   DwarfGnuPubTypesSection = Ctx->getCOFFSection(
     577             :       ".debug_gnu_pubtypes",
     578             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     579             :           COFF::IMAGE_SCN_MEM_READ,
     580             :       SectionKind::getMetadata());
     581        2116 :   DwarfStrSection = Ctx->getCOFFSection(
     582             :       ".debug_str",
     583             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     584             :           COFF::IMAGE_SCN_MEM_READ,
     585             :       SectionKind::getMetadata(), "info_string");
     586        2116 :   DwarfStrOffSection = Ctx->getCOFFSection(
     587             :       ".debug_str_offsets",
     588             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     589             :           COFF::IMAGE_SCN_MEM_READ,
     590             :       SectionKind::getMetadata(), "section_str_off");
     591        2116 :   DwarfLocSection = Ctx->getCOFFSection(
     592             :       ".debug_loc",
     593             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     594             :           COFF::IMAGE_SCN_MEM_READ,
     595             :       SectionKind::getMetadata(), "section_debug_loc");
     596        2116 :   DwarfARangesSection = Ctx->getCOFFSection(
     597             :       ".debug_aranges",
     598             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     599             :           COFF::IMAGE_SCN_MEM_READ,
     600             :       SectionKind::getMetadata());
     601        2116 :   DwarfRangesSection = Ctx->getCOFFSection(
     602             :       ".debug_ranges",
     603             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     604             :           COFF::IMAGE_SCN_MEM_READ,
     605             :       SectionKind::getMetadata(), "debug_range");
     606        2116 :   DwarfMacinfoSection = Ctx->getCOFFSection(
     607             :       ".debug_macinfo",
     608             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     609             :           COFF::IMAGE_SCN_MEM_READ,
     610             :       SectionKind::getMetadata(), "debug_macinfo");
     611        2116 :   DwarfInfoDWOSection = Ctx->getCOFFSection(
     612             :       ".debug_info.dwo",
     613             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     614             :           COFF::IMAGE_SCN_MEM_READ,
     615             :       SectionKind::getMetadata(), "section_info_dwo");
     616        2116 :   DwarfTypesDWOSection = Ctx->getCOFFSection(
     617             :       ".debug_types.dwo",
     618             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     619             :           COFF::IMAGE_SCN_MEM_READ,
     620             :       SectionKind::getMetadata(), "section_types_dwo");
     621        2116 :   DwarfAbbrevDWOSection = Ctx->getCOFFSection(
     622             :       ".debug_abbrev.dwo",
     623             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     624             :           COFF::IMAGE_SCN_MEM_READ,
     625             :       SectionKind::getMetadata(), "section_abbrev_dwo");
     626        2116 :   DwarfStrDWOSection = Ctx->getCOFFSection(
     627             :       ".debug_str.dwo",
     628             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     629             :           COFF::IMAGE_SCN_MEM_READ,
     630             :       SectionKind::getMetadata(), "skel_string");
     631        2116 :   DwarfLineDWOSection = Ctx->getCOFFSection(
     632             :       ".debug_line.dwo",
     633             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     634             :           COFF::IMAGE_SCN_MEM_READ,
     635             :       SectionKind::getMetadata());
     636        2116 :   DwarfLocDWOSection = Ctx->getCOFFSection(
     637             :       ".debug_loc.dwo",
     638             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     639             :           COFF::IMAGE_SCN_MEM_READ,
     640             :       SectionKind::getMetadata(), "skel_loc");
     641        2116 :   DwarfStrOffDWOSection = Ctx->getCOFFSection(
     642             :       ".debug_str_offsets.dwo",
     643             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     644             :           COFF::IMAGE_SCN_MEM_READ,
     645             :       SectionKind::getMetadata(), "section_str_off_dwo");
     646        2116 :   DwarfAddrSection = Ctx->getCOFFSection(
     647             :       ".debug_addr",
     648             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     649             :           COFF::IMAGE_SCN_MEM_READ,
     650             :       SectionKind::getMetadata(), "addr_sec");
     651        2116 :   DwarfCUIndexSection = Ctx->getCOFFSection(
     652             :       ".debug_cu_index",
     653             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     654             :           COFF::IMAGE_SCN_MEM_READ,
     655             :       SectionKind::getMetadata());
     656        2116 :   DwarfTUIndexSection = Ctx->getCOFFSection(
     657             :       ".debug_tu_index",
     658             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     659             :           COFF::IMAGE_SCN_MEM_READ,
     660             :       SectionKind::getMetadata());
     661        2116 :   DwarfDebugNamesSection = Ctx->getCOFFSection(
     662             :       ".debug_names",
     663             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     664             :           COFF::IMAGE_SCN_MEM_READ,
     665             :       SectionKind::getMetadata(), "debug_names_begin");
     666        2116 :   DwarfAccelNamesSection = Ctx->getCOFFSection(
     667             :       ".apple_names",
     668             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     669             :           COFF::IMAGE_SCN_MEM_READ,
     670             :       SectionKind::getMetadata(), "names_begin");
     671        2116 :   DwarfAccelNamespaceSection = Ctx->getCOFFSection(
     672             :       ".apple_namespaces",
     673             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     674             :           COFF::IMAGE_SCN_MEM_READ,
     675             :       SectionKind::getMetadata(), "namespac_begin");
     676        2116 :   DwarfAccelTypesSection = Ctx->getCOFFSection(
     677             :       ".apple_types",
     678             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     679             :           COFF::IMAGE_SCN_MEM_READ,
     680             :       SectionKind::getMetadata(), "types_begin");
     681        2116 :   DwarfAccelObjCSection = Ctx->getCOFFSection(
     682             :       ".apple_objc",
     683             :       COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     684             :           COFF::IMAGE_SCN_MEM_READ,
     685             :       SectionKind::getMetadata(), "objc_begin");
     686             : 
     687        2116 :   DrectveSection = Ctx->getCOFFSection(
     688             :       ".drectve", COFF::IMAGE_SCN_LNK_INFO | COFF::IMAGE_SCN_LNK_REMOVE,
     689             :       SectionKind::getMetadata());
     690             : 
     691        2116 :   PDataSection = Ctx->getCOFFSection(
     692             :       ".pdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
     693             :       SectionKind::getData());
     694             : 
     695        2116 :   XDataSection = Ctx->getCOFFSection(
     696             :       ".xdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
     697             :       SectionKind::getData());
     698             : 
     699        2116 :   SXDataSection = Ctx->getCOFFSection(".sxdata", COFF::IMAGE_SCN_LNK_INFO,
     700             :                                       SectionKind::getMetadata());
     701             : 
     702        2116 :   GFIDsSection = Ctx->getCOFFSection(".gfids$y",
     703             :                                      COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     704             :                                          COFF::IMAGE_SCN_MEM_READ,
     705             :                                      SectionKind::getMetadata());
     706             : 
     707        2116 :   TLSDataSection = Ctx->getCOFFSection(
     708             :       ".tls$", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
     709             :                    COFF::IMAGE_SCN_MEM_WRITE,
     710             :       SectionKind::getData());
     711             : 
     712        2116 :   StackMapSection = Ctx->getCOFFSection(".llvm_stackmaps",
     713             :                                         COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
     714             :                                             COFF::IMAGE_SCN_MEM_READ,
     715             :                                         SectionKind::getReadOnly());
     716        1058 : }
     717             : 
     718         308 : void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
     719         308 :   TextSection = Ctx->getWasmSection(".text", SectionKind::getText());
     720         308 :   DataSection = Ctx->getWasmSection(".data", SectionKind::getData());
     721             : 
     722         308 :   DwarfLineSection =
     723         308 :       Ctx->getWasmSection(".debug_line", SectionKind::getMetadata());
     724         308 :   DwarfLineStrSection =
     725         308 :       Ctx->getWasmSection(".debug_line_str", SectionKind::getMetadata());
     726         308 :   DwarfStrSection =
     727         308 :       Ctx->getWasmSection(".debug_str", SectionKind::getMetadata());
     728         308 :   DwarfLocSection =
     729         308 :       Ctx->getWasmSection(".debug_loc", SectionKind::getMetadata());
     730         308 :   DwarfAbbrevSection =
     731         308 :       Ctx->getWasmSection(".debug_abbrev", SectionKind::getMetadata());
     732         308 :   DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", SectionKind::getMetadata());
     733         308 :   DwarfRangesSection =
     734         308 :       Ctx->getWasmSection(".debug_ranges", SectionKind::getMetadata());
     735         308 :   DwarfMacinfoSection =
     736         308 :       Ctx->getWasmSection(".debug_macinfo", SectionKind::getMetadata());
     737         308 :   DwarfAddrSection = Ctx->getWasmSection(".debug_addr", SectionKind::getMetadata());
     738         308 :   DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata());
     739         308 :   DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata());
     740         308 :   DwarfInfoSection =
     741         308 :       Ctx->getWasmSection(".debug_info", SectionKind::getMetadata());
     742         308 :   DwarfFrameSection = Ctx->getWasmSection(".debug_frame", SectionKind::getMetadata());
     743         308 :   DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", SectionKind::getMetadata());
     744         308 :   DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", SectionKind::getMetadata());
     745             : 
     746             :   // TODO: Define more sections.
     747         308 : }
     748             : 
     749       37814 : void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,
     750             :                                             MCContext &ctx,
     751             :                                             bool LargeCodeModel) {
     752       37814 :   PositionIndependent = PIC;
     753       37814 :   Ctx = &ctx;
     754             : 
     755             :   // Common.
     756       37814 :   CommDirectiveSupportsAlignment = true;
     757       37814 :   SupportsWeakOmittedEHFrame = true;
     758       37814 :   SupportsCompactUnwindWithoutEHFrame = false;
     759       37814 :   OmitDwarfIfHaveCompactUnwind = false;
     760             : 
     761       37814 :   FDECFIEncoding = dwarf::DW_EH_PE_absptr;
     762             : 
     763       37814 :   CompactUnwindDwarfEHFrameOnly = 0;
     764             : 
     765       37814 :   EHFrameSection = nullptr;             // Created on demand.
     766       37814 :   CompactUnwindSection = nullptr;       // Used only by selected targets.
     767       37814 :   DwarfAccelNamesSection = nullptr;     // Used only by selected targets.
     768       37814 :   DwarfAccelObjCSection = nullptr;      // Used only by selected targets.
     769       37814 :   DwarfAccelNamespaceSection = nullptr; // Used only by selected targets.
     770       37814 :   DwarfAccelTypesSection = nullptr;     // Used only by selected targets.
     771             : 
     772       37814 :   TT = TheTriple;
     773             : 
     774       37814 :   switch (TT.getObjectFormat()) {
     775        3279 :   case Triple::MachO:
     776        3279 :     Env = IsMachO;
     777        3279 :     initMachOMCObjectFileInfo(TT);
     778        3279 :     break;
     779        1058 :   case Triple::COFF:
     780        1058 :     if (!TT.isOSWindows())
     781           0 :       report_fatal_error(
     782             :           "Cannot initialize MC for non-Windows COFF object files.");
     783             : 
     784        1058 :     Env = IsCOFF;
     785        1058 :     initCOFFMCObjectFileInfo(TT);
     786        1058 :     break;
     787       33169 :   case Triple::ELF:
     788       33169 :     Env = IsELF;
     789       33169 :     initELFMCObjectFileInfo(TT, LargeCodeModel);
     790       33169 :     break;
     791         308 :   case Triple::Wasm:
     792         308 :     Env = IsWasm;
     793         308 :     initWasmMCObjectFileInfo(TT);
     794         308 :     break;
     795           0 :   case Triple::UnknownObjectFormat:
     796           0 :     report_fatal_error("Cannot initialize MC for unknown object file format.");
     797             :     break;
     798             :   }
     799       37814 : }
     800             : 
     801          20 : MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
     802          20 :   switch (TT.getObjectFormat()) {
     803          20 :   case Triple::ELF:
     804          20 :     return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
     805          40 :                               0, utostr(Hash));
     806           0 :   case Triple::MachO:
     807             :   case Triple::COFF:
     808             :   case Triple::Wasm:
     809             :   case Triple::UnknownObjectFormat:
     810           0 :     report_fatal_error("Cannot get DWARF types section for this object file "
     811             :                        "format: not implemented.");
     812             :     break;
     813             :   }
     814           0 :   llvm_unreachable("Unknown ObjectFormatType");
     815             : }
     816             : 
     817             : MCSection *
     818          20 : MCObjectFileInfo::getStackSizesSection(const MCSection &TextSec) const {
     819          20 :   if (Env != IsELF)
     820           0 :     return StackSizesSection;
     821             : 
     822             :   const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec);
     823             :   unsigned Flags = ELF::SHF_LINK_ORDER;
     824          20 :   StringRef GroupName;
     825          20 :   if (const MCSymbol *Group = ElfSec.getGroup()) {
     826           2 :     GroupName = Group->getName();
     827             :     Flags |= ELF::SHF_GROUP;
     828             :   }
     829             : 
     830             :   const MCSymbol *Link = TextSec.getBeginSymbol();
     831          20 :   auto It = StackSizesUniquing.insert({Link, StackSizesUniquing.size()});
     832          20 :   unsigned UniqueID = It.first->second;
     833             : 
     834          40 :   return Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, Flags, 0,
     835             :                             GroupName, UniqueID, cast<MCSymbolELF>(Link));
     836             : }

Generated by: LCOV version 1.13