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/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 /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the
37 /// "EH_frame" symbol for EH information should be an assembler temporary (aka
38 /// private linkage, aka an L or .L label) or false if it should be a normal
39 /// non-.globl label. This defaults to true.
40 bool IsFunctionEHFrameSymbolPrivate;
42 /// SupportsCompactUnwindWithoutEHFrame - True if the target object file
43 /// supports emitting a compact unwind section without an associated EH frame
45 bool SupportsCompactUnwindWithoutEHFrame;
47 /// PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values
49 unsigned PersonalityEncoding;
50 unsigned LSDAEncoding;
51 unsigned FDECFIEncoding;
52 unsigned TTypeEncoding;
54 /// Section flags for eh_frame
55 unsigned EHSectionType;
56 unsigned EHSectionFlags;
58 /// CompactUnwindDwarfEHFrameOnly - Compact unwind encoding indicating that we
59 /// should emit only an EH frame.
60 unsigned CompactUnwindDwarfEHFrameOnly;
62 /// TextSection - Section directive for standard text.
64 const MCSection *TextSection;
66 /// DataSection - Section directive for standard data.
68 const MCSection *DataSection;
70 /// BSSSection - Section that is default initialized to zero.
71 const MCSection *BSSSection;
73 /// ReadOnlySection - Section that is readonly and can contain arbitrary
74 /// initialized data. Targets are not required to have a readonly section.
75 /// If they don't, various bits of code will fall back to using the data
76 /// section for constants.
77 const MCSection *ReadOnlySection;
79 /// StaticCtorSection - This section contains the static constructor pointer
81 const MCSection *StaticCtorSection;
83 /// StaticDtorSection - This section contains the static destructor pointer
85 const MCSection *StaticDtorSection;
87 /// LSDASection - If exception handling is supported by the target, this is
88 /// the section the Language Specific Data Area information is emitted to.
89 const MCSection *LSDASection;
91 /// CompactUnwindSection - If exception handling is supported by the target
92 /// and the target can support a compact representation of the CIE and FDE,
93 /// this is the section to emit them into.
94 const MCSection *CompactUnwindSection;
96 // Dwarf sections for debug info. If a target supports debug info, these must
98 const MCSection *DwarfAbbrevSection;
99 const MCSection *DwarfInfoSection;
100 const MCSection *DwarfLineSection;
101 const MCSection *DwarfFrameSection;
102 const MCSection *DwarfPubTypesSection;
103 const MCSection *DwarfDebugInlineSection;
104 const MCSection *DwarfStrSection;
105 const MCSection *DwarfLocSection;
106 const MCSection *DwarfARangesSection;
107 const MCSection *DwarfRangesSection;
108 const MCSection *DwarfMacroInfoSection;
109 // The pubnames section is no longer generated by default. The generation
110 // can be enabled by a compiler flag.
111 const MCSection *DwarfPubNamesSection;
113 // DWARF5 Experimental Debug Info Sections
114 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
115 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
116 /// If we use the DWARF accelerated hash tables then we want to emit these
118 const MCSection *DwarfAccelNamesSection;
119 const MCSection *DwarfAccelObjCSection;
120 const MCSection *DwarfAccelNamespaceSection;
121 const MCSection *DwarfAccelTypesSection;
123 /// These are used for the Fission separate debug information files.
124 const MCSection *DwarfInfoDWOSection;
125 const MCSection *DwarfTypesDWOSection;
126 const MCSection *DwarfAbbrevDWOSection;
127 const MCSection *DwarfStrDWOSection;
128 const MCSection *DwarfLineDWOSection;
129 const MCSection *DwarfLocDWOSection;
130 const MCSection *DwarfStrOffDWOSection;
131 const MCSection *DwarfAddrSection;
133 /// Sections for newer gnu pubnames and pubtypes.
134 const MCSection *DwarfGnuPubNamesSection;
135 const MCSection *DwarfGnuPubTypesSection;
137 const MCSection *COFFDebugSymbolsSection;
139 // Extra TLS Variable Data section. If the target needs to put additional
140 // information for a TLS variable, it'll go here.
141 const MCSection *TLSExtraDataSection;
143 /// TLSDataSection - Section directive for Thread Local data.
144 /// ELF, MachO and COFF.
145 const MCSection *TLSDataSection; // Defaults to ".tdata".
147 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
148 /// Null if this target doesn't support a BSS section.
149 /// ELF and MachO only.
150 const MCSection *TLSBSSSection; // Defaults to ".tbss".
152 /// StackMap section.
153 const MCSection *StackMapSection;
155 /// EHFrameSection - EH frame section. It is initialized on demand so it
156 /// can be overwritten (with uniquing).
157 const MCSection *EHFrameSection;
159 /// ELF specific sections.
161 const MCSection *DataRelSection;
162 const MCSection *DataRelLocalSection;
163 const MCSection *DataRelROSection;
164 const MCSection *DataRelROLocalSection;
165 const MCSection *MergeableConst4Section;
166 const MCSection *MergeableConst8Section;
167 const MCSection *MergeableConst16Section;
169 /// MachO specific sections.
172 /// TLSTLVSection - Section for thread local structure information.
173 /// Contains the source code name of the variable, visibility and a pointer
174 /// to the initial value (.tdata or .tbss).
175 const MCSection *TLSTLVSection; // Defaults to ".tlv".
177 /// TLSThreadInitSection - Section for thread local data initialization
179 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
181 const MCSection *CStringSection;
182 const MCSection *UStringSection;
183 const MCSection *TextCoalSection;
184 const MCSection *ConstTextCoalSection;
185 const MCSection *ConstDataSection;
186 const MCSection *DataCoalSection;
187 const MCSection *DataCommonSection;
188 const MCSection *DataBSSSection;
189 const MCSection *FourByteConstantSection;
190 const MCSection *EightByteConstantSection;
191 const MCSection *SixteenByteConstantSection;
192 const MCSection *LazySymbolPointerSection;
193 const MCSection *NonLazySymbolPointerSection;
195 /// COFF specific sections.
197 const MCSection *DrectveSection;
198 const MCSection *PDataSection;
199 const MCSection *XDataSection;
202 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
205 bool isFunctionEHFrameSymbolPrivate() const {
206 return IsFunctionEHFrameSymbolPrivate;
208 bool getSupportsWeakOmittedEHFrame() const {
209 return SupportsWeakOmittedEHFrame;
211 bool getSupportsCompactUnwindWithoutEHFrame() const {
212 return SupportsCompactUnwindWithoutEHFrame;
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 const MCSection *getTextSection() const { return TextSection; }
228 const MCSection *getDataSection() const { return DataSection; }
229 const MCSection *getBSSSection() const { return BSSSection; }
230 const MCSection *getLSDASection() const { return LSDASection; }
231 const MCSection *getCompactUnwindSection() const{
232 return CompactUnwindSection;
234 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
235 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
236 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
237 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
238 const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
239 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
240 const MCSection *getDwarfGnuPubNamesSection() const {
241 return DwarfGnuPubNamesSection;
243 const MCSection *getDwarfGnuPubTypesSection() const {
244 return DwarfGnuPubTypesSection;
246 const MCSection *getDwarfDebugInlineSection() const {
247 return DwarfDebugInlineSection;
249 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
250 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
251 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
252 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
253 const MCSection *getDwarfMacroInfoSection() const {
254 return DwarfMacroInfoSection;
257 // DWARF5 Experimental Debug Info Sections
258 const MCSection *getDwarfAccelNamesSection() const {
259 return DwarfAccelNamesSection;
261 const MCSection *getDwarfAccelObjCSection() const {
262 return DwarfAccelObjCSection;
264 const MCSection *getDwarfAccelNamespaceSection() const {
265 return DwarfAccelNamespaceSection;
267 const MCSection *getDwarfAccelTypesSection() const {
268 return DwarfAccelTypesSection;
270 const MCSection *getDwarfInfoDWOSection() const {
271 return DwarfInfoDWOSection;
273 const MCSection *getDwarfTypesSection(uint64_t Hash) const;
274 const MCSection *getDwarfTypesDWOSection() const {
275 return DwarfTypesDWOSection;
277 const MCSection *getDwarfAbbrevDWOSection() const {
278 return DwarfAbbrevDWOSection;
280 const MCSection *getDwarfStrDWOSection() const {
281 return DwarfStrDWOSection;
283 const MCSection *getDwarfLineDWOSection() const {
284 return DwarfLineDWOSection;
286 const MCSection *getDwarfLocDWOSection() const {
287 return DwarfLocDWOSection;
289 const MCSection *getDwarfStrOffDWOSection() const {
290 return DwarfStrOffDWOSection;
292 const MCSection *getDwarfAddrSection() const {
293 return DwarfAddrSection;
296 const MCSection *getCOFFDebugSymbolsSection() const {
297 return COFFDebugSymbolsSection;
300 const MCSection *getTLSExtraDataSection() const {
301 return TLSExtraDataSection;
303 const MCSection *getTLSDataSection() const { return TLSDataSection; }
304 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
306 const MCSection *getStackMapSection() const { return StackMapSection; }
308 /// ELF specific sections.
310 const MCSection *getDataRelSection() const { return DataRelSection; }
311 const MCSection *getDataRelLocalSection() const {
312 return DataRelLocalSection;
314 const MCSection *getDataRelROSection() const { return DataRelROSection; }
315 const MCSection *getDataRelROLocalSection() const {
316 return DataRelROLocalSection;
318 const MCSection *getMergeableConst4Section() const {
319 return MergeableConst4Section;
321 const MCSection *getMergeableConst8Section() const {
322 return MergeableConst8Section;
324 const MCSection *getMergeableConst16Section() const {
325 return MergeableConst16Section;
328 /// MachO specific sections.
330 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
331 const MCSection *getTLSThreadInitSection() const {
332 return TLSThreadInitSection;
334 const MCSection *getCStringSection() const { return CStringSection; }
335 const MCSection *getUStringSection() const { return UStringSection; }
336 const MCSection *getTextCoalSection() const { return TextCoalSection; }
337 const MCSection *getConstTextCoalSection() const {
338 return ConstTextCoalSection;
340 const MCSection *getConstDataSection() const { return ConstDataSection; }
341 const MCSection *getDataCoalSection() const { return DataCoalSection; }
342 const MCSection *getDataCommonSection() const { return DataCommonSection; }
343 const MCSection *getDataBSSSection() const { return DataBSSSection; }
344 const MCSection *getFourByteConstantSection() const {
345 return FourByteConstantSection;
347 const MCSection *getEightByteConstantSection() const {
348 return EightByteConstantSection;
350 const MCSection *getSixteenByteConstantSection() const {
351 return SixteenByteConstantSection;
353 const MCSection *getLazySymbolPointerSection() const {
354 return LazySymbolPointerSection;
356 const MCSection *getNonLazySymbolPointerSection() const {
357 return NonLazySymbolPointerSection;
360 /// COFF specific sections.
362 const MCSection *getDrectveSection() const { return DrectveSection; }
363 const MCSection *getPDataSection() const { return PDataSection; }
364 const MCSection *getXDataSection() const { return XDataSection; }
366 const MCSection *getEHFrameSection() {
368 InitEHFrameSection();
369 return EHFrameSection;
372 enum Environment { IsMachO, IsELF, IsCOFF };
373 Environment getObjectFileType() const {
377 Reloc::Model getRelocM() const {
384 CodeModel::Model CMModel;
387 void InitMachOMCObjectFileInfo(Triple T);
388 void InitELFMCObjectFileInfo(Triple T);
389 void InitCOFFMCObjectFileInfo(Triple T);
391 /// InitEHFrameSection - Initialize EHFrameSection on demand.
393 void InitEHFrameSection();
396 } // end namespace llvm