LLVM  10.0.0svn
MCObjectFileInfo.cpp
Go to the documentation of this file.
1 //===-- MCObjectFileInfo.cpp - Object File Information --------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "llvm/ADT/StringExtras.h"
11 #include "llvm/ADT/Triple.h"
12 #include "llvm/BinaryFormat/COFF.h"
13 #include "llvm/BinaryFormat/ELF.h"
14 #include "llvm/MC/MCAsmInfo.h"
15 #include "llvm/MC/MCContext.h"
16 #include "llvm/MC/MCSection.h"
17 #include "llvm/MC/MCSectionCOFF.h"
18 #include "llvm/MC/MCSectionELF.h"
19 #include "llvm/MC/MCSectionMachO.h"
20 #include "llvm/MC/MCSectionWasm.h"
21 #include "llvm/MC/MCSectionXCOFF.h"
22 
23 using namespace llvm;
24 
25 static bool useCompactUnwind(const Triple &T) {
26  // Only on darwin.
27  if (!T.isOSDarwin())
28  return false;
29 
30  // aarch64 always has it.
32  return true;
33 
34  // armv7k always has it.
35  if (T.isWatchABI())
36  return true;
37 
38  // Use it on newer version of OS X.
39  if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6))
40  return true;
41 
42  // And the iOS simulator.
43  if (T.isiOS() &&
44  (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86))
45  return true;
46 
47  return false;
48 }
49 
50 void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
51  // MachO
53 
55  "__TEXT", "__eh_frame",
59 
60  if (T.isOSDarwin() &&
63 
64  if (T.isWatchABI())
66 
68 
69  // .comm doesn't support alignment before Leopard.
70  if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5))
72 
73  TextSection // .text
74  = Ctx->getMachOSection("__TEXT", "__text",
77  DataSection // .data
78  = Ctx->getMachOSection("__DATA", "__data", 0, SectionKind::getData());
79 
80  // BSSSection might not be expected initialized on msvc.
81  BSSSection = nullptr;
82 
83  TLSDataSection // .tdata
84  = Ctx->getMachOSection("__DATA", "__thread_data",
87  TLSBSSSection // .tbss
88  = Ctx->getMachOSection("__DATA", "__thread_bss",
91 
92  // TODO: Verify datarel below.
93  TLSTLVSection // .tlv
94  = Ctx->getMachOSection("__DATA", "__thread_vars",
97 
99  "__DATA", "__thread_init", MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
101 
102  CStringSection // .cstring
103  = Ctx->getMachOSection("__TEXT", "__cstring",
107  = Ctx->getMachOSection("__TEXT","__ustring", 0,
109  FourByteConstantSection // .literal4
110  = Ctx->getMachOSection("__TEXT", "__literal4",
113  EightByteConstantSection // .literal8
114  = Ctx->getMachOSection("__TEXT", "__literal8",
117 
118  SixteenByteConstantSection // .literal16
119  = Ctx->getMachOSection("__TEXT", "__literal16",
122 
123  ReadOnlySection // .const
124  = Ctx->getMachOSection("__TEXT", "__const", 0,
126 
127  // If the target is not powerpc, map the coal sections to the non-coal
128  // sections.
129  //
130  // "__TEXT/__textcoal_nt" => section "__TEXT/__text"
131  // "__TEXT/__const_coal" => section "__TEXT/__const"
132  // "__DATA/__datacoal_nt" => section "__DATA/__data"
133  Triple::ArchType ArchTy = T.getArch();
134 
135  ConstDataSection // .const_data
136  = Ctx->getMachOSection("__DATA", "__const", 0,
138 
139  if (ArchTy == Triple::ppc || ArchTy == Triple::ppc64) {
141  = Ctx->getMachOSection("__TEXT", "__textcoal_nt",
146  = Ctx->getMachOSection("__TEXT", "__const_coal",
150  "__DATA", "__datacoal_nt", MachO::S_COALESCED, SectionKind::getData());
152  } else {
157  }
158 
160  = Ctx->getMachOSection("__DATA","__common",
164  = Ctx->getMachOSection("__DATA","__bss", MachO::S_ZEROFILL,
166 
167 
169  = Ctx->getMachOSection("__DATA", "__la_symbol_ptr",
173  = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr",
176 
178  = Ctx->getMachOSection("__DATA", "__thread_ptr",
181 
182  // Exception Handling.
183  LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0,
185 
186  COFFDebugSymbolsSection = nullptr;
187  COFFDebugTypesSection = nullptr;
188  COFFGlobalTypeHashesSection = nullptr;
189 
190  if (useCompactUnwind(T)) {
192  Ctx->getMachOSection("__LD", "__compact_unwind", MachO::S_ATTR_DEBUG,
194 
195  if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)
196  CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_X86_64_MODE_DWARF
197  else if (T.getArch() == Triple::aarch64 || T.getArch() == Triple::aarch64_32)
198  CompactUnwindDwarfEHFrameOnly = 0x03000000; // UNWIND_ARM64_MODE_DWARF
199  else if (T.getArch() == Triple::arm || T.getArch() == Triple::thumb)
200  CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_ARM_MODE_DWARF
201  }
202 
203  // Debug Information.
205  Ctx->getMachOSection("__DWARF", "__debug_names", MachO::S_ATTR_DEBUG,
206  SectionKind::getMetadata(), "debug_names_begin");
208  Ctx->getMachOSection("__DWARF", "__apple_names", MachO::S_ATTR_DEBUG,
209  SectionKind::getMetadata(), "names_begin");
211  Ctx->getMachOSection("__DWARF", "__apple_objc", MachO::S_ATTR_DEBUG,
212  SectionKind::getMetadata(), "objc_begin");
213  // 16 character section limit...
215  Ctx->getMachOSection("__DWARF", "__apple_namespac", MachO::S_ATTR_DEBUG,
216  SectionKind::getMetadata(), "namespac_begin");
218  Ctx->getMachOSection("__DWARF", "__apple_types", MachO::S_ATTR_DEBUG,
219  SectionKind::getMetadata(), "types_begin");
220 
222  Ctx->getMachOSection("__DWARF", "__swift_ast", MachO::S_ATTR_DEBUG,
224 
226  Ctx->getMachOSection("__DWARF", "__debug_abbrev", MachO::S_ATTR_DEBUG,
227  SectionKind::getMetadata(), "section_abbrev");
229  Ctx->getMachOSection("__DWARF", "__debug_info", MachO::S_ATTR_DEBUG,
230  SectionKind::getMetadata(), "section_info");
232  Ctx->getMachOSection("__DWARF", "__debug_line", MachO::S_ATTR_DEBUG,
233  SectionKind::getMetadata(), "section_line");
235  Ctx->getMachOSection("__DWARF", "__debug_line_str", MachO::S_ATTR_DEBUG,
236  SectionKind::getMetadata(), "section_line_str");
238  Ctx->getMachOSection("__DWARF", "__debug_frame", MachO::S_ATTR_DEBUG,
241  Ctx->getMachOSection("__DWARF", "__debug_pubnames", MachO::S_ATTR_DEBUG,
244  Ctx->getMachOSection("__DWARF", "__debug_pubtypes", MachO::S_ATTR_DEBUG,
247  Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn", MachO::S_ATTR_DEBUG,
250  Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt", MachO::S_ATTR_DEBUG,
253  Ctx->getMachOSection("__DWARF", "__debug_str", MachO::S_ATTR_DEBUG,
254  SectionKind::getMetadata(), "info_string");
256  Ctx->getMachOSection("__DWARF", "__debug_str_offs", MachO::S_ATTR_DEBUG,
257  SectionKind::getMetadata(), "section_str_off");
259  Ctx->getMachOSection("__DWARF", "__debug_addr", MachO::S_ATTR_DEBUG,
260  SectionKind::getMetadata(), "section_info");
262  Ctx->getMachOSection("__DWARF", "__debug_loc", MachO::S_ATTR_DEBUG,
263  SectionKind::getMetadata(), "section_debug_loc");
265  Ctx->getMachOSection("__DWARF", "__debug_loclists", MachO::S_ATTR_DEBUG,
266  SectionKind::getMetadata(), "section_debug_loc");
267 
269  Ctx->getMachOSection("__DWARF", "__debug_aranges", MachO::S_ATTR_DEBUG,
272  Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG,
273  SectionKind::getMetadata(), "debug_range");
275  Ctx->getMachOSection("__DWARF", "__debug_rnglists", MachO::S_ATTR_DEBUG,
276  SectionKind::getMetadata(), "debug_range");
278  Ctx->getMachOSection("__DWARF", "__debug_macinfo", MachO::S_ATTR_DEBUG,
279  SectionKind::getMetadata(), "debug_macinfo");
281  Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG,
284  Ctx->getMachOSection("__DWARF", "__debug_cu_index", MachO::S_ATTR_DEBUG,
287  Ctx->getMachOSection("__DWARF", "__debug_tu_index", MachO::S_ATTR_DEBUG,
289  StackMapSection = Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps",
291 
292  FaultMapSection = Ctx->getMachOSection("__LLVM_FAULTMAPS", "__llvm_faultmaps",
294 
296  "__LLVM", "__remarks", MachO::S_ATTR_DEBUG, SectionKind::getMetadata());
297 
299 }
300 
301 void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
302  switch (T.getArch()) {
303  case Triple::mips:
304  case Triple::mipsel:
305  case Triple::mips64:
306  case Triple::mips64el:
310  break;
311  case Triple::ppc64:
312  case Triple::ppc64le:
313  case Triple::x86_64:
316  break;
317  case Triple::bpfel:
318  case Triple::bpfeb:
320  break;
321  case Triple::hexagon:
323  PositionIndependent ? dwarf::DW_EH_PE_pcrel : dwarf::DW_EH_PE_absptr;
324  break;
325  default:
327  break;
328  }
329 
330  unsigned EHSectionType = T.getArch() == Triple::x86_64
333 
334  // Solaris requires different flags for .eh_frame to seemingly every other
335  // platform.
336  unsigned EHSectionFlags = ELF::SHF_ALLOC;
337  if (T.isOSSolaris() && T.getArch() != Triple::x86_64)
338  EHSectionFlags |= ELF::SHF_WRITE;
339 
340  // ELF
343 
346 
349 
352 
354  Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
356 
359 
360  DataRelROSection = Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
362 
364  Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
365  ELF::SHF_ALLOC | ELF::SHF_MERGE, 4, "");
366 
368  Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
369  ELF::SHF_ALLOC | ELF::SHF_MERGE, 8, "");
370 
372  Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
373  ELF::SHF_ALLOC | ELF::SHF_MERGE, 16, "");
374 
376  Ctx->getELFSection(".rodata.cst32", ELF::SHT_PROGBITS,
377  ELF::SHF_ALLOC | ELF::SHF_MERGE, 32, "");
378 
379  // Exception Handling Sections.
380 
381  // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
382  // it contains relocatable pointers. In PIC mode, this is probably a big
383  // runtime hit for C++ apps. Either the contents of the LSDA need to be
384  // adjusted or this should be a data section.
385  LSDASection = Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
387 
388  COFFDebugSymbolsSection = nullptr;
389  COFFDebugTypesSection = nullptr;
390 
391  unsigned DebugSecType = ELF::SHT_PROGBITS;
392 
393  // MIPS .debug_* sections should have SHT_MIPS_DWARF section type
394  // to distinguish among sections contain DWARF and ECOFF debug formats.
395  // Sections with ECOFF debug format are obsoleted and marked by SHT_PROGBITS.
396  if (T.isMIPS())
397  DebugSecType = ELF::SHT_MIPS_DWARF;
398 
399  // Debug Info Sections.
401  Ctx->getELFSection(".debug_abbrev", DebugSecType, 0);
402  DwarfInfoSection = Ctx->getELFSection(".debug_info", DebugSecType, 0);
403  DwarfLineSection = Ctx->getELFSection(".debug_line", DebugSecType, 0);
405  Ctx->getELFSection(".debug_line_str", DebugSecType,
407  DwarfFrameSection = Ctx->getELFSection(".debug_frame", DebugSecType, 0);
409  Ctx->getELFSection(".debug_pubnames", DebugSecType, 0);
411  Ctx->getELFSection(".debug_pubtypes", DebugSecType, 0);
413  Ctx->getELFSection(".debug_gnu_pubnames", DebugSecType, 0);
415  Ctx->getELFSection(".debug_gnu_pubtypes", DebugSecType, 0);
417  Ctx->getELFSection(".debug_str", DebugSecType,
419  DwarfLocSection = Ctx->getELFSection(".debug_loc", DebugSecType, 0);
421  Ctx->getELFSection(".debug_aranges", DebugSecType, 0);
423  Ctx->getELFSection(".debug_ranges", DebugSecType, 0);
425  Ctx->getELFSection(".debug_macinfo", DebugSecType, 0);
426 
427  // DWARF5 Experimental Debug Info
428 
429  // Accelerator Tables
431  Ctx->getELFSection(".debug_names", ELF::SHT_PROGBITS, 0);
433  Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0);
435  Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0);
437  Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0);
439  Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0);
440 
441  // String Offset and Address Sections
443  Ctx->getELFSection(".debug_str_offsets", DebugSecType, 0);
444  DwarfAddrSection = Ctx->getELFSection(".debug_addr", DebugSecType, 0);
445  DwarfRnglistsSection = Ctx->getELFSection(".debug_rnglists", DebugSecType, 0);
446  DwarfLoclistsSection = Ctx->getELFSection(".debug_loclists", DebugSecType, 0);
447 
448  // Fission Sections
450  Ctx->getELFSection(".debug_info.dwo", DebugSecType, ELF::SHF_EXCLUDE);
452  Ctx->getELFSection(".debug_types.dwo", DebugSecType, ELF::SHF_EXCLUDE);
454  Ctx->getELFSection(".debug_abbrev.dwo", DebugSecType, ELF::SHF_EXCLUDE);
456  ".debug_str.dwo", DebugSecType,
459  Ctx->getELFSection(".debug_line.dwo", DebugSecType, ELF::SHF_EXCLUDE);
461  Ctx->getELFSection(".debug_loc.dwo", DebugSecType, ELF::SHF_EXCLUDE);
462  DwarfStrOffDWOSection = Ctx->getELFSection(".debug_str_offsets.dwo",
463  DebugSecType, ELF::SHF_EXCLUDE);
465  Ctx->getELFSection(".debug_rnglists.dwo", DebugSecType, ELF::SHF_EXCLUDE);
466 
467  // DWP Sections
469  Ctx->getELFSection(".debug_cu_index", DebugSecType, 0);
471  Ctx->getELFSection(".debug_tu_index", DebugSecType, 0);
472 
474  Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
475 
477  Ctx->getELFSection(".llvm_faultmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
478 
480  Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
481 
482  StackSizesSection = Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, 0);
483 
486 }
487 
488 void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
493 
494  // Set the `IMAGE_SCN_MEM_16BIT` flag when compiling for thumb mode. This is
495  // used to indicate to the linker that the text segment contains thumb instructions
496  // and to set the ISA selection bit for calls accordingly.
497  const bool IsThumb = T.getArch() == Triple::thumb;
498 
500 
501  // COFF
502  BSSSection = Ctx->getCOFFSection(
507  ".text",
519 
520  if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::aarch64) {
521  // On Windows 64 with SEH, the LSDA is emitted into the .xdata section
522  LSDASection = nullptr;
523  } else {
524  LSDASection = Ctx->getCOFFSection(".gcc_except_table",
528  }
529 
530  // Debug info.
542  ".debug$H",
546 
548  ".debug_abbrev",
551  SectionKind::getMetadata(), "section_abbrev");
553  ".debug_info",
556  SectionKind::getMetadata(), "section_info");
558  ".debug_line",
561  SectionKind::getMetadata(), "section_line");
563  ".debug_line_str",
566  SectionKind::getMetadata(), "section_line_str");
568  ".debug_frame",
573  ".debug_pubnames",
578  ".debug_pubtypes",
583  ".debug_gnu_pubnames",
588  ".debug_gnu_pubtypes",
593  ".debug_str",
596  SectionKind::getMetadata(), "info_string");
598  ".debug_str_offsets",
601  SectionKind::getMetadata(), "section_str_off");
603  ".debug_loc",
606  SectionKind::getMetadata(), "section_debug_loc");
608  ".debug_aranges",
613  ".debug_ranges",
616  SectionKind::getMetadata(), "debug_range");
618  ".debug_macinfo",
621  SectionKind::getMetadata(), "debug_macinfo");
623  ".debug_info.dwo",
626  SectionKind::getMetadata(), "section_info_dwo");
628  ".debug_types.dwo",
631  SectionKind::getMetadata(), "section_types_dwo");
633  ".debug_abbrev.dwo",
636  SectionKind::getMetadata(), "section_abbrev_dwo");
638  ".debug_str.dwo",
641  SectionKind::getMetadata(), "skel_string");
643  ".debug_line.dwo",
648  ".debug_loc.dwo",
651  SectionKind::getMetadata(), "skel_loc");
653  ".debug_str_offsets.dwo",
656  SectionKind::getMetadata(), "section_str_off_dwo");
658  ".debug_addr",
661  SectionKind::getMetadata(), "addr_sec");
663  ".debug_cu_index",
668  ".debug_tu_index",
673  ".debug_names",
676  SectionKind::getMetadata(), "debug_names_begin");
678  ".apple_names",
681  SectionKind::getMetadata(), "names_begin");
683  ".apple_namespaces",
686  SectionKind::getMetadata(), "namespac_begin");
688  ".apple_types",
691  SectionKind::getMetadata(), "types_begin");
693  ".apple_objc",
696  SectionKind::getMetadata(), "objc_begin");
697 
701 
705 
709 
712 
713  GFIDsSection = Ctx->getCOFFSection(".gfids$y",
717 
722 
723  StackMapSection = Ctx->getCOFFSection(".llvm_stackmaps",
727 }
728 
729 void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
732 
734  Ctx->getWasmSection(".debug_line", SectionKind::getMetadata());
736  Ctx->getWasmSection(".debug_line_str", SectionKind::getMetadata());
738  Ctx->getWasmSection(".debug_str", SectionKind::getMetadata());
740  Ctx->getWasmSection(".debug_loc", SectionKind::getMetadata());
742  Ctx->getWasmSection(".debug_abbrev", SectionKind::getMetadata());
743  DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", SectionKind::getMetadata());
745  Ctx->getWasmSection(".debug_ranges", SectionKind::getMetadata());
747  Ctx->getWasmSection(".debug_macinfo", SectionKind::getMetadata());
749  DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata());
750  DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata());
752  Ctx->getWasmSection(".debug_info", SectionKind::getMetadata());
754  DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", SectionKind::getMetadata());
755  DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", SectionKind::getMetadata());
756 
757  // Wasm use data section for LSDA.
758  // TODO Consider putting each function's exception table in a separate
759  // section, as in -function-sections, to facilitate lld's --gc-section.
760  LSDASection = Ctx->getWasmSection(".rodata.gcc_except_table",
762 
763  // TODO: Define more sections.
764 }
765 
766 void MCObjectFileInfo::initXCOFFMCObjectFileInfo(const Triple &T) {
767  // The default csect for program code. Functions without a specified section
768  // get placed into this csect. The choice of csect name is not a property of
769  // the ABI or object file format. For example, the XL compiler uses an unnamed
770  // csect for program code.
774 
778 }
779 
780 void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,
781  MCContext &ctx,
782  bool LargeCodeModel) {
783  PositionIndependent = PIC;
784  Ctx = &ctx;
785 
786  // Common.
791 
793 
795 
796  EHFrameSection = nullptr; // Created on demand.
797  CompactUnwindSection = nullptr; // Used only by selected targets.
798  DwarfAccelNamesSection = nullptr; // Used only by selected targets.
799  DwarfAccelObjCSection = nullptr; // Used only by selected targets.
800  DwarfAccelNamespaceSection = nullptr; // Used only by selected targets.
801  DwarfAccelTypesSection = nullptr; // Used only by selected targets.
802 
803  TT = TheTriple;
804 
805  switch (TT.getObjectFormat()) {
806  case Triple::MachO:
807  Env = IsMachO;
808  initMachOMCObjectFileInfo(TT);
809  break;
810  case Triple::COFF:
811  if (!TT.isOSWindows())
813  "Cannot initialize MC for non-Windows COFF object files.");
814 
815  Env = IsCOFF;
816  initCOFFMCObjectFileInfo(TT);
817  break;
818  case Triple::ELF:
819  Env = IsELF;
820  initELFMCObjectFileInfo(TT, LargeCodeModel);
821  break;
822  case Triple::Wasm:
823  Env = IsWasm;
824  initWasmMCObjectFileInfo(TT);
825  break;
826  case Triple::XCOFF:
827  Env = IsXCOFF;
828  initXCOFFMCObjectFileInfo(TT);
829  break;
831  report_fatal_error("Cannot initialize MC for unknown object file format.");
832  break;
833  }
834 }
835 
836 MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name,
837  uint64_t Hash) const {
838  switch (TT.getObjectFormat()) {
839  case Triple::ELF:
840  return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0,
841  utostr(Hash));
842  case Triple::MachO:
843  case Triple::COFF:
844  case Triple::Wasm:
845  case Triple::XCOFF:
847  report_fatal_error("Cannot get DWARF comdat section for this object file "
848  "format: not implemented.");
849  break;
850  }
851  llvm_unreachable("Unknown ObjectFormatType");
852 }
853 
854 MCSection *
856  if (Env != IsELF)
857  return StackSizesSection;
858 
859  const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec);
860  unsigned Flags = ELF::SHF_LINK_ORDER;
861  StringRef GroupName;
862  if (const MCSymbol *Group = ElfSec.getGroup()) {
863  GroupName = Group->getName();
864  Flags |= ELF::SHF_GROUP;
865  }
866 
867  const MCSymbol *Link = TextSec.getBeginSymbol();
869  unsigned UniqueID = It.first->second;
870 
871  return Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, Flags, 0,
872  GroupName, UniqueID, cast<MCSymbolELF>(Link));
873 }
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:318
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Definition: Triple.h:481
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
MCSection * MergeableConst4Section
static SectionKind getData()
Definition: SectionKind.h:201
MCSection * DwarfStrOffSection
The DWARF v5 string offset and address table sections.
S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
Definition: MachO.h:131
S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine instructions.
Definition: MachO.h:181
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:139
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:453
MCSection * DwarfPubTypesSection
MCSection * DwarfGnuPubTypesSection
Section for newer gnu pubtypes.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
MCSection * StackMapSection
StackMap section.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
MCSection * SixteenByteConstantSection
MCSection * DwarfRnglistsSection
The DWARF v5 range list section.
MCSection * TextSection
Section directive for standard text.
MCSection * ConstTextCoalSection
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K)
Definition: MCContext.h:487
S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section in files with the MY_DYLDLINK f...
Definition: MachO.h:187
MCSection * LazySymbolPointerSection
static SectionKind getMergeableConst8()
Definition: SectionKind.h:192
static SectionKind getMergeableConst16()
Definition: SectionKind.h:193
static SectionKind getMergeable1ByteCString()
Definition: SectionKind.h:182
S_THREAD_LOCAL_VARIABLES - Section with thread local variable structure data.
Definition: MachO.h:164
Read Write Data.
Definition: XCOFF.h:42
static SectionKind getMergeableConst4()
Definition: SectionKind.h:191
static bool useCompactUnwind(const Triple &T)
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:434
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:195
MCSection * MergeableConst32Section
MCSection * DwarfDebugNamesSection
Accelerator table sections.
S_4BYTE_LITERALS - Section with 4 byte literals.
Definition: MachO.h:125
static SectionKind getBSS()
Definition: SectionKind.h:197
MCSection * COFFDebugTypesSection
MCSection * MergeableConst16Section
MCSection * DwarfPubNamesSection
S_8BYTE_LITERALS - Section with 8 byte literals.
Definition: MachO.h:127
MCSection * EightByteConstantSection
MCSection * getStackSizesSection(const MCSection &TextSec) const
bool isOSSolaris() const
Definition: Triple.h:511
MCSection * TLSDataSection
Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
Context object for machine code objects.
Definition: MCContext.h:65
MCSectionXCOFF * getXCOFFSection(StringRef Section, XCOFF::StorageMappingClass MappingClass, XCOFF::SymbolType CSectType, XCOFF::StorageClass StorageClass, SectionKind K, const char *BeginSymName=nullptr)
Definition: MCContext.cpp:538
const MCSection * DwarfDebugInlineSection
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
Definition: MCContext.cpp:285
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:296
MCSection * ConstDataCoalSection
MCSection * DrectveSection
COFF specific sections.
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:462
MCSection * DwarfAccelNamesSection
MCSection * DataSection
Section directive for standard data.
SectionCharacteristics
Definition: COFF.h:283
S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks.
Definition: MachO.h:191
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:538
MCSection * ThreadLocalPointerSection
MCSection * DwarfLineStrSection
Program Code.
Definition: XCOFF.h:30
const MCSymbolELF * getGroup() const
Definition: MCSectionELF.h:75
MCSection * DwarfSwiftASTSection
MCSection * TLSTLVSection
Section for thread local structure information.
S_THREAD_LOCAL_ZEROFILL - Thread local zerofill section.
Definition: MachO.h:161
bool isWatchABI() const
Definition: Triple.h:476
MCSection * RemarksSection
Remarks section.
MCSection * DwarfAccelNamespaceSection
S_THREAD_LOCAL_REGULAR - Thread local data section.
Definition: MachO.h:159
unsigned size() const
Definition: DenseMap.h:99
bool SupportsCompactUnwindWithoutEHFrame
True if the target object file supports emitting a compact unwind section without an associated EH fr...
S_CSTRING_LITERALS - Section with literal C strings.
Definition: MachO.h:123
bool CommDirectiveSupportsAlignment
True if .comm supports alignment.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
MCSection * COFFDebugSymbolsSection
MCSection * DwarfAbbrevSection
MCSection * EHFrameSection
EH frame section.
MCSection * DwarfLoclistsSection
The DWARF v5 locations list section.
S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers.
Definition: MachO.h:133
MCSection * DwarfTypesDWOSection
static SectionKind getThreadBSS()
Definition: SectionKind.h:195
MCSection * DwarfRangesSection
S_THREAD_LOCAL_VARIABLE_POINTERS - Section with pointers to thread local structures.
Definition: MachO.h:167
static SectionKind getMetadata()
Definition: SectionKind.h:178
static SectionKind getReadOnlyWithRel()
Definition: SectionKind.h:202
MCSymbol * getBeginSymbol()
Definition: MCSection.h:110
MCSection * DwarfARangesSection
MCSection * CompactUnwindSection
If exception handling is supported by the target and the target can support a compact representation ...
MCSection * DwarfAccelTypesSection
S_THREAD_LOCAL_INIT_FUNCTION_POINTERS - Section with thread local variable initialization pointers to...
Definition: MachO.h:170
DenseMap< const MCSymbol *, unsigned > StackSizesUniquing
std::string utostr(uint64_t X, bool isNeg=false)
Definition: StringExtras.h:223
MCSection * DwarfStrOffDWOSection
S_16BYTE_LITERALS - Section with only 16 byte literals.
Definition: MachO.h:152
MCSection * DwarfGnuPubNamesSection
Section for newer gnu pubnames.
bool isMIPS() const
Tests whether the target is MIPS (little and big endian, 32- or 64-bit).
Definition: Triple.h:719
MCSection * DwarfAbbrevDWOSection
MCSection * FaultMapSection
FaultMap section.
bool OmitDwarfIfHaveCompactUnwind
OmitDwarfIfHaveCompactUnwind - True if the target object file supports having some functions with com...
MCSection * FourByteConstantSection
Csect definition for initialized storage.
Definition: XCOFF.h:145
static SectionKind getMergeable2ByteCString()
Definition: SectionKind.h:185
void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx, bool LargeCodeModel=false)
unsigned FDECFIEncoding
FDE CFI encoding.
MCSection * LSDASection
If exception handling is supported by the target, this is the section the Language Specific Data Area...
MCSection * TLSExtraDataSection
Extra TLS Variable Data section.
ObjectFormatType getObjectFormat() const
getFormat - Get the object format for this triple.
Definition: Triple.h:326
unsigned CompactUnwindDwarfEHFrameOnly
Compact unwind encoding indicating that we should emit only an EH frame.
MCSection * StackSizesSection
Section containing metadata on function stack sizes.
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition: MCSectionELF.h:27
S_ATTR_DEBUG - A debug section.
Definition: MachO.h:196
S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be in a ranlib table of contents...
Definition: MachO.h:184
bool isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isMacOSXVersionLT - Comparison function for checking OS X version compatibility, which handles suppor...
Definition: Triple.h:438
MCSection * DwarfAccelObjCSection
unsigned getCodePointerSize() const
Get the code pointer size in bytes.
Definition: MCAsmInfo.h:407
S_COALESCED - Section contains symbols that are to be coalesced.
Definition: MachO.h:144
MCSection * COFFGlobalTypeHashesSection
MCSection * TLSBSSSection
Section directive for Thread Local uninitialized data.
MCSection * NonLazySymbolPointerSection
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:424
const MCSection * TLSThreadInitSection
Section for thread local data initialization functions.
MCSection * DwarfRnglistsDWOSection
The DWARF v5 range list section for fission.
bool SupportsWeakOmittedEHFrame
True if target object file supports a weak_definition of constant 0 for an omitted EH frame...
MCSection * BSSSection
Section that is default initialized to zero.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
S_ZEROFILL - Zero fill on demand section.
Definition: MachO.h:121
MCSection * DwarfMacinfoSection
static SectionKind getReadOnly()
Definition: SectionKind.h:181
static SectionKind getText()
Definition: SectionKind.h:179
MCSection * MergeableConst8Section