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 *DwarfAbbrevDWOSection;
126 const MCSection *DwarfStrDWOSection;
127 const MCSection *DwarfLineDWOSection;
128 const MCSection *DwarfLocDWOSection;
129 const MCSection *DwarfStrOffDWOSection;
130 const MCSection *DwarfAddrSection;
132 /// Sections for newer gnu pubnames and pubtypes.
133 const MCSection *DwarfGnuPubNamesSection;
134 const MCSection *DwarfGnuPubTypesSection;
136 const MCSection *COFFDebugSymbolsSection;
138 // Extra TLS Variable Data section. If the target needs to put additional
139 // information for a TLS variable, it'll go here.
140 const MCSection *TLSExtraDataSection;
142 /// TLSDataSection - Section directive for Thread Local data.
143 /// ELF, MachO and COFF.
144 const MCSection *TLSDataSection; // Defaults to ".tdata".
146 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
147 /// Null if this target doesn't support a BSS section.
148 /// ELF and MachO only.
149 const MCSection *TLSBSSSection; // Defaults to ".tbss".
151 /// StackMap section.
152 const MCSection *StackMapSection;
154 /// EHFrameSection - EH frame section. It is initialized on demand so it
155 /// can be overwritten (with uniquing).
156 const MCSection *EHFrameSection;
158 /// ELF specific sections.
160 const MCSection *DataRelSection;
161 const MCSection *DataRelLocalSection;
162 const MCSection *DataRelROSection;
163 const MCSection *DataRelROLocalSection;
164 const MCSection *MergeableConst4Section;
165 const MCSection *MergeableConst8Section;
166 const MCSection *MergeableConst16Section;
168 /// MachO specific sections.
171 /// TLSTLVSection - Section for thread local structure information.
172 /// Contains the source code name of the variable, visibility and a pointer
173 /// to the initial value (.tdata or .tbss).
174 const MCSection *TLSTLVSection; // Defaults to ".tlv".
176 /// TLSThreadInitSection - Section for thread local data initialization
178 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
180 const MCSection *CStringSection;
181 const MCSection *UStringSection;
182 const MCSection *TextCoalSection;
183 const MCSection *ConstTextCoalSection;
184 const MCSection *ConstDataSection;
185 const MCSection *DataCoalSection;
186 const MCSection *DataCommonSection;
187 const MCSection *DataBSSSection;
188 const MCSection *FourByteConstantSection;
189 const MCSection *EightByteConstantSection;
190 const MCSection *SixteenByteConstantSection;
191 const MCSection *LazySymbolPointerSection;
192 const MCSection *NonLazySymbolPointerSection;
194 /// COFF specific sections.
196 const MCSection *DrectveSection;
197 const MCSection *PDataSection;
198 const MCSection *XDataSection;
201 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
204 bool isFunctionEHFrameSymbolPrivate() const {
205 return IsFunctionEHFrameSymbolPrivate;
207 bool getSupportsWeakOmittedEHFrame() const {
208 return SupportsWeakOmittedEHFrame;
210 bool getSupportsCompactUnwindWithoutEHFrame() const {
211 return SupportsCompactUnwindWithoutEHFrame;
213 bool getCommDirectiveSupportsAlignment() const {
214 return CommDirectiveSupportsAlignment;
217 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
218 unsigned getLSDAEncoding() const { return LSDAEncoding; }
219 unsigned getFDEEncoding() const { return FDECFIEncoding; }
220 unsigned getTTypeEncoding() const { return TTypeEncoding; }
222 unsigned getCompactUnwindDwarfEHFrameOnly() const {
223 return CompactUnwindDwarfEHFrameOnly;
226 const MCSection *getTextSection() const { return TextSection; }
227 const MCSection *getDataSection() const { return DataSection; }
228 const MCSection *getBSSSection() const { return BSSSection; }
229 const MCSection *getLSDASection() const { return LSDASection; }
230 const MCSection *getCompactUnwindSection() const{
231 return CompactUnwindSection;
233 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
234 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
235 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
236 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
237 const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
238 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
239 const MCSection *getDwarfGnuPubNamesSection() const {
240 return DwarfGnuPubNamesSection;
242 const MCSection *getDwarfGnuPubTypesSection() const {
243 return DwarfGnuPubTypesSection;
245 const MCSection *getDwarfDebugInlineSection() const {
246 return DwarfDebugInlineSection;
248 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
249 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
250 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
251 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
252 const MCSection *getDwarfMacroInfoSection() const {
253 return DwarfMacroInfoSection;
256 // DWARF5 Experimental Debug Info Sections
257 const MCSection *getDwarfAccelNamesSection() const {
258 return DwarfAccelNamesSection;
260 const MCSection *getDwarfAccelObjCSection() const {
261 return DwarfAccelObjCSection;
263 const MCSection *getDwarfAccelNamespaceSection() const {
264 return DwarfAccelNamespaceSection;
266 const MCSection *getDwarfAccelTypesSection() const {
267 return DwarfAccelTypesSection;
269 const MCSection *getDwarfInfoDWOSection() const {
270 return DwarfInfoDWOSection;
272 const MCSection *getDwarfTypesSection(uint64_t Hash) const;
273 const MCSection *getDwarfTypesDWOSection(uint64_t Hash) const;
274 const MCSection *getDwarfAbbrevDWOSection() const {
275 return DwarfAbbrevDWOSection;
277 const MCSection *getDwarfStrDWOSection() const {
278 return DwarfStrDWOSection;
280 const MCSection *getDwarfLineDWOSection() const {
281 return DwarfLineDWOSection;
283 const MCSection *getDwarfLocDWOSection() const {
284 return DwarfLocDWOSection;
286 const MCSection *getDwarfStrOffDWOSection() const {
287 return DwarfStrOffDWOSection;
289 const MCSection *getDwarfAddrSection() const {
290 return DwarfAddrSection;
293 const MCSection *getCOFFDebugSymbolsSection() const {
294 return COFFDebugSymbolsSection;
297 const MCSection *getTLSExtraDataSection() const {
298 return TLSExtraDataSection;
300 const MCSection *getTLSDataSection() const { return TLSDataSection; }
301 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
303 const MCSection *getStackMapSection() const { return StackMapSection; }
305 /// ELF specific sections.
307 const MCSection *getDataRelSection() const { return DataRelSection; }
308 const MCSection *getDataRelLocalSection() const {
309 return DataRelLocalSection;
311 const MCSection *getDataRelROSection() const { return DataRelROSection; }
312 const MCSection *getDataRelROLocalSection() const {
313 return DataRelROLocalSection;
315 const MCSection *getMergeableConst4Section() const {
316 return MergeableConst4Section;
318 const MCSection *getMergeableConst8Section() const {
319 return MergeableConst8Section;
321 const MCSection *getMergeableConst16Section() const {
322 return MergeableConst16Section;
325 /// MachO specific sections.
327 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
328 const MCSection *getTLSThreadInitSection() const {
329 return TLSThreadInitSection;
331 const MCSection *getCStringSection() const { return CStringSection; }
332 const MCSection *getUStringSection() const { return UStringSection; }
333 const MCSection *getTextCoalSection() const { return TextCoalSection; }
334 const MCSection *getConstTextCoalSection() const {
335 return ConstTextCoalSection;
337 const MCSection *getConstDataSection() const { return ConstDataSection; }
338 const MCSection *getDataCoalSection() const { return DataCoalSection; }
339 const MCSection *getDataCommonSection() const { return DataCommonSection; }
340 const MCSection *getDataBSSSection() const { return DataBSSSection; }
341 const MCSection *getFourByteConstantSection() const {
342 return FourByteConstantSection;
344 const MCSection *getEightByteConstantSection() const {
345 return EightByteConstantSection;
347 const MCSection *getSixteenByteConstantSection() const {
348 return SixteenByteConstantSection;
350 const MCSection *getLazySymbolPointerSection() const {
351 return LazySymbolPointerSection;
353 const MCSection *getNonLazySymbolPointerSection() const {
354 return NonLazySymbolPointerSection;
357 /// COFF specific sections.
359 const MCSection *getDrectveSection() const { return DrectveSection; }
360 const MCSection *getPDataSection() const { return PDataSection; }
361 const MCSection *getXDataSection() const { return XDataSection; }
363 const MCSection *getEHFrameSection() {
365 InitEHFrameSection();
366 return EHFrameSection;
369 enum Environment { IsMachO, IsELF, IsCOFF };
370 Environment getObjectFileType() const {
374 Reloc::Model getRelocM() const {
381 CodeModel::Model CMModel;
384 void InitMachOMCObjectFileInfo(Triple T);
385 void InitELFMCObjectFileInfo(Triple T);
386 void InitCOFFMCObjectFileInfo(Triple T);
388 /// InitEHFrameSection - Initialize EHFrameSection on demand.
390 void InitEHFrameSection();
393 } // end namespace llvm