1 //===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes common object file formats.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCBJECTFILEINFO_H
15 #define LLVM_MC_MCBJECTFILEINFO_H
17 #include "llvm/ADT/Triple.h"
18 #include "llvm/Support/CodeGen.h"
25 class MCObjectFileInfo {
27 /// CommDirectiveSupportsAlignment - True if .comm supports alignment. This
28 /// is a hack for as long as we support 10.4 Tiger, whose assembler doesn't
29 /// support alignment on comm.
30 bool CommDirectiveSupportsAlignment;
32 /// SupportsWeakEmptyEHFrame - True if target object file supports a
33 /// weak_definition of constant 0 for an omitted EH frame.
34 bool SupportsWeakOmittedEHFrame;
36 /// SupportsCompactUnwindWithoutEHFrame - True if the target object file
37 /// supports emitting a compact unwind section without an associated EH frame
39 bool SupportsCompactUnwindWithoutEHFrame;
41 /// PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values
43 unsigned PersonalityEncoding;
44 unsigned LSDAEncoding;
45 unsigned FDECFIEncoding;
46 unsigned TTypeEncoding;
48 /// Section flags for eh_frame
49 unsigned EHSectionType;
50 unsigned EHSectionFlags;
52 /// CompactUnwindDwarfEHFrameOnly - Compact unwind encoding indicating that we
53 /// should emit only an EH frame.
54 unsigned CompactUnwindDwarfEHFrameOnly;
56 /// TextSection - Section directive for standard text.
58 const MCSection *TextSection;
60 /// DataSection - Section directive for standard data.
62 const MCSection *DataSection;
64 /// BSSSection - Section that is default initialized to zero.
65 const MCSection *BSSSection;
67 /// ReadOnlySection - Section that is readonly and can contain arbitrary
68 /// initialized data. Targets are not required to have a readonly section.
69 /// If they don't, various bits of code will fall back to using the data
70 /// section for constants.
71 const MCSection *ReadOnlySection;
73 /// StaticCtorSection - This section contains the static constructor pointer
75 const MCSection *StaticCtorSection;
77 /// StaticDtorSection - This section contains the static destructor pointer
79 const MCSection *StaticDtorSection;
81 /// LSDASection - If exception handling is supported by the target, this is
82 /// the section the Language Specific Data Area information is emitted to.
83 const MCSection *LSDASection;
85 /// CompactUnwindSection - If exception handling is supported by the target
86 /// and the target can support a compact representation of the CIE and FDE,
87 /// this is the section to emit them into.
88 const MCSection *CompactUnwindSection;
90 // Dwarf sections for debug info. If a target supports debug info, these must
92 const MCSection *DwarfAbbrevSection;
93 const MCSection *DwarfInfoSection;
94 const MCSection *DwarfLineSection;
95 const MCSection *DwarfFrameSection;
96 const MCSection *DwarfPubTypesSection;
97 const MCSection *DwarfDebugInlineSection;
98 const MCSection *DwarfStrSection;
99 const MCSection *DwarfLocSection;
100 const MCSection *DwarfARangesSection;
101 const MCSection *DwarfRangesSection;
102 const MCSection *DwarfMacroInfoSection;
103 // The pubnames section is no longer generated by default. The generation
104 // can be enabled by a compiler flag.
105 const MCSection *DwarfPubNamesSection;
107 // DWARF5 Experimental Debug Info Sections
108 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
109 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
110 /// If we use the DWARF accelerated hash tables then we want to emit these
112 const MCSection *DwarfAccelNamesSection;
113 const MCSection *DwarfAccelObjCSection;
114 const MCSection *DwarfAccelNamespaceSection;
115 const MCSection *DwarfAccelTypesSection;
117 /// These are used for the Fission separate debug information files.
118 const MCSection *DwarfInfoDWOSection;
119 const MCSection *DwarfAbbrevDWOSection;
120 const MCSection *DwarfStrDWOSection;
121 const MCSection *DwarfLineDWOSection;
122 const MCSection *DwarfLocDWOSection;
123 const MCSection *DwarfStrOffDWOSection;
124 const MCSection *DwarfAddrSection;
126 /// Sections for newer gnu pubnames and pubtypes.
127 const MCSection *DwarfGnuPubNamesSection;
128 const MCSection *DwarfGnuPubTypesSection;
130 const MCSection *COFFDebugSymbolsSection;
132 // Extra TLS Variable Data section. If the target needs to put additional
133 // information for a TLS variable, it'll go here.
134 const MCSection *TLSExtraDataSection;
136 /// TLSDataSection - Section directive for Thread Local data.
137 /// ELF, MachO and COFF.
138 const MCSection *TLSDataSection; // Defaults to ".tdata".
140 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
141 /// Null if this target doesn't support a BSS section.
142 /// ELF and MachO only.
143 const MCSection *TLSBSSSection; // Defaults to ".tbss".
145 /// StackMap section.
146 const MCSection *StackMapSection;
148 /// EHFrameSection - EH frame section. It is initialized on demand so it
149 /// can be overwritten (with uniquing).
150 const MCSection *EHFrameSection;
152 /// ELF specific sections.
154 const MCSection *DataRelSection;
155 const MCSection *DataRelLocalSection;
156 const MCSection *DataRelROSection;
157 const MCSection *DataRelROLocalSection;
158 const MCSection *MergeableConst4Section;
159 const MCSection *MergeableConst8Section;
160 const MCSection *MergeableConst16Section;
162 /// MachO specific sections.
165 /// TLSTLVSection - Section for thread local structure information.
166 /// Contains the source code name of the variable, visibility and a pointer
167 /// to the initial value (.tdata or .tbss).
168 const MCSection *TLSTLVSection; // Defaults to ".tlv".
170 /// TLSThreadInitSection - Section for thread local data initialization
172 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
174 const MCSection *CStringSection;
175 const MCSection *UStringSection;
176 const MCSection *TextCoalSection;
177 const MCSection *ConstTextCoalSection;
178 const MCSection *ConstDataSection;
179 const MCSection *DataCoalSection;
180 const MCSection *DataCommonSection;
181 const MCSection *DataBSSSection;
182 const MCSection *FourByteConstantSection;
183 const MCSection *EightByteConstantSection;
184 const MCSection *SixteenByteConstantSection;
185 const MCSection *LazySymbolPointerSection;
186 const MCSection *NonLazySymbolPointerSection;
188 /// COFF specific sections.
190 const MCSection *DrectveSection;
191 const MCSection *PDataSection;
192 const MCSection *XDataSection;
195 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
198 bool getSupportsWeakOmittedEHFrame() const {
199 return SupportsWeakOmittedEHFrame;
201 bool getSupportsCompactUnwindWithoutEHFrame() const {
202 return SupportsCompactUnwindWithoutEHFrame;
204 bool getCommDirectiveSupportsAlignment() const {
205 return CommDirectiveSupportsAlignment;
208 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
209 unsigned getLSDAEncoding() const { return LSDAEncoding; }
210 unsigned getFDEEncoding() const { return FDECFIEncoding; }
211 unsigned getTTypeEncoding() const { return TTypeEncoding; }
213 unsigned getCompactUnwindDwarfEHFrameOnly() const {
214 return CompactUnwindDwarfEHFrameOnly;
217 const MCSection *getTextSection() const { return TextSection; }
218 const MCSection *getDataSection() const { return DataSection; }
219 const MCSection *getBSSSection() const { return BSSSection; }
220 const MCSection *getLSDASection() const { return LSDASection; }
221 const MCSection *getCompactUnwindSection() const{
222 return CompactUnwindSection;
224 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
225 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
226 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
227 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
228 const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
229 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
230 const MCSection *getDwarfGnuPubNamesSection() const {
231 return DwarfGnuPubNamesSection;
233 const MCSection *getDwarfGnuPubTypesSection() const {
234 return DwarfGnuPubTypesSection;
236 const MCSection *getDwarfDebugInlineSection() const {
237 return DwarfDebugInlineSection;
239 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
240 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
241 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
242 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
243 const MCSection *getDwarfMacroInfoSection() const {
244 return DwarfMacroInfoSection;
247 // DWARF5 Experimental Debug Info Sections
248 const MCSection *getDwarfAccelNamesSection() const {
249 return DwarfAccelNamesSection;
251 const MCSection *getDwarfAccelObjCSection() const {
252 return DwarfAccelObjCSection;
254 const MCSection *getDwarfAccelNamespaceSection() const {
255 return DwarfAccelNamespaceSection;
257 const MCSection *getDwarfAccelTypesSection() const {
258 return DwarfAccelTypesSection;
260 const MCSection *getDwarfInfoDWOSection() const {
261 return DwarfInfoDWOSection;
263 const MCSection *getDwarfTypesSection(uint64_t Hash) const;
264 const MCSection *getDwarfTypesDWOSection(uint64_t Hash) const;
265 const MCSection *getDwarfAbbrevDWOSection() const {
266 return DwarfAbbrevDWOSection;
268 const MCSection *getDwarfStrDWOSection() const {
269 return DwarfStrDWOSection;
271 const MCSection *getDwarfLineDWOSection() const {
272 return DwarfLineDWOSection;
274 const MCSection *getDwarfLocDWOSection() const {
275 return DwarfLocDWOSection;
277 const MCSection *getDwarfStrOffDWOSection() const {
278 return DwarfStrOffDWOSection;
280 const MCSection *getDwarfAddrSection() const {
281 return DwarfAddrSection;
284 const MCSection *getCOFFDebugSymbolsSection() const {
285 return COFFDebugSymbolsSection;
288 const MCSection *getTLSExtraDataSection() const {
289 return TLSExtraDataSection;
291 const MCSection *getTLSDataSection() const { return TLSDataSection; }
292 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
294 const MCSection *getStackMapSection() const { return StackMapSection; }
296 /// ELF specific sections.
298 const MCSection *getDataRelSection() const { return DataRelSection; }
299 const MCSection *getDataRelLocalSection() const {
300 return DataRelLocalSection;
302 const MCSection *getDataRelROSection() const { return DataRelROSection; }
303 const MCSection *getDataRelROLocalSection() const {
304 return DataRelROLocalSection;
306 const MCSection *getMergeableConst4Section() const {
307 return MergeableConst4Section;
309 const MCSection *getMergeableConst8Section() const {
310 return MergeableConst8Section;
312 const MCSection *getMergeableConst16Section() const {
313 return MergeableConst16Section;
316 /// MachO specific sections.
318 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
319 const MCSection *getTLSThreadInitSection() const {
320 return TLSThreadInitSection;
322 const MCSection *getCStringSection() const { return CStringSection; }
323 const MCSection *getUStringSection() const { return UStringSection; }
324 const MCSection *getTextCoalSection() const { return TextCoalSection; }
325 const MCSection *getConstTextCoalSection() const {
326 return ConstTextCoalSection;
328 const MCSection *getConstDataSection() const { return ConstDataSection; }
329 const MCSection *getDataCoalSection() const { return DataCoalSection; }
330 const MCSection *getDataCommonSection() const { return DataCommonSection; }
331 const MCSection *getDataBSSSection() const { return DataBSSSection; }
332 const MCSection *getFourByteConstantSection() const {
333 return FourByteConstantSection;
335 const MCSection *getEightByteConstantSection() const {
336 return EightByteConstantSection;
338 const MCSection *getSixteenByteConstantSection() const {
339 return SixteenByteConstantSection;
341 const MCSection *getLazySymbolPointerSection() const {
342 return LazySymbolPointerSection;
344 const MCSection *getNonLazySymbolPointerSection() const {
345 return NonLazySymbolPointerSection;
348 /// COFF specific sections.
350 const MCSection *getDrectveSection() const { return DrectveSection; }
351 const MCSection *getPDataSection() const { return PDataSection; }
352 const MCSection *getXDataSection() const { return XDataSection; }
354 const MCSection *getEHFrameSection() {
356 InitEHFrameSection();
357 return EHFrameSection;
360 enum Environment { IsMachO, IsELF, IsCOFF };
361 Environment getObjectFileType() const {
365 Reloc::Model getRelocM() const {
372 CodeModel::Model CMModel;
376 void InitMachOMCObjectFileInfo(Triple T);
377 void InitELFMCObjectFileInfo(Triple T);
378 void InitCOFFMCObjectFileInfo(Triple T);
380 /// InitEHFrameSection - Initialize EHFrameSection on demand.
382 void InitEHFrameSection();
385 const Triple &getTargetTriple() const { return TT; }
388 } // end namespace llvm