LLVM  3.7.0
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/Triple.h"
18 #include "llvm/Support/CodeGen.h"
19 
20 namespace llvm {
21 class MCContext;
22 class MCSection;
23 
25 protected:
26  /// True if .comm supports alignment. This is a hack for as long as we
27  /// support 10.4 Tiger, whose assembler doesn't support alignment on comm.
29 
30  /// True if target object file supports a weak_definition of constant 0 for an
31  /// omitted EH frame.
33 
34  /// True if the target object file supports emitting a compact unwind section
35  /// without an associated EH frame section.
37 
38  /// Some encoding values for EH.
40  unsigned LSDAEncoding;
41  unsigned FDECFIEncoding;
42  unsigned TTypeEncoding;
43 
44  /// Section flags for eh_frame
45  unsigned EHSectionType;
46  unsigned EHSectionFlags;
47 
48  /// Compact unwind encoding indicating that we should emit only an EH frame.
50 
51  /// Section directive for standard text.
53 
54  /// Section directive for standard data.
56 
57  /// Section that is default initialized to zero.
59 
60  /// Section that is readonly and can contain arbitrary initialized data.
61  /// Targets are not required to have a readonly section. If they don't,
62  /// various bits of code will fall back to using the data section for
63  /// constants.
65 
66  /// This section contains the static constructor pointer list.
68 
69  /// This section contains the static destructor pointer list.
71 
72  /// If exception handling is supported by the target, this is the section the
73  /// Language Specific Data Area information is emitted to.
75 
76  /// If exception handling is supported by the target and the target can
77  /// support a compact representation of the CIE and FDE, this is the section
78  /// to emit them into.
80 
81  // Dwarf sections for debug info. If a target supports debug info, these must
82  // be set.
93  // The pubnames section is no longer generated by default. The generation
94  // can be enabled by a compiler flag.
96 
97  /// DWARF5 Experimental Debug Info Sections
98  /// DwarfAccelNamesSection, DwarfAccelObjCSection,
99  /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
100  /// If we use the DWARF accelerated hash tables then we want to emit these
101  /// sections.
106 
107  // These are used for the Fission separate debug information files.
116 
117  /// Section for newer gnu pubnames.
119  /// Section for newer gnu pubtypes.
121 
123 
124  /// Extra TLS Variable Data section.
125  ///
126  /// If the target needs to put additional information for a TLS variable,
127  /// it'll go here.
129 
130  /// Section directive for Thread Local data. ELF, MachO and COFF.
131  MCSection *TLSDataSection; // Defaults to ".tdata".
132 
133  /// Section directive for Thread Local uninitialized data.
134  ///
135  /// Null if this target doesn't support a BSS section. ELF and MachO only.
136  MCSection *TLSBSSSection; // Defaults to ".tbss".
137 
138  /// StackMap section.
140 
141  /// FaultMap section.
143 
144  /// EH frame section.
145  ///
146  /// It is initialized on demand so it can be overwritten (with uniquing).
148 
149  // ELF specific sections.
157 
158  // MachO specific sections.
159 
160  /// Section for thread local structure information.
161  ///
162  /// Contains the source code name of the variable, visibility and a pointer to
163  /// the initial value (.tdata or .tbss).
164  MCSection *TLSTLVSection; // Defaults to ".tlv".
165 
166  /// Section for thread local data initialization functions.
167  const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
168 
182 
183  /// COFF specific sections.
188 
189 public:
190  void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM,
191  CodeModel::Model CM, MCContext &ctx);
194  CodeModel::Model CM, MCContext &ctx),
195  "StringRef GNU Triple argument replaced by a llvm::Triple object");
196 
199  }
202  }
205  }
206 
207  unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
208  unsigned getLSDAEncoding() const { return LSDAEncoding; }
209  unsigned getFDEEncoding() const { return FDECFIEncoding; }
210  unsigned getTTypeEncoding() const { return TTypeEncoding; }
211 
214  }
215 
216  MCSection *getTextSection() const { return TextSection; }
217  MCSection *getDataSection() const { return DataSection; }
218  MCSection *getBSSSection() const { return BSSSection; }
219  MCSection *getLSDASection() const { return LSDASection; }
229  }
232  }
235  }
240 
241  // DWARF5 Experimental Debug Info Sections
243  return DwarfAccelNamesSection;
244  }
248  }
250  return DwarfAccelTypesSection;
251  }
253  MCSection *getDwarfTypesSection(uint64_t Hash) const;
261 
264  }
265 
267  const MCSection *getTLSDataSection() const { return TLSDataSection; }
269 
272 
273  // ELF specific sections.
276  return DataRelLocalSection;
277  }
281  return MergeableConst4Section;
282  }
284  return MergeableConst8Section;
285  }
288  }
289 
290  // MachO specific sections.
291  const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
293  return TLSThreadInitSection;
294  }
295  const MCSection *getCStringSection() const { return CStringSection; }
296  const MCSection *getUStringSection() const { return UStringSection; }
299  return ConstTextCoalSection;
300  }
301  const MCSection *getConstDataSection() const { return ConstDataSection; }
302  const MCSection *getDataCoalSection() const { return DataCoalSection; }
307  }
310  }
313  }
316  }
319  }
320 
321  // COFF specific sections.
326 
328  if (!EHFrameSection)
329  InitEHFrameSection();
330  return EHFrameSection;
331  }
332 
334  Environment getObjectFileType() const { return Env; }
335 
336  Reloc::Model getRelocM() const { return RelocM; }
337 
338 private:
339  Environment Env;
340  Reloc::Model RelocM;
341  CodeModel::Model CMModel;
342  MCContext *Ctx;
343  Triple TT;
344 
345  void initMachOMCObjectFileInfo(Triple T);
346  void initELFMCObjectFileInfo(Triple T);
347  void initCOFFMCObjectFileInfo(Triple T);
348 
349  /// Initialize EHFrameSection on demand.
350  void InitEHFrameSection();
351 
352 public:
353  const Triple &getTargetTriple() const { return TT; }
354 };
355 
356 } // end namespace llvm
357 
358 #endif
MCSection * getNonLazySymbolPointerSection() const
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:48
MCSection * MergeableConst4Section
MCSection * getStackMapSection() const
unsigned getFDEEncoding() const
MCSection * getDwarfAddrSection() const
MCSection * DwarfPubTypesSection
MCSection * getDwarfAccelObjCSection() const
MCSection * DwarfGnuPubTypesSection
Section for newer gnu pubtypes.
MCSection * StackMapSection
StackMap section.
MCSection * getLazySymbolPointerSection() const
MCSection * SixteenByteConstantSection
MCSection * getDwarfStrOffDWOSection() const
const MCSection * getConstDataSection() const
MCSection * getDwarfPubTypesSection() const
unsigned PersonalityEncoding
Some encoding values for EH.
MCSection * TextSection
Section directive for standard text.
MCSection * getEHFrameSection()
MCSection * ConstTextCoalSection
const MCSection * getFourByteConstantSection() const
MCSection * LazySymbolPointerSection
MCSection * getDataSection() const
MCSection * getDataRelROSection() const
const MCSection * getTLSThreadInitSection() const
const MCSection * getSixteenByteConstantSection() const
MCSection * getDwarfTypesSection(uint64_t Hash) const
MCSection * getFaultMapSection() const
bool getSupportsCompactUnwindWithoutEHFrame() const
const MCSection * getMergeableConst16Section() const
MCSection * MergeableConst16Section
MCSection * DwarfPubNamesSection
const MCSection * getEightByteConstantSection() const
MCSection * StaticDtorSection
This section contains the static destructor pointer list.
MCSection * getDwarfLineDWOSection() const
MCSection * getDataBSSSection() const
MCSection * EightByteConstantSection
MCSection * TLSDataSection
Section directive for Thread Local data. ELF, MachO and COFF.
unsigned getTTypeEncoding() const
Context object for machine code objects.
Definition: MCContext.h:48
MCSection * getBSSSection() const
const MCSection * DwarfDebugInlineSection
Environment getObjectFileType() const
MCSection * getDataRelROLocalSection() const
const MCSection * getMergeableConst8Section() const
MCSection * DrectveSection
COFF specific sections.
MCSection * getPDataSection() const
const MCSection * getDataRelLocalSection() const
MCSection * DwarfAccelNamesSection
DWARF5 Experimental Debug Info Sections DwarfAccelNamesSection, DwarfAccelObjCSection, DwarfAccelNamespaceSection, DwarfAccelTypesSection - If we use the DWARF accelerated hash tables then we want to emit these sections.
const MCSection * getTLSDataSection() const
const Triple & getTargetTriple() const
const MCSection * getUStringSection() const
MCSection * DataSection
Section directive for standard data.
bool getCommDirectiveSupportsAlignment() const
const MCSection * getConstTextCoalSection() const
MCSection * getDwarfLineSection() const
MCSection * getLSDASection() const
MCSection * getCompactUnwindSection() const
const MCSection * getDataCommonSection() const
LLVM_ATTRIBUTE_DEPRECATED(void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, MCContext &ctx),"StringRef GNU Triple argument replaced by a llvm::Triple object")
MCSection * TLSTLVSection
Section for thread local structure information.
MCSection * getDwarfLocDWOSection() const
MCSection * getXDataSection() const
const MCSection * DataRelLocalSection
MCSection * getDwarfAccelTypesSection() const
MCSection * DwarfAccelNamespaceSection
MCSection * getDwarfAccelNamespaceSection() const
MCSection * getDrectveSection() const
MCSection * getTextSection() const
MCSection * getDwarfInfoDWOSection() const
MCSection * getTextCoalSection() const
bool SupportsCompactUnwindWithoutEHFrame
True if the target object file supports emitting a compact unwind section without an associated EH fr...
bool CommDirectiveSupportsAlignment
True if .comm supports alignment.
MCSection * DataRelROLocalSection
MCSection * StaticCtorSection
This section contains the static constructor pointer list.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
MCSection * COFFDebugSymbolsSection
MCSection * DwarfAbbrevSection
MCSection * getSXDataSection() const
MCSection * EHFrameSection
EH frame section.
MCSection * getDwarfStrSection() const
MCSection * DwarfTypesDWOSection
unsigned getLSDAEncoding() const
MCSection * getDwarfStrDWOSection() const
MCSection * DwarfRangesSection
MCSection * getDwarfAbbrevDWOSection() const
MCSection * getTLSExtraDataSection() const
MCSection * DwarfARangesSection
MCSection * CompactUnwindSection
If exception handling is supported by the target and the target can support a compact representation ...
MCSection * DwarfAccelTypesSection
unsigned getPersonalityEncoding() const
MCSection * DwarfStrOffDWOSection
void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM, CodeModel::Model CM, MCContext &ctx)
MCSection * DwarfGnuPubNamesSection
Section for newer gnu pubnames.
MCSection * DwarfAbbrevDWOSection
MCSection * getDwarfAccelNamesSection() const
MCSection * FaultMapSection
FaultMap section.
MCSection * FourByteConstantSection
const MCSection * getDataCoalSection() const
MCSection * getDwarfARangesSection() const
MCSection * LSDASection
If exception handling is supported by the target, this is the section the Language Specific Data Area...
MCSection * getDwarfGnuPubTypesSection() const
MCSection * TLSExtraDataSection
Extra TLS Variable Data section.
const MCSection * getCStringSection() const
unsigned CompactUnwindDwarfEHFrameOnly
Compact unwind encoding indicating that we should emit only an EH frame.
MCSection * getDwarfFrameSection() const
MCSection * DwarfAccelObjCSection
MCSection * getDwarfTypesDWOSection() const
MCSection * getCOFFDebugSymbolsSection() const
MCSection * TLSBSSSection
Section directive for Thread Local uninitialized data.
MCSection * NonLazySymbolPointerSection
Reloc::Model getRelocM() const
const MCSection * TLSThreadInitSection
Section for thread local data initialization functions.
MCSection * getDwarfGnuPubNamesSection() const
unsigned EHSectionType
Section flags for eh_frame.
MCSection * getDwarfInfoSection() const
MCSection * getDwarfRangesSection() const
MCSection * getDwarfPubNamesSection() const
bool SupportsWeakOmittedEHFrame
True if target object file supports a weak_definition of constant 0 for an omitted EH frame...
MCSection * getDataRelSection() const
unsigned getCompactUnwindDwarfEHFrameOnly() const
std::string Hash(const Unit &U)
Definition: FuzzerUtil.cpp:39
MCSection * BSSSection
Section that is default initialized to zero.
bool getSupportsWeakOmittedEHFrame() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40
const MCSection * getMergeableConst4Section() const
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
MCSection * getDwarfAbbrevSection() const
MCSection * getTLSBSSSection() const
const MCSection * getDwarfDebugInlineSection() const
MCSection * getDwarfLocSection() const
const MCSection * getTLSTLVSection() const
MCSection * MergeableConst8Section