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_MCOBJECTFILEINFO_H
15 #define LLVM_MC_MCOBJECTFILEINFO_H
17 #include "llvm/ADT/Triple.h"
18 #include "llvm/Support/CodeGen.h"
24 class MCObjectFileInfo {
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.
28 bool CommDirectiveSupportsAlignment;
30 /// True if target object file supports a weak_definition of constant 0 for an
32 bool SupportsWeakOmittedEHFrame;
34 /// True if the target object file supports emitting a compact unwind section
35 /// without an associated EH frame section.
36 bool SupportsCompactUnwindWithoutEHFrame;
38 /// OmitDwarfIfHaveCompactUnwind - True if the target object file
39 /// supports having some functions with compact unwind and other with
41 bool OmitDwarfIfHaveCompactUnwind;
43 /// PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values
45 unsigned PersonalityEncoding;
46 unsigned LSDAEncoding;
47 unsigned FDECFIEncoding;
48 unsigned TTypeEncoding;
50 /// Compact unwind encoding indicating that we should emit only an EH frame.
51 unsigned CompactUnwindDwarfEHFrameOnly;
53 /// Section directive for standard text.
54 MCSection *TextSection;
56 /// Section directive for standard data.
57 MCSection *DataSection;
59 /// Section that is default initialized to zero.
60 MCSection *BSSSection;
62 /// Section that is readonly and can contain arbitrary initialized data.
63 /// Targets are not required to have a readonly section. If they don't,
64 /// various bits of code will fall back to using the data section for
66 MCSection *ReadOnlySection;
68 /// If exception handling is supported by the target, this is the section the
69 /// Language Specific Data Area information is emitted to.
70 MCSection *LSDASection;
72 /// If exception handling is supported by the target and the target can
73 /// support a compact representation of the CIE and FDE, this is the section
74 /// to emit them into.
75 MCSection *CompactUnwindSection;
77 // Dwarf sections for debug info. If a target supports debug info, these must
79 MCSection *DwarfAbbrevSection;
80 MCSection *DwarfInfoSection;
81 MCSection *DwarfLineSection;
82 MCSection *DwarfFrameSection;
83 MCSection *DwarfPubTypesSection;
84 const MCSection *DwarfDebugInlineSection;
85 MCSection *DwarfStrSection;
86 MCSection *DwarfLocSection;
87 MCSection *DwarfARangesSection;
88 MCSection *DwarfRangesSection;
89 MCSection *DwarfMacinfoSection;
90 // The pubnames section is no longer generated by default. The generation
91 // can be enabled by a compiler flag.
92 MCSection *DwarfPubNamesSection;
94 /// DWARF5 Experimental Debug Info Sections
95 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
96 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
97 /// If we use the DWARF accelerated hash tables then we want to emit these
99 MCSection *DwarfAccelNamesSection;
100 MCSection *DwarfAccelObjCSection;
101 MCSection *DwarfAccelNamespaceSection;
102 MCSection *DwarfAccelTypesSection;
104 // These are used for the Fission separate debug information files.
105 MCSection *DwarfInfoDWOSection;
106 MCSection *DwarfTypesDWOSection;
107 MCSection *DwarfAbbrevDWOSection;
108 MCSection *DwarfStrDWOSection;
109 MCSection *DwarfLineDWOSection;
110 MCSection *DwarfLocDWOSection;
111 MCSection *DwarfStrOffDWOSection;
113 /// The DWARF v5 string offset and address table sections.
114 MCSection *DwarfStrOffSection;
115 MCSection *DwarfAddrSection;
117 // These are for Fission DWP files.
118 MCSection *DwarfCUIndexSection;
119 MCSection *DwarfTUIndexSection;
121 /// Section for newer gnu pubnames.
122 MCSection *DwarfGnuPubNamesSection;
123 /// Section for newer gnu pubtypes.
124 MCSection *DwarfGnuPubTypesSection;
126 // Section for Swift AST
127 MCSection *DwarfSwiftASTSection;
129 MCSection *COFFDebugSymbolsSection;
130 MCSection *COFFDebugTypesSection;
131 MCSection *COFFGlobalTypeHashesSection;
133 /// Extra TLS Variable Data section.
135 /// If the target needs to put additional information for a TLS variable,
137 MCSection *TLSExtraDataSection;
139 /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
140 MCSection *TLSDataSection; // Defaults to ".tdata".
142 /// Section directive for Thread Local uninitialized data.
144 /// Null if this target doesn't support a BSS section. ELF and MachO only.
145 MCSection *TLSBSSSection; // Defaults to ".tbss".
147 /// StackMap section.
148 MCSection *StackMapSection;
150 /// FaultMap section.
151 MCSection *FaultMapSection;
153 /// EH frame section.
155 /// It is initialized on demand so it can be overwritten (with uniquing).
156 MCSection *EHFrameSection;
158 /// Section containing metadata on function stack sizes.
159 MCSection *StackSizesSection;
161 // ELF specific sections.
162 MCSection *DataRelROSection;
163 MCSection *MergeableConst4Section;
164 MCSection *MergeableConst8Section;
165 MCSection *MergeableConst16Section;
166 MCSection *MergeableConst32Section;
168 // MachO specific sections.
170 /// Section for thread local structure information.
172 /// Contains the source code name of the variable, visibility and a pointer to
173 /// the initial value (.tdata or .tbss).
174 MCSection *TLSTLVSection; // Defaults to ".tlv".
176 /// Section for thread local data initialization functions.
177 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
179 MCSection *CStringSection;
180 MCSection *UStringSection;
181 MCSection *TextCoalSection;
182 MCSection *ConstTextCoalSection;
183 MCSection *ConstDataSection;
184 MCSection *DataCoalSection;
185 MCSection *DataCommonSection;
186 MCSection *DataBSSSection;
187 MCSection *FourByteConstantSection;
188 MCSection *EightByteConstantSection;
189 MCSection *SixteenByteConstantSection;
190 MCSection *LazySymbolPointerSection;
191 MCSection *NonLazySymbolPointerSection;
192 MCSection *ThreadLocalPointerSection;
194 /// COFF specific sections.
195 MCSection *DrectveSection;
196 MCSection *PDataSection;
197 MCSection *XDataSection;
198 MCSection *SXDataSection;
201 void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
202 bool LargeCodeModel = false);
204 bool getSupportsWeakOmittedEHFrame() const {
205 return SupportsWeakOmittedEHFrame;
207 bool getSupportsCompactUnwindWithoutEHFrame() const {
208 return SupportsCompactUnwindWithoutEHFrame;
210 bool getOmitDwarfIfHaveCompactUnwind() const {
211 return OmitDwarfIfHaveCompactUnwind;
214 bool getCommDirectiveSupportsAlignment() const {
215 return CommDirectiveSupportsAlignment;
218 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
219 unsigned getLSDAEncoding() const { return LSDAEncoding; }
220 unsigned getFDEEncoding() const { return FDECFIEncoding; }
221 unsigned getTTypeEncoding() const { return TTypeEncoding; }
223 unsigned getCompactUnwindDwarfEHFrameOnly() const {
224 return CompactUnwindDwarfEHFrameOnly;
227 MCSection *getTextSection() const { return TextSection; }
228 MCSection *getDataSection() const { return DataSection; }
229 MCSection *getBSSSection() const { return BSSSection; }
230 MCSection *getReadOnlySection() const { return ReadOnlySection; }
231 MCSection *getLSDASection() const { return LSDASection; }
232 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
233 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
234 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
235 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
236 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
237 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
238 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
239 MCSection *getDwarfGnuPubNamesSection() const {
240 return DwarfGnuPubNamesSection;
242 MCSection *getDwarfGnuPubTypesSection() const {
243 return DwarfGnuPubTypesSection;
245 const MCSection *getDwarfDebugInlineSection() const {
246 return DwarfDebugInlineSection;
248 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
249 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
250 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
251 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
252 MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
254 // DWARF5 Experimental Debug Info Sections
255 MCSection *getDwarfAccelNamesSection() const {
256 return DwarfAccelNamesSection;
258 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
259 MCSection *getDwarfAccelNamespaceSection() const {
260 return DwarfAccelNamespaceSection;
262 MCSection *getDwarfAccelTypesSection() const {
263 return DwarfAccelTypesSection;
265 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
266 MCSection *getDwarfTypesSection(uint64_t Hash) const;
267 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
268 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
269 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
270 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
271 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
272 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
273 MCSection *getDwarfStrOffSection() const { return DwarfStrOffSection; }
274 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
275 MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
276 MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
277 MCSection *getDwarfSwiftASTSection() const { return DwarfSwiftASTSection; }
279 MCSection *getCOFFDebugSymbolsSection() const {
280 return COFFDebugSymbolsSection;
282 MCSection *getCOFFDebugTypesSection() const {
283 return COFFDebugTypesSection;
285 MCSection *getCOFFGlobalTypeHashesSection() const {
286 return COFFGlobalTypeHashesSection;
289 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
290 const MCSection *getTLSDataSection() const { return TLSDataSection; }
291 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
293 MCSection *getStackMapSection() const { return StackMapSection; }
294 MCSection *getFaultMapSection() const { return FaultMapSection; }
296 MCSection *getStackSizesSection() const { return StackSizesSection; }
298 // ELF specific sections.
299 MCSection *getDataRelROSection() const { return DataRelROSection; }
300 const MCSection *getMergeableConst4Section() const {
301 return MergeableConst4Section;
303 const MCSection *getMergeableConst8Section() const {
304 return MergeableConst8Section;
306 const MCSection *getMergeableConst16Section() const {
307 return MergeableConst16Section;
309 const MCSection *getMergeableConst32Section() const {
310 return MergeableConst32Section;
313 // MachO specific sections.
314 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
315 const MCSection *getTLSThreadInitSection() const {
316 return TLSThreadInitSection;
318 const MCSection *getCStringSection() const { return CStringSection; }
319 const MCSection *getUStringSection() const { return UStringSection; }
320 MCSection *getTextCoalSection() const { return TextCoalSection; }
321 const MCSection *getConstTextCoalSection() const {
322 return ConstTextCoalSection;
324 const MCSection *getConstDataSection() const { return ConstDataSection; }
325 const MCSection *getDataCoalSection() const { return DataCoalSection; }
326 const MCSection *getDataCommonSection() const { return DataCommonSection; }
327 MCSection *getDataBSSSection() const { return DataBSSSection; }
328 const MCSection *getFourByteConstantSection() const {
329 return FourByteConstantSection;
331 const MCSection *getEightByteConstantSection() const {
332 return EightByteConstantSection;
334 const MCSection *getSixteenByteConstantSection() const {
335 return SixteenByteConstantSection;
337 MCSection *getLazySymbolPointerSection() const {
338 return LazySymbolPointerSection;
340 MCSection *getNonLazySymbolPointerSection() const {
341 return NonLazySymbolPointerSection;
343 MCSection *getThreadLocalPointerSection() const {
344 return ThreadLocalPointerSection;
347 // COFF specific sections.
348 MCSection *getDrectveSection() const { return DrectveSection; }
349 MCSection *getPDataSection() const { return PDataSection; }
350 MCSection *getXDataSection() const { return XDataSection; }
351 MCSection *getSXDataSection() const { return SXDataSection; }
353 MCSection *getEHFrameSection() {
354 return EHFrameSection;
357 enum Environment { IsMachO, IsELF, IsCOFF, IsWasm };
358 Environment getObjectFileType() const { return Env; }
360 bool isPositionIndependent() const { return PositionIndependent; }
364 bool PositionIndependent;
368 void initMachOMCObjectFileInfo(const Triple &T);
369 void initELFMCObjectFileInfo(const Triple &T, bool Large);
370 void initCOFFMCObjectFileInfo(const Triple &T);
371 void initWasmMCObjectFileInfo(const Triple &T);
374 const Triple &getTargetTriple() const { return TT; }
377 } // end namespace llvm