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 MCSection *COFFDebugSymbolsSection;
127 MCSection *COFFDebugTypesSection;
129 /// Extra TLS Variable Data section.
131 /// If the target needs to put additional information for a TLS variable,
133 MCSection *TLSExtraDataSection;
135 /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
136 MCSection *TLSDataSection; // Defaults to ".tdata".
138 /// Section directive for Thread Local uninitialized data.
140 /// Null if this target doesn't support a BSS section. ELF and MachO only.
141 MCSection *TLSBSSSection; // Defaults to ".tbss".
143 /// StackMap section.
144 MCSection *StackMapSection;
146 /// FaultMap section.
147 MCSection *FaultMapSection;
149 /// EH frame section.
151 /// It is initialized on demand so it can be overwritten (with uniquing).
152 MCSection *EHFrameSection;
154 // ELF specific sections.
155 MCSection *DataRelROSection;
156 MCSection *MergeableConst4Section;
157 MCSection *MergeableConst8Section;
158 MCSection *MergeableConst16Section;
159 MCSection *MergeableConst32Section;
161 // MachO specific sections.
163 /// Section for thread local structure information.
165 /// Contains the source code name of the variable, visibility and a pointer to
166 /// the initial value (.tdata or .tbss).
167 MCSection *TLSTLVSection; // Defaults to ".tlv".
169 /// Section for thread local data initialization functions.
170 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
172 MCSection *CStringSection;
173 MCSection *UStringSection;
174 MCSection *TextCoalSection;
175 MCSection *ConstTextCoalSection;
176 MCSection *ConstDataSection;
177 MCSection *DataCoalSection;
178 MCSection *DataCommonSection;
179 MCSection *DataBSSSection;
180 MCSection *FourByteConstantSection;
181 MCSection *EightByteConstantSection;
182 MCSection *SixteenByteConstantSection;
183 MCSection *LazySymbolPointerSection;
184 MCSection *NonLazySymbolPointerSection;
185 MCSection *ThreadLocalPointerSection;
187 /// COFF specific sections.
188 MCSection *DrectveSection;
189 MCSection *PDataSection;
190 MCSection *XDataSection;
191 MCSection *SXDataSection;
194 void InitMCObjectFileInfo(const Triple &TT, bool PIC, CodeModel::Model CM,
197 bool getSupportsWeakOmittedEHFrame() const {
198 return SupportsWeakOmittedEHFrame;
200 bool getSupportsCompactUnwindWithoutEHFrame() const {
201 return SupportsCompactUnwindWithoutEHFrame;
203 bool getOmitDwarfIfHaveCompactUnwind() const {
204 return OmitDwarfIfHaveCompactUnwind;
207 bool getCommDirectiveSupportsAlignment() const {
208 return CommDirectiveSupportsAlignment;
211 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
212 unsigned getLSDAEncoding() const { return LSDAEncoding; }
213 unsigned getFDEEncoding() const { return FDECFIEncoding; }
214 unsigned getTTypeEncoding() const { return TTypeEncoding; }
216 unsigned getCompactUnwindDwarfEHFrameOnly() const {
217 return CompactUnwindDwarfEHFrameOnly;
220 MCSection *getTextSection() const { return TextSection; }
221 MCSection *getDataSection() const { return DataSection; }
222 MCSection *getBSSSection() const { return BSSSection; }
223 MCSection *getReadOnlySection() const { return ReadOnlySection; }
224 MCSection *getLSDASection() const { return LSDASection; }
225 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
226 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
227 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
228 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
229 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
230 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
231 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
232 MCSection *getDwarfGnuPubNamesSection() const {
233 return DwarfGnuPubNamesSection;
235 MCSection *getDwarfGnuPubTypesSection() const {
236 return DwarfGnuPubTypesSection;
238 const MCSection *getDwarfDebugInlineSection() const {
239 return DwarfDebugInlineSection;
241 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
242 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
243 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
244 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
245 MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
247 // DWARF5 Experimental Debug Info Sections
248 MCSection *getDwarfAccelNamesSection() const {
249 return DwarfAccelNamesSection;
251 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
252 MCSection *getDwarfAccelNamespaceSection() const {
253 return DwarfAccelNamespaceSection;
255 MCSection *getDwarfAccelTypesSection() const {
256 return DwarfAccelTypesSection;
258 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
259 MCSection *getDwarfTypesSection(uint64_t Hash) const;
260 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
261 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
262 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
263 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
264 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
265 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
266 MCSection *getDwarfStrOffSection() const { return DwarfStrOffSection; }
267 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
268 MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
269 MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
271 MCSection *getCOFFDebugSymbolsSection() const {
272 return COFFDebugSymbolsSection;
274 MCSection *getCOFFDebugTypesSection() const {
275 return COFFDebugTypesSection;
279 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
280 const MCSection *getTLSDataSection() const { return TLSDataSection; }
281 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
283 MCSection *getStackMapSection() const { return StackMapSection; }
284 MCSection *getFaultMapSection() const { return FaultMapSection; }
286 // ELF specific sections.
287 MCSection *getDataRelROSection() const { return DataRelROSection; }
288 const MCSection *getMergeableConst4Section() const {
289 return MergeableConst4Section;
291 const MCSection *getMergeableConst8Section() const {
292 return MergeableConst8Section;
294 const MCSection *getMergeableConst16Section() const {
295 return MergeableConst16Section;
297 const MCSection *getMergeableConst32Section() const {
298 return MergeableConst32Section;
301 // MachO specific sections.
302 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
303 const MCSection *getTLSThreadInitSection() const {
304 return TLSThreadInitSection;
306 const MCSection *getCStringSection() const { return CStringSection; }
307 const MCSection *getUStringSection() const { return UStringSection; }
308 MCSection *getTextCoalSection() const { return TextCoalSection; }
309 const MCSection *getConstTextCoalSection() const {
310 return ConstTextCoalSection;
312 const MCSection *getConstDataSection() const { return ConstDataSection; }
313 const MCSection *getDataCoalSection() const { return DataCoalSection; }
314 const MCSection *getDataCommonSection() const { return DataCommonSection; }
315 MCSection *getDataBSSSection() const { return DataBSSSection; }
316 const MCSection *getFourByteConstantSection() const {
317 return FourByteConstantSection;
319 const MCSection *getEightByteConstantSection() const {
320 return EightByteConstantSection;
322 const MCSection *getSixteenByteConstantSection() const {
323 return SixteenByteConstantSection;
325 MCSection *getLazySymbolPointerSection() const {
326 return LazySymbolPointerSection;
328 MCSection *getNonLazySymbolPointerSection() const {
329 return NonLazySymbolPointerSection;
331 MCSection *getThreadLocalPointerSection() const {
332 return ThreadLocalPointerSection;
335 // COFF specific sections.
336 MCSection *getDrectveSection() const { return DrectveSection; }
337 MCSection *getPDataSection() const { return PDataSection; }
338 MCSection *getXDataSection() const { return XDataSection; }
339 MCSection *getSXDataSection() const { return SXDataSection; }
341 MCSection *getEHFrameSection() {
342 return EHFrameSection;
345 enum Environment { IsMachO, IsELF, IsCOFF, IsWasm };
346 Environment getObjectFileType() const { return Env; }
348 bool isPositionIndependent() const { return PositionIndependent; }
352 bool PositionIndependent;
353 CodeModel::Model CMModel;
357 void initMachOMCObjectFileInfo(const Triple &T);
358 void initELFMCObjectFileInfo(const Triple &T);
359 void initCOFFMCObjectFileInfo(const Triple &T);
360 void initWasmMCObjectFileInfo(const Triple &T);
363 const Triple &getTargetTriple() const { return TT; }
366 } // end namespace llvm