LLVM  8.0.1
MCObjectFileInfo.h
Go to the documentation of this file.
1 //===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===//
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 // This file describes common object file formats.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_MC_MCOBJECTFILEINFO_H
15 #define LLVM_MC_MCOBJECTFILEINFO_H
16 
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/MC/MCSymbol.h"
20 #include "llvm/Support/CodeGen.h"
22 
23 namespace llvm {
24 class MCContext;
25 class MCSection;
26 
28 protected:
29  /// True if .comm supports alignment. This is a hack for as long as we
30  /// support 10.4 Tiger, whose assembler doesn't support alignment on comm.
32 
33  /// True if target object file supports a weak_definition of constant 0 for an
34  /// omitted EH frame.
36 
37  /// True if the target object file supports emitting a compact unwind section
38  /// without an associated EH frame section.
40 
41  /// OmitDwarfIfHaveCompactUnwind - True if the target object file
42  /// supports having some functions with compact unwind and other with
43  /// dwarf unwind.
45 
46  /// FDE CFI encoding. Controls the encoding of the begin label in the
47  /// .eh_frame section. Unlike the LSDA encoding, personality encoding, and
48  /// type encodings, this is something that the assembler just "knows" about
49  /// its target
50  unsigned FDECFIEncoding = 0;
51 
52  /// Compact unwind encoding indicating that we should emit only an EH frame.
54 
55  /// Section directive for standard text.
57 
58  /// Section directive for standard data.
60 
61  /// Section that is default initialized to zero.
63 
64  /// Section that is readonly and can contain arbitrary initialized data.
65  /// Targets are not required to have a readonly section. If they don't,
66  /// various bits of code will fall back to using the data section for
67  /// constants.
69 
70  /// If exception handling is supported by the target, this is the section the
71  /// Language Specific Data Area information is emitted to.
73 
74  /// If exception handling is supported by the target and the target can
75  /// support a compact representation of the CIE and FDE, this is the section
76  /// to emit them into.
78 
79  // Dwarf sections for debug info. If a target supports debug info, these must
80  // be set.
93  // The pubnames section is no longer generated by default. The generation
94  // can be enabled by a compiler flag.
96 
97  /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
98  /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
99  /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
100  /// extensions.
106 
107  // 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 list section for fission.
126 
127  // These are for Fission DWP files.
130 
131  /// Section for newer gnu pubnames.
133  /// Section for newer gnu pubtypes.
135 
136  // Section for Swift AST
138 
142 
143  /// Extra TLS Variable Data section.
144  ///
145  /// If the target needs to put additional information for a TLS variable,
146  /// it'll go here.
148 
149  /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
150  MCSection *TLSDataSection; // Defaults to ".tdata".
151 
152  /// Section directive for Thread Local uninitialized data.
153  ///
154  /// Null if this target doesn't support a BSS section. ELF and MachO only.
155  MCSection *TLSBSSSection; // Defaults to ".tbss".
156 
157  /// StackMap section.
159 
160  /// FaultMap section.
162 
163  /// EH frame section.
164  ///
165  /// It is initialized on demand so it can be overwritten (with uniquing).
167 
168  /// Section containing metadata on function stack sizes.
171 
172  // ELF specific sections.
178 
179  // MachO specific sections.
180 
181  /// Section for thread local structure information.
182  ///
183  /// Contains the source code name of the variable, visibility and a pointer to
184  /// the initial value (.tdata or .tbss).
185  MCSection *TLSTLVSection; // Defaults to ".tlv".
186 
187  /// Section for thread local data initialization functions.
188  const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
189 
205 
206  /// COFF specific sections.
212 
213 public:
214  void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
215  bool LargeCodeModel = false);
216 
219  }
222  }
225  }
226 
229  }
230 
231  unsigned getFDEEncoding() const { return FDECFIEncoding; }
232 
235  }
236 
237  MCSection *getTextSection() const { return TextSection; }
238  MCSection *getDataSection() const { return DataSection; }
239  MCSection *getBSSSection() const { return BSSSection; }
241  MCSection *getLSDASection() const { return LSDASection; }
245  MCSection *getDwarfInfoSection(uint64_t Hash) const {
246  return getDwarfComdatSection(".debug_info", Hash);
247  }
255  }
258  }
261  }
269 
271  return DwarfDebugNamesSection;
272  }
274  return DwarfAccelNamesSection;
275  }
279  }
281  return DwarfAccelTypesSection;
282  }
284  MCSection *getDwarfTypesSection(uint64_t Hash) const {
285  return getDwarfComdatSection(".debug_types", Hash);
286  }
297  }
301 
304  }
306  return COFFDebugTypesSection;
307  }
310  }
311 
313  const MCSection *getTLSDataSection() const { return TLSDataSection; }
315 
318 
319  MCSection *getStackSizesSection(const MCSection &TextSec) const;
320 
321  // ELF specific sections.
324  return MergeableConst4Section;
325  }
327  return MergeableConst8Section;
328  }
331  }
334  }
335 
336  // MachO specific sections.
337  const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
339  return TLSThreadInitSection;
340  }
341  const MCSection *getCStringSection() const { return CStringSection; }
342  const MCSection *getUStringSection() const { return UStringSection; }
345  return ConstTextCoalSection;
346  }
347  const MCSection *getConstDataSection() const { return ConstDataSection; }
348  const MCSection *getDataCoalSection() const { return DataCoalSection; }
350  return ConstDataCoalSection;
351  }
356  }
359  }
362  }
365  }
368  }
371  }
372 
373  // COFF specific sections.
379 
381  return EHFrameSection;
382  }
383 
385  Environment getObjectFileType() const { return Env; }
386 
387  bool isPositionIndependent() const { return PositionIndependent; }
388 
389 private:
390  Environment Env;
391  bool PositionIndependent;
392  MCContext *Ctx;
393  Triple TT;
394  VersionTuple SDKVersion;
395 
396  void initMachOMCObjectFileInfo(const Triple &T);
397  void initELFMCObjectFileInfo(const Triple &T, bool Large);
398  void initCOFFMCObjectFileInfo(const Triple &T);
399  void initWasmMCObjectFileInfo(const Triple &T);
400  MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
401 
402 public:
403  const Triple &getTargetTriple() const { return TT; }
404 
405  void setSDKVersion(const VersionTuple &TheSDKVersion) {
406  SDKVersion = TheSDKVersion;
407  }
408 
409  const VersionTuple &getSDKVersion() const { return SDKVersion; }
410 };
411 
412 } // end namespace llvm
413 
414 #endif
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:24
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 * getTLSBSSSection() const
const MCSection * getFourByteConstantSection() const
MCSection * StackMapSection
StackMap section.
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 * 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.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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:63
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 * getNonLazySymbolPointerSection() const
unsigned getFDEEncoding() const
MCSection * DwarfAccelNamespaceSection
MCSection * getDwarfLineDWOSection() const
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:44
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 * 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:27
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
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 list section 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