LLVM  10.0.0
MCObjectFileInfo.h
Go to the documentation of this file.
1 //===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===//
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 //
9 // This file describes common object file formats.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_MC_MCOBJECTFILEINFO_H
14 #define LLVM_MC_MCOBJECTFILEINFO_H
15 
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/Triple.h"
18 #include "llvm/MC/MCSymbol.h"
19 #include "llvm/Support/CodeGen.h"
21 
22 namespace llvm {
23 class MCContext;
24 class MCSection;
25 
27 protected:
28  /// True if .comm supports alignment. This is a hack for as long as we
29  /// support 10.4 Tiger, whose assembler doesn't support alignment on comm.
31 
32  /// True if target object file supports a weak_definition of constant 0 for an
33  /// omitted EH frame.
35 
36  /// True if the target object file supports emitting a compact unwind section
37  /// without an associated EH frame section.
39 
40  /// OmitDwarfIfHaveCompactUnwind - True if the target object file
41  /// supports having some functions with compact unwind and other with
42  /// dwarf unwind.
44 
45  /// FDE CFI encoding. Controls the encoding of the begin label in the
46  /// .eh_frame section. Unlike the LSDA encoding, personality encoding, and
47  /// type encodings, this is something that the assembler just "knows" about
48  /// its target
49  unsigned FDECFIEncoding = 0;
50 
51  /// Compact unwind encoding indicating that we should emit only an EH frame.
53 
54  /// Section directive for standard text.
55  MCSection *TextSection = nullptr;
56 
57  /// Section directive for standard data.
58  MCSection *DataSection = nullptr;
59 
60  /// Section that is default initialized to zero.
61  MCSection *BSSSection = nullptr;
62 
63  /// Section that is readonly and can contain arbitrary initialized data.
64  /// Targets are not required to have a readonly section. If they don't,
65  /// various bits of code will fall back to using the data section for
66  /// constants.
68 
69  /// If exception handling is supported by the target, this is the section the
70  /// Language Specific Data Area information is emitted to.
71  MCSection *LSDASection = nullptr;
72 
73  /// If exception handling is supported by the target and the target can
74  /// support a compact representation of the CIE and FDE, this is the section
75  /// to emit them into.
77 
78  // Dwarf sections for debug info. If a target supports debug info, these must
79  // be set.
92  // The pubnames section is no longer generated by default. The generation
93  // can be enabled by a compiler flag.
95 
96  /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
97  /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
98  /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
99  /// extensions.
105 
106  // These are used for the Fission separate debug information files.
115 
116  /// The DWARF v5 string offset and address table sections.
119  /// The DWARF v5 range list section.
121  /// The DWARF v5 locations list section.
123 
124  /// The DWARF v5 range and location list sections for fission.
127 
128  // These are for Fission DWP files.
131 
132  /// Section for newer gnu pubnames.
134  /// Section for newer gnu pubtypes.
136 
137  // Section for Swift AST
139 
143 
144  /// Extra TLS Variable Data section.
145  ///
146  /// If the target needs to put additional information for a TLS variable,
147  /// it'll go here.
149 
150  /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
151  MCSection *TLSDataSection = nullptr; // Defaults to ".tdata".
152 
153  /// Section directive for Thread Local uninitialized data.
154  ///
155  /// Null if this target doesn't support a BSS section. ELF and MachO only.
156  MCSection *TLSBSSSection = nullptr; // Defaults to ".tbss".
157 
158  /// StackMap section.
160 
161  /// FaultMap section.
163 
164  /// Remarks section.
166 
167  /// EH frame section.
168  ///
169  /// It is initialized on demand so it can be overwritten (with uniquing).
171 
172  /// Section containing metadata on function stack sizes.
175 
176  // ELF specific sections.
182 
183  // MachO specific sections.
184 
185  /// Section for thread local structure information.
186  ///
187  /// Contains the source code name of the variable, visibility and a pointer to
188  /// the initial value (.tdata or .tbss).
189  MCSection *TLSTLVSection = nullptr; // Defaults to ".tlv".
190 
191  /// Section for thread local data initialization functions.
192  // Defaults to ".thread_init_func".
193  const MCSection *TLSThreadInitSection = nullptr;
194 
210 
211  /// COFF specific sections.
218 
219 public:
220  void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
221  bool LargeCodeModel = false);
222 
225  }
228  }
231  }
232 
235  }
236 
237  unsigned getFDEEncoding() const { return FDECFIEncoding; }
238 
241  }
242 
243  MCSection *getTextSection() const { return TextSection; }
244  MCSection *getDataSection() const { return DataSection; }
245  MCSection *getBSSSection() const { return BSSSection; }
247  MCSection *getLSDASection() const { return LSDASection; }
251  MCSection *getDwarfInfoSection(uint64_t Hash) const {
252  return getDwarfComdatSection(".debug_info", Hash);
253  }
261  }
264  }
267  }
275 
277  return DwarfDebugNamesSection;
278  }
280  return DwarfAccelNamesSection;
281  }
285  }
287  return DwarfAccelTypesSection;
288  }
290  MCSection *getDwarfTypesSection(uint64_t Hash) const {
291  return getDwarfComdatSection(".debug_types", Hash);
292  }
303  }
306  }
308  return DwarfMacinfoDWOSection;
309  }
313 
316  }
318  return COFFDebugTypesSection;
319  }
322  }
323 
325  const MCSection *getTLSDataSection() const { return TLSDataSection; }
327 
331 
332  MCSection *getStackSizesSection(const MCSection &TextSec) const;
333 
334  // ELF specific sections.
337  return MergeableConst4Section;
338  }
340  return MergeableConst8Section;
341  }
344  }
347  }
348 
349  // MachO specific sections.
350  const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
352  return TLSThreadInitSection;
353  }
354  const MCSection *getCStringSection() const { return CStringSection; }
355  const MCSection *getUStringSection() const { return UStringSection; }
358  return ConstTextCoalSection;
359  }
360  const MCSection *getConstDataSection() const { return ConstDataSection; }
361  const MCSection *getDataCoalSection() const { return DataCoalSection; }
363  return ConstDataCoalSection;
364  }
369  }
372  }
375  }
378  }
381  }
384  }
385 
386  // COFF specific sections.
393 
395  return EHFrameSection;
396  }
397 
399  Environment getObjectFileType() const { return Env; }
400 
401  bool isPositionIndependent() const { return PositionIndependent; }
402 
403 private:
404  Environment Env;
405  bool PositionIndependent = false;
406  MCContext *Ctx = nullptr;
407  Triple TT;
408  VersionTuple SDKVersion;
409 
410  void initMachOMCObjectFileInfo(const Triple &T);
411  void initELFMCObjectFileInfo(const Triple &T, bool Large);
412  void initCOFFMCObjectFileInfo(const Triple &T);
413  void initWasmMCObjectFileInfo(const Triple &T);
414  void initXCOFFMCObjectFileInfo(const Triple &T);
415  MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
416 
417 public:
418  const Triple &getTargetTriple() const { return TT; }
419 
420  void setSDKVersion(const VersionTuple &TheSDKVersion) {
421  SDKVersion = TheSDKVersion;
422  }
423 
424  const VersionTuple &getSDKVersion() const { return SDKVersion; }
425 };
426 
427 } // end namespace llvm
428 
429 #endif
MCSection * DwarfLoclistsDWOSection
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
MCSection * MergeableConst4Section
MCSection * DwarfStrOffSection
The DWARF v5 string offset and address table sections.
const MCSection * getConstDataSection() const
MCSection * getDwarfStrOffSection() const
MCSection * getDwarfTUIndexSection() const
MCSection * getDwarfAccelObjCSection() const
MCSection * getDwarfCUIndexSection() const
MCSection * getDwarfStrSection() const
This class represents lattice values for constants.
Definition: AllocatorList.h:23
MCSection * getCOFFDebugTypesSection() const
const MCSection * getTLSTLVSection() const
MCSection * getDwarfLineSection() const
MCSection * getStackMapSection() const
MCSection * DwarfPubTypesSection
MCSection * getDwarfLocSection() const
MCSection * DwarfGnuPubTypesSection
Section for newer gnu pubtypes.
MCSection * getRemarksSection() const
MCSection * getTLSBSSSection() const
const MCSection * getFourByteConstantSection() const
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 * getEHFrameSection()
MCSection * ConstTextCoalSection
MCSection * getDwarfAccelNamesSection() const
const MCSection * getConstDataCoalSection() const
MCSection * LazySymbolPointerSection
MCSection * getDwarfMacinfoDWOSection() const
MCSection * getDwarfLineStrSection() const
MCSection * getDwarfARangesSection() const
bool getSupportsCompactUnwindWithoutEHFrame() const
MCSection * getCOFFGlobalTypeHashesSection() const
MCSection * getDwarfRnglistsDWOSection() const
MCSection * getDwarfRnglistsSection() const
MCSection * getDwarfPubNamesSection() const
MCSection * getReadOnlySection() const
MCSection * MergeableConst32Section
MCSection * DwarfDebugNamesSection
Accelerator table sections.
MCSection * getDwarfMacinfoSection() const
MCSection * getDwarfLocDWOSection() const
MCSection * COFFDebugTypesSection
const MCSection * getCStringSection() const
MCSection * MergeableConst16Section
MCSection * DwarfPubNamesSection
bool getCommDirectiveSupportsAlignment() const
MCSection * getBSSSection() const
MCSection * getDataSection() const
MCSection * EightByteConstantSection
unsigned getCompactUnwindDwarfEHFrameOnly() const
MCSection * getStackSizesSection(const MCSection &TextSec) const
MCSection * getDwarfFrameSection() const
MCSection * TLSDataSection
Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
MCSection * getDwarfTypesSection(uint64_t Hash) const
MCSection * getDataBSSSection() const
bool getOmitDwarfIfHaveCompactUnwind() const
Context object for machine code objects.
Definition: MCContext.h:65
MCSection * getSXDataSection() const
const MCSection * DwarfDebugInlineSection
const MCSection * getDwarfDebugInlineSection() const
bool getSupportsWeakOmittedEHFrame() const
MCSection * getCOFFDebugSymbolsSection() const
MCSection * ConstDataCoalSection
MCSection * DrectveSection
COFF specific sections.
MCSection * getCompactUnwindSection() const
MCSection * getPDataSection() const
MCSection * DwarfAccelNamesSection
MCSection * getGFIDsSection() const
const MCSection * getMergeableConst16Section() const
MCSection * getDwarfAccelTypesSection() const
MCSection * getDwarfAbbrevSection() const
MCSection * DataSection
Section directive for standard data.
MCSection * getDwarfAbbrevDWOSection() const
MCSection * getTLSExtraDataSection() const
MCSection * getDwarfGnuPubTypesSection() const
MCSection * getDwarfTypesDWOSection() const
MCSection * ThreadLocalPointerSection
MCSection * DwarfLineStrSection
MCSection * getDwarfAddrSection() const
MCSection * DwarfSwiftASTSection
MCSection * TLSTLVSection
Section for thread local structure information.
MCSection * RemarksSection
Remarks section.
MCSection * getNonLazySymbolPointerSection() const
unsigned getFDEEncoding() const
MCSection * DwarfAccelNamespaceSection
MCSection * getDwarfLineDWOSection() const
MCSection * DwarfMacinfoDWOSection
const MCSection * getMergeableConst8Section() const
Environment getObjectFileType() const
bool SupportsCompactUnwindWithoutEHFrame
True if the target object file supports emitting a compact unwind section without an associated EH fr...
MCSection * getDwarfSwiftASTSection() const
bool CommDirectiveSupportsAlignment
True if .comm supports alignment.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
MCSection * getDrectveSection() const
MCSection * COFFDebugSymbolsSection
MCSection * DwarfAbbrevSection
MCSection * getThreadLocalPointerSection() const
MCSection * EHFrameSection
EH frame section.
const MCSection * getEightByteConstantSection() const
MCSection * getDataRelROSection() const
MCSection * DwarfLoclistsSection
The DWARF v5 locations list section.
MCSection * DwarfTypesDWOSection
MCSection * getGLJMPSection() const
MCSection * DwarfRangesSection
const MCSection * getConstTextCoalSection() const
const Triple & getTargetTriple() const
MCSection * DwarfARangesSection
const MCSection * getDataCommonSection() const
MCSection * CompactUnwindSection
If exception handling is supported by the target and the target can support a compact representation ...
MCSection * getDwarfInfoSection() const
MCSection * DwarfAccelTypesSection
MCSection * getDwarfDebugNamesSection() const
void setSDKVersion(const VersionTuple &TheSDKVersion)
MCSection * getDwarfStrOffDWOSection() const
DenseMap< const MCSymbol *, unsigned > StackSizesUniquing
MCSection * DwarfStrOffDWOSection
MCSection * getDwarfInfoSection(uint64_t Hash) const
MCSection * DwarfGnuPubNamesSection
Section for newer gnu pubnames.
MCSection * DwarfAbbrevDWOSection
const MCSection * getMergeableConst4Section() const
MCSection * getDwarfPubTypesSection() const
MCSection * FaultMapSection
FaultMap section.
bool OmitDwarfIfHaveCompactUnwind
OmitDwarfIfHaveCompactUnwind - True if the target object file supports having some functions with com...
MCSection * FourByteConstantSection
void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx, bool LargeCodeModel=false)
unsigned FDECFIEncoding
FDE CFI encoding.
MCSection * getDwarfStrDWOSection() const
const MCSection * getMergeableConst32Section() const
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:26
MCSection * getXDataSection() const
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.
MCSection * getLazySymbolPointerSection() const
unsigned CompactUnwindDwarfEHFrameOnly
Compact unwind encoding indicating that we should emit only an EH frame.
const VersionTuple & getSDKVersion() const
MCSection * StackSizesSection
Section containing metadata on function stack sizes.
MCSection * getDwarfGnuPubNamesSection() const
MCSection * DwarfAccelObjCSection
MCSection * getFaultMapSection() const
MCSection * getDwarfLoclistsDWOSection() const
const MCSection * getTLSThreadInitSection() const
MCSection * getTextSection() const
MCSection * COFFGlobalTypeHashesSection
MCSection * TLSBSSSection
Section directive for Thread Local uninitialized data.
MCSection * NonLazySymbolPointerSection
MCSection * getDwarfAccelNamespaceSection() const
const MCSection * TLSThreadInitSection
Section for thread local data initialization functions.
MCSection * DwarfRnglistsDWOSection
The DWARF v5 range and location list sections for fission.
Defines the llvm::VersionTuple class, which represents a version in the form major[.minor[.subminor]].
bool SupportsWeakOmittedEHFrame
True if target object file supports a weak_definition of constant 0 for an omitted EH frame...
MCSection * getLSDASection() const
MCSection * getDwarfInfoDWOSection() const
MCSection * BSSSection
Section that is default initialized to zero.
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
bool isPositionIndependent() const
MCSection * DwarfMacinfoSection
MCSection * getDwarfRangesSection() const
const MCSection * getTLSDataSection() const
const MCSection * getSixteenByteConstantSection() const
const MCSection * getUStringSection() const
MCSection * getTextCoalSection() const
const MCSection * getDataCoalSection() const
MCSection * getDwarfLoclistsSection() const
MCSection * MergeableConst8Section