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 // The pubnames section is no longer generated by default. The generation
96 // can be enabled by a compiler flag.
97 MCSection *DwarfPubNamesSection;
99 /// DWARF5 Experimental Debug Info Sections
100 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
101 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
102 /// If we use the DWARF accelerated hash tables then we want to emit these
104 MCSection *DwarfAccelNamesSection;
105 MCSection *DwarfAccelObjCSection;
106 MCSection *DwarfAccelNamespaceSection;
107 MCSection *DwarfAccelTypesSection;
109 // These are used for the Fission separate debug information files.
110 MCSection *DwarfInfoDWOSection;
111 MCSection *DwarfTypesDWOSection;
112 MCSection *DwarfAbbrevDWOSection;
113 MCSection *DwarfStrDWOSection;
114 MCSection *DwarfLineDWOSection;
115 MCSection *DwarfLocDWOSection;
116 MCSection *DwarfStrOffDWOSection;
117 MCSection *DwarfAddrSection;
119 /// Section for newer gnu pubnames.
120 MCSection *DwarfGnuPubNamesSection;
121 /// Section for newer gnu pubtypes.
122 MCSection *DwarfGnuPubTypesSection;
124 MCSection *COFFDebugSymbolsSection;
126 /// Extra TLS Variable Data section.
128 /// If the target needs to put additional information for a TLS variable,
130 MCSection *TLSExtraDataSection;
132 /// Section directive for Thread Local data. ELF, MachO and COFF.
133 MCSection *TLSDataSection; // Defaults to ".tdata".
135 /// Section directive for Thread Local uninitialized data.
137 /// Null if this target doesn't support a BSS section. ELF and MachO only.
138 MCSection *TLSBSSSection; // Defaults to ".tbss".
140 /// StackMap section.
141 MCSection *StackMapSection;
143 /// FaultMap section.
144 MCSection *FaultMapSection;
146 /// EH frame section.
148 /// It is initialized on demand so it can be overwritten (with uniquing).
149 MCSection *EHFrameSection;
151 // ELF specific sections.
152 MCSection *DataRelROSection;
153 MCSection *MergeableConst4Section;
154 MCSection *MergeableConst8Section;
155 MCSection *MergeableConst16Section;
157 // MachO specific sections.
159 /// Section for thread local structure information.
161 /// Contains the source code name of the variable, visibility and a pointer to
162 /// the initial value (.tdata or .tbss).
163 MCSection *TLSTLVSection; // Defaults to ".tlv".
165 /// Section for thread local data initialization functions.
166 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
168 MCSection *CStringSection;
169 MCSection *UStringSection;
170 MCSection *TextCoalSection;
171 MCSection *ConstTextCoalSection;
172 MCSection *ConstDataSection;
173 MCSection *DataCoalSection;
174 MCSection *DataCommonSection;
175 MCSection *DataBSSSection;
176 MCSection *FourByteConstantSection;
177 MCSection *EightByteConstantSection;
178 MCSection *SixteenByteConstantSection;
179 MCSection *LazySymbolPointerSection;
180 MCSection *NonLazySymbolPointerSection;
182 /// COFF specific sections.
183 MCSection *DrectveSection;
184 MCSection *PDataSection;
185 MCSection *XDataSection;
186 MCSection *SXDataSection;
189 void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM,
190 CodeModel::Model CM, MCContext &ctx);
191 LLVM_ATTRIBUTE_DEPRECATED(
192 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM,
193 CodeModel::Model CM, MCContext &ctx),
194 "StringRef GNU Triple argument replaced by a llvm::Triple object");
196 bool getSupportsWeakOmittedEHFrame() const {
197 return SupportsWeakOmittedEHFrame;
199 bool getSupportsCompactUnwindWithoutEHFrame() const {
200 return SupportsCompactUnwindWithoutEHFrame;
202 bool getOmitDwarfIfHaveCompactUnwind() const {
203 return OmitDwarfIfHaveCompactUnwind;
206 bool getCommDirectiveSupportsAlignment() const {
207 return CommDirectiveSupportsAlignment;
210 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
211 unsigned getLSDAEncoding() const { return LSDAEncoding; }
212 unsigned getFDEEncoding() const { return FDECFIEncoding; }
213 unsigned getTTypeEncoding() const { return TTypeEncoding; }
215 unsigned getCompactUnwindDwarfEHFrameOnly() const {
216 return CompactUnwindDwarfEHFrameOnly;
219 MCSection *getTextSection() const { return TextSection; }
220 MCSection *getDataSection() const { return DataSection; }
221 MCSection *getBSSSection() const { return BSSSection; }
222 MCSection *getReadOnlySection() const { return ReadOnlySection; }
223 MCSection *getLSDASection() const { return LSDASection; }
224 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
225 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
226 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
227 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
228 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
229 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
230 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
231 MCSection *getDwarfGnuPubNamesSection() const {
232 return DwarfGnuPubNamesSection;
234 MCSection *getDwarfGnuPubTypesSection() const {
235 return DwarfGnuPubTypesSection;
237 const MCSection *getDwarfDebugInlineSection() const {
238 return DwarfDebugInlineSection;
240 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
241 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
242 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
243 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
245 // DWARF5 Experimental Debug Info Sections
246 MCSection *getDwarfAccelNamesSection() const {
247 return DwarfAccelNamesSection;
249 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
250 MCSection *getDwarfAccelNamespaceSection() const {
251 return DwarfAccelNamespaceSection;
253 MCSection *getDwarfAccelTypesSection() const {
254 return DwarfAccelTypesSection;
256 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
257 MCSection *getDwarfTypesSection(uint64_t Hash) const;
258 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
259 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
260 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
261 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
262 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
263 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
264 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
266 MCSection *getCOFFDebugSymbolsSection() const {
267 return COFFDebugSymbolsSection;
270 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
271 const MCSection *getTLSDataSection() const { return TLSDataSection; }
272 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
274 MCSection *getStackMapSection() const { return StackMapSection; }
275 MCSection *getFaultMapSection() const { return FaultMapSection; }
277 // ELF specific sections.
278 MCSection *getDataRelROSection() const { return DataRelROSection; }
279 const MCSection *getMergeableConst4Section() const {
280 return MergeableConst4Section;
282 const MCSection *getMergeableConst8Section() const {
283 return MergeableConst8Section;
285 const MCSection *getMergeableConst16Section() const {
286 return MergeableConst16Section;
289 // MachO specific sections.
290 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
291 const MCSection *getTLSThreadInitSection() const {
292 return TLSThreadInitSection;
294 const MCSection *getCStringSection() const { return CStringSection; }
295 const MCSection *getUStringSection() const { return UStringSection; }
296 MCSection *getTextCoalSection() const { return TextCoalSection; }
297 const MCSection *getConstTextCoalSection() const {
298 return ConstTextCoalSection;
300 const MCSection *getConstDataSection() const { return ConstDataSection; }
301 const MCSection *getDataCoalSection() const { return DataCoalSection; }
302 const MCSection *getDataCommonSection() const { return DataCommonSection; }
303 MCSection *getDataBSSSection() const { return DataBSSSection; }
304 const MCSection *getFourByteConstantSection() const {
305 return FourByteConstantSection;
307 const MCSection *getEightByteConstantSection() const {
308 return EightByteConstantSection;
310 const MCSection *getSixteenByteConstantSection() const {
311 return SixteenByteConstantSection;
313 MCSection *getLazySymbolPointerSection() const {
314 return LazySymbolPointerSection;
316 MCSection *getNonLazySymbolPointerSection() const {
317 return NonLazySymbolPointerSection;
320 // COFF specific sections.
321 MCSection *getDrectveSection() const { return DrectveSection; }
322 MCSection *getPDataSection() const { return PDataSection; }
323 MCSection *getXDataSection() const { return XDataSection; }
324 MCSection *getSXDataSection() const { return SXDataSection; }
326 MCSection *getEHFrameSection() {
327 return EHFrameSection;
330 enum Environment { IsMachO, IsELF, IsCOFF };
331 Environment getObjectFileType() const { return Env; }
333 Reloc::Model getRelocM() const { return RelocM; }
338 CodeModel::Model CMModel;
342 void initMachOMCObjectFileInfo(Triple T);
343 void initELFMCObjectFileInfo(Triple T);
344 void initCOFFMCObjectFileInfo(Triple T);
347 const Triple &getTargetTriple() const { return TT; }
350 } // end namespace llvm