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 /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
43 /// encoding values for EH.
44 unsigned PersonalityEncoding;
45 unsigned LSDAEncoding;
47 unsigned FDECFIEncoding;
48 unsigned TTypeEncoding;
50 /// Section flags for eh_frame
51 unsigned EHSectionType;
52 unsigned EHSectionFlags;
54 /// CompactUnwindDwarfEHFrameOnly - Compact unwind encoding indicating that we
55 /// should emit only an EH frame.
56 unsigned CompactUnwindDwarfEHFrameOnly;
58 /// TextSection - Section directive for standard text.
60 const MCSection *TextSection;
62 /// DataSection - Section directive for standard data.
64 const MCSection *DataSection;
66 /// BSSSection - Section that is default initialized to zero.
67 const MCSection *BSSSection;
69 /// ReadOnlySection - Section that is readonly and can contain arbitrary
70 /// initialized data. Targets are not required to have a readonly section.
71 /// If they don't, various bits of code will fall back to using the data
72 /// section for constants.
73 const MCSection *ReadOnlySection;
75 /// StaticCtorSection - This section contains the static constructor pointer
77 const MCSection *StaticCtorSection;
79 /// StaticDtorSection - This section contains the static destructor pointer
81 const MCSection *StaticDtorSection;
83 /// LSDASection - If exception handling is supported by the target, this is
84 /// the section the Language Specific Data Area information is emitted to.
85 const MCSection *LSDASection;
87 /// CompactUnwindSection - If exception handling is supported by the target
88 /// and the target can support a compact representation of the CIE and FDE,
89 /// this is the section to emit them into.
90 const MCSection *CompactUnwindSection;
92 // Dwarf sections for debug info. If a target supports debug info, these must
94 const MCSection *DwarfAbbrevSection;
95 const MCSection *DwarfInfoSection;
96 const MCSection *DwarfLineSection;
97 const MCSection *DwarfFrameSection;
98 const MCSection *DwarfPubTypesSection;
99 const MCSection *DwarfDebugInlineSection;
100 const MCSection *DwarfStrSection;
101 const MCSection *DwarfLocSection;
102 const MCSection *DwarfARangesSection;
103 const MCSection *DwarfRangesSection;
104 const MCSection *DwarfMacroInfoSection;
105 // The pubnames section is no longer generated by default. The generation
106 // can be enabled by a compiler flag.
107 const MCSection *DwarfPubNamesSection;
109 // DWARF5 Experimental Debug Info Sections
110 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
111 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
112 /// If we use the DWARF accelerated hash tables then we want to emit these
114 const MCSection *DwarfAccelNamesSection;
115 const MCSection *DwarfAccelObjCSection;
116 const MCSection *DwarfAccelNamespaceSection;
117 const MCSection *DwarfAccelTypesSection;
119 /// These are used for the Fission separate debug information files.
120 const MCSection *DwarfInfoDWOSection;
121 const MCSection *DwarfAbbrevDWOSection;
122 const MCSection *DwarfStrDWOSection;
123 const MCSection *DwarfLineDWOSection;
124 const MCSection *DwarfLocDWOSection;
125 const MCSection *DwarfStrOffDWOSection;
126 const MCSection *DwarfAddrSection;
128 /// Sections for newer gnu pubnames and pubtypes.
129 const MCSection *DwarfGnuPubNamesSection;
130 const MCSection *DwarfGnuPubTypesSection;
132 const MCSection *COFFDebugSymbolsSection;
134 // Extra TLS Variable Data section. If the target needs to put additional
135 // information for a TLS variable, it'll go here.
136 const MCSection *TLSExtraDataSection;
138 /// TLSDataSection - Section directive for Thread Local data.
139 /// ELF, MachO and COFF.
140 const MCSection *TLSDataSection; // Defaults to ".tdata".
142 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
143 /// Null if this target doesn't support a BSS section.
144 /// ELF and MachO only.
145 const MCSection *TLSBSSSection; // Defaults to ".tbss".
147 /// StackMap section.
148 const MCSection *StackMapSection;
150 /// EHFrameSection - EH frame section. It is initialized on demand so it
151 /// can be overwritten (with uniquing).
152 const MCSection *EHFrameSection;
154 /// ELF specific sections.
156 const MCSection *DataRelSection;
157 const MCSection *DataRelLocalSection;
158 const MCSection *DataRelROSection;
159 const MCSection *DataRelROLocalSection;
160 const MCSection *MergeableConst4Section;
161 const MCSection *MergeableConst8Section;
162 const MCSection *MergeableConst16Section;
164 /// MachO specific sections.
167 /// TLSTLVSection - Section for thread local structure information.
168 /// Contains the source code name of the variable, visibility and a pointer
169 /// to the initial value (.tdata or .tbss).
170 const MCSection *TLSTLVSection; // Defaults to ".tlv".
172 /// TLSThreadInitSection - Section for thread local data initialization
174 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
176 const MCSection *CStringSection;
177 const MCSection *UStringSection;
178 const MCSection *TextCoalSection;
179 const MCSection *ConstTextCoalSection;
180 const MCSection *ConstDataSection;
181 const MCSection *DataCoalSection;
182 const MCSection *DataCommonSection;
183 const MCSection *DataBSSSection;
184 const MCSection *FourByteConstantSection;
185 const MCSection *EightByteConstantSection;
186 const MCSection *SixteenByteConstantSection;
187 const MCSection *LazySymbolPointerSection;
188 const MCSection *NonLazySymbolPointerSection;
190 /// COFF specific sections.
192 const MCSection *DrectveSection;
193 const MCSection *PDataSection;
194 const MCSection *XDataSection;
197 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
200 bool isFunctionEHFrameSymbolPrivate() const {
201 return IsFunctionEHFrameSymbolPrivate;
203 bool getSupportsWeakOmittedEHFrame() const {
204 return SupportsWeakOmittedEHFrame;
206 bool getCommDirectiveSupportsAlignment() const {
207 return CommDirectiveSupportsAlignment;
210 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
211 unsigned getLSDAEncoding() const { return LSDAEncoding; }
212 unsigned getFDEEncoding(bool CFI) const {
213 return CFI ? FDECFIEncoding : FDEEncoding;
215 unsigned getTTypeEncoding() const { return TTypeEncoding; }
217 unsigned getCompactUnwindDwarfEHFrameOnly() const {
218 return CompactUnwindDwarfEHFrameOnly;
221 const MCSection *getTextSection() const { return TextSection; }
222 const MCSection *getDataSection() const { return DataSection; }
223 const MCSection *getBSSSection() const { return BSSSection; }
224 const MCSection *getLSDASection() const { return LSDASection; }
225 const MCSection *getCompactUnwindSection() const{
226 return CompactUnwindSection;
228 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
229 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
230 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
231 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
232 const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
233 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
234 const MCSection *getDwarfGnuPubNamesSection() const {
235 return DwarfGnuPubNamesSection;
237 const MCSection *getDwarfGnuPubTypesSection() const {
238 return DwarfGnuPubTypesSection;
240 const MCSection *getDwarfDebugInlineSection() const {
241 return DwarfDebugInlineSection;
243 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
244 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
245 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
246 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
247 const MCSection *getDwarfMacroInfoSection() const {
248 return DwarfMacroInfoSection;
251 // DWARF5 Experimental Debug Info Sections
252 const MCSection *getDwarfAccelNamesSection() const {
253 return DwarfAccelNamesSection;
255 const MCSection *getDwarfAccelObjCSection() const {
256 return DwarfAccelObjCSection;
258 const MCSection *getDwarfAccelNamespaceSection() const {
259 return DwarfAccelNamespaceSection;
261 const MCSection *getDwarfAccelTypesSection() const {
262 return DwarfAccelTypesSection;
264 const MCSection *getDwarfInfoDWOSection() const {
265 return DwarfInfoDWOSection;
267 const MCSection *getDwarfTypesSection(uint64_t Hash) const;
268 const MCSection *getDwarfTypesDWOSection(uint64_t Hash) const;
269 const MCSection *getDwarfAbbrevDWOSection() const {
270 return DwarfAbbrevDWOSection;
272 const MCSection *getDwarfStrDWOSection() const {
273 return DwarfStrDWOSection;
275 const MCSection *getDwarfLineDWOSection() const {
276 return DwarfLineDWOSection;
278 const MCSection *getDwarfLocDWOSection() const {
279 return DwarfLocDWOSection;
281 const MCSection *getDwarfStrOffDWOSection() const {
282 return DwarfStrOffDWOSection;
284 const MCSection *getDwarfAddrSection() const {
285 return DwarfAddrSection;
288 const MCSection *getCOFFDebugSymbolsSection() const {
289 return COFFDebugSymbolsSection;
292 const MCSection *getTLSExtraDataSection() const {
293 return TLSExtraDataSection;
295 const MCSection *getTLSDataSection() const { return TLSDataSection; }
296 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
298 const MCSection *getStackMapSection() const { return StackMapSection; }
300 /// ELF specific sections.
302 const MCSection *getDataRelSection() const { return DataRelSection; }
303 const MCSection *getDataRelLocalSection() const {
304 return DataRelLocalSection;
306 const MCSection *getDataRelROSection() const { return DataRelROSection; }
307 const MCSection *getDataRelROLocalSection() const {
308 return DataRelROLocalSection;
310 const MCSection *getMergeableConst4Section() const {
311 return MergeableConst4Section;
313 const MCSection *getMergeableConst8Section() const {
314 return MergeableConst8Section;
316 const MCSection *getMergeableConst16Section() const {
317 return MergeableConst16Section;
320 /// MachO specific sections.
322 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
323 const MCSection *getTLSThreadInitSection() const {
324 return TLSThreadInitSection;
326 const MCSection *getCStringSection() const { return CStringSection; }
327 const MCSection *getUStringSection() const { return UStringSection; }
328 const MCSection *getTextCoalSection() const { return TextCoalSection; }
329 const MCSection *getConstTextCoalSection() const {
330 return ConstTextCoalSection;
332 const MCSection *getConstDataSection() const { return ConstDataSection; }
333 const MCSection *getDataCoalSection() const { return DataCoalSection; }
334 const MCSection *getDataCommonSection() const { return DataCommonSection; }
335 const MCSection *getDataBSSSection() const { return DataBSSSection; }
336 const MCSection *getFourByteConstantSection() const {
337 return FourByteConstantSection;
339 const MCSection *getEightByteConstantSection() const {
340 return EightByteConstantSection;
342 const MCSection *getSixteenByteConstantSection() const {
343 return SixteenByteConstantSection;
345 const MCSection *getLazySymbolPointerSection() const {
346 return LazySymbolPointerSection;
348 const MCSection *getNonLazySymbolPointerSection() const {
349 return NonLazySymbolPointerSection;
352 /// COFF specific sections.
354 const MCSection *getDrectveSection() const { return DrectveSection; }
355 const MCSection *getPDataSection() const { return PDataSection; }
356 const MCSection *getXDataSection() const { return XDataSection; }
358 const MCSection *getEHFrameSection() {
360 InitEHFrameSection();
361 return EHFrameSection;
364 enum Environment { IsMachO, IsELF, IsCOFF };
365 Environment getObjectFileType() const {
372 CodeModel::Model CMModel;
375 void InitMachOMCObjectFileInfo(Triple T);
376 void InitELFMCObjectFileInfo(Triple T);
377 void InitCOFFMCObjectFileInfo(Triple T);
379 /// InitEHFrameSection - Initialize EHFrameSection on demand.
381 void InitEHFrameSection();
384 } // end namespace llvm