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 /// This section contains the static constructor pointer list.
69 MCSection *StaticCtorSection;
71 /// This section contains the static destructor pointer list.
72 MCSection *StaticDtorSection;
74 /// If exception handling is supported by the target, this is the section the
75 /// Language Specific Data Area information is emitted to.
76 MCSection *LSDASection;
78 /// If exception handling is supported by the target and the target can
79 /// support a compact representation of the CIE and FDE, this is the section
80 /// to emit them into.
81 MCSection *CompactUnwindSection;
83 // Dwarf sections for debug info. If a target supports debug info, these must
85 MCSection *DwarfAbbrevSection;
86 MCSection *DwarfInfoSection;
87 MCSection *DwarfLineSection;
88 MCSection *DwarfFrameSection;
89 MCSection *DwarfPubTypesSection;
90 const MCSection *DwarfDebugInlineSection;
91 MCSection *DwarfStrSection;
92 MCSection *DwarfLocSection;
93 MCSection *DwarfARangesSection;
94 MCSection *DwarfRangesSection;
95 MCSection *DwarfMacinfoSection;
96 // The pubnames section is no longer generated by default. The generation
97 // can be enabled by a compiler flag.
98 MCSection *DwarfPubNamesSection;
100 /// DWARF5 Experimental Debug Info Sections
101 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
102 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
103 /// If we use the DWARF accelerated hash tables then we want to emit these
105 MCSection *DwarfAccelNamesSection;
106 MCSection *DwarfAccelObjCSection;
107 MCSection *DwarfAccelNamespaceSection;
108 MCSection *DwarfAccelTypesSection;
110 // These are used for the Fission separate debug information files.
111 MCSection *DwarfInfoDWOSection;
112 MCSection *DwarfTypesDWOSection;
113 MCSection *DwarfAbbrevDWOSection;
114 MCSection *DwarfStrDWOSection;
115 MCSection *DwarfLineDWOSection;
116 MCSection *DwarfLocDWOSection;
117 MCSection *DwarfStrOffDWOSection;
118 MCSection *DwarfAddrSection;
120 // These are for Fission DWP files.
121 MCSection *DwarfCUIndexSection;
122 MCSection *DwarfTUIndexSection;
124 /// Section for newer gnu pubnames.
125 MCSection *DwarfGnuPubNamesSection;
126 /// Section for newer gnu pubtypes.
127 MCSection *DwarfGnuPubTypesSection;
129 MCSection *COFFDebugSymbolsSection;
131 /// Extra TLS Variable Data section.
133 /// If the target needs to put additional information for a TLS variable,
135 MCSection *TLSExtraDataSection;
137 /// Section directive for Thread Local data. ELF, MachO and COFF.
138 MCSection *TLSDataSection; // Defaults to ".tdata".
140 /// Section directive for Thread Local uninitialized data.
142 /// Null if this target doesn't support a BSS section. ELF and MachO only.
143 MCSection *TLSBSSSection; // Defaults to ".tbss".
145 /// StackMap section.
146 MCSection *StackMapSection;
148 /// FaultMap section.
149 MCSection *FaultMapSection;
151 /// EH frame section.
153 /// It is initialized on demand so it can be overwritten (with uniquing).
154 MCSection *EHFrameSection;
156 // ELF specific sections.
157 MCSection *DataRelROSection;
158 MCSection *MergeableConst4Section;
159 MCSection *MergeableConst8Section;
160 MCSection *MergeableConst16Section;
162 // MachO specific sections.
164 /// Section for thread local structure information.
166 /// Contains the source code name of the variable, visibility and a pointer to
167 /// the initial value (.tdata or .tbss).
168 MCSection *TLSTLVSection; // Defaults to ".tlv".
170 /// Section for thread local data initialization functions.
171 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
173 MCSection *CStringSection;
174 MCSection *UStringSection;
175 MCSection *TextCoalSection;
176 MCSection *ConstTextCoalSection;
177 MCSection *ConstDataSection;
178 MCSection *DataCoalSection;
179 MCSection *DataCommonSection;
180 MCSection *DataBSSSection;
181 MCSection *FourByteConstantSection;
182 MCSection *EightByteConstantSection;
183 MCSection *SixteenByteConstantSection;
184 MCSection *LazySymbolPointerSection;
185 MCSection *NonLazySymbolPointerSection;
187 /// COFF specific sections.
188 MCSection *DrectveSection;
189 MCSection *PDataSection;
190 MCSection *XDataSection;
191 MCSection *SXDataSection;
194 void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM,
195 CodeModel::Model CM, MCContext &ctx);
196 LLVM_ATTRIBUTE_DEPRECATED(
197 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM,
198 CodeModel::Model CM, MCContext &ctx),
199 "StringRef GNU Triple argument replaced by a llvm::Triple object");
201 bool getSupportsWeakOmittedEHFrame() const {
202 return SupportsWeakOmittedEHFrame;
204 bool getSupportsCompactUnwindWithoutEHFrame() const {
205 return SupportsCompactUnwindWithoutEHFrame;
207 bool getOmitDwarfIfHaveCompactUnwind() const {
208 return OmitDwarfIfHaveCompactUnwind;
211 bool getCommDirectiveSupportsAlignment() const {
212 return CommDirectiveSupportsAlignment;
215 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
216 unsigned getLSDAEncoding() const { return LSDAEncoding; }
217 unsigned getFDEEncoding() const { return FDECFIEncoding; }
218 unsigned getTTypeEncoding() const { return TTypeEncoding; }
220 unsigned getCompactUnwindDwarfEHFrameOnly() const {
221 return CompactUnwindDwarfEHFrameOnly;
224 MCSection *getTextSection() const { return TextSection; }
225 MCSection *getDataSection() const { return DataSection; }
226 MCSection *getBSSSection() const { return BSSSection; }
227 MCSection *getReadOnlySection() const { return ReadOnlySection; }
228 MCSection *getLSDASection() const { return LSDASection; }
229 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
230 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
231 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
232 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
233 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
234 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
235 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
236 MCSection *getDwarfGnuPubNamesSection() const {
237 return DwarfGnuPubNamesSection;
239 MCSection *getDwarfGnuPubTypesSection() const {
240 return DwarfGnuPubTypesSection;
242 const MCSection *getDwarfDebugInlineSection() const {
243 return DwarfDebugInlineSection;
245 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
246 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
247 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
248 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
249 MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
251 // DWARF5 Experimental Debug Info Sections
252 MCSection *getDwarfAccelNamesSection() const {
253 return DwarfAccelNamesSection;
255 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
256 MCSection *getDwarfAccelNamespaceSection() const {
257 return DwarfAccelNamespaceSection;
259 MCSection *getDwarfAccelTypesSection() const {
260 return DwarfAccelTypesSection;
262 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
263 MCSection *getDwarfTypesSection(uint64_t Hash) const;
264 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
265 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
266 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
267 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
268 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
269 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
270 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
271 MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
272 MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
274 MCSection *getCOFFDebugSymbolsSection() const {
275 return COFFDebugSymbolsSection;
278 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
279 const MCSection *getTLSDataSection() const { return TLSDataSection; }
280 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
282 MCSection *getStackMapSection() const { return StackMapSection; }
283 MCSection *getFaultMapSection() const { return FaultMapSection; }
285 // ELF specific sections.
286 MCSection *getDataRelROSection() const { return DataRelROSection; }
287 const MCSection *getMergeableConst4Section() const {
288 return MergeableConst4Section;
290 const MCSection *getMergeableConst8Section() const {
291 return MergeableConst8Section;
293 const MCSection *getMergeableConst16Section() const {
294 return MergeableConst16Section;
297 // MachO specific sections.
298 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
299 const MCSection *getTLSThreadInitSection() const {
300 return TLSThreadInitSection;
302 const MCSection *getCStringSection() const { return CStringSection; }
303 const MCSection *getUStringSection() const { return UStringSection; }
304 MCSection *getTextCoalSection() const { return TextCoalSection; }
305 const MCSection *getConstTextCoalSection() const {
306 return ConstTextCoalSection;
308 const MCSection *getConstDataSection() const { return ConstDataSection; }
309 const MCSection *getDataCoalSection() const { return DataCoalSection; }
310 const MCSection *getDataCommonSection() const { return DataCommonSection; }
311 MCSection *getDataBSSSection() const { return DataBSSSection; }
312 const MCSection *getFourByteConstantSection() const {
313 return FourByteConstantSection;
315 const MCSection *getEightByteConstantSection() const {
316 return EightByteConstantSection;
318 const MCSection *getSixteenByteConstantSection() const {
319 return SixteenByteConstantSection;
321 MCSection *getLazySymbolPointerSection() const {
322 return LazySymbolPointerSection;
324 MCSection *getNonLazySymbolPointerSection() const {
325 return NonLazySymbolPointerSection;
328 // COFF specific sections.
329 MCSection *getDrectveSection() const { return DrectveSection; }
330 MCSection *getPDataSection() const { return PDataSection; }
331 MCSection *getXDataSection() const { return XDataSection; }
332 MCSection *getSXDataSection() const { return SXDataSection; }
334 MCSection *getEHFrameSection() {
335 return EHFrameSection;
338 enum Environment { IsMachO, IsELF, IsCOFF };
339 Environment getObjectFileType() const { return Env; }
341 Reloc::Model getRelocM() const { return RelocM; }
346 CodeModel::Model CMModel;
350 void initMachOMCObjectFileInfo(Triple T);
351 void initELFMCObjectFileInfo(Triple T);
352 void initCOFFMCObjectFileInfo(Triple T);
355 const Triple &getTargetTriple() const { return TT; }
358 } // end namespace llvm