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 // Extra TLS Variable Data section. If the target needs to put additional
129 // information for a TLS variable, it'll go here.
130 const MCSection *TLSExtraDataSection;
132 /// TLSDataSection - Section directive for Thread Local data.
133 /// ELF, MachO and COFF.
134 const MCSection *TLSDataSection; // Defaults to ".tdata".
136 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
137 /// Null if this target doesn't support a BSS section.
138 /// ELF and MachO only.
139 const MCSection *TLSBSSSection; // Defaults to ".tbss".
142 /// EHFrameSection - EH frame section. It is initialized on demand so it
143 /// can be overwritten (with uniquing).
144 const MCSection *EHFrameSection;
146 /// ELF specific sections.
148 const MCSection *DataRelSection;
149 const MCSection *DataRelLocalSection;
150 const MCSection *DataRelROSection;
151 const MCSection *DataRelROLocalSection;
152 const MCSection *MergeableConst4Section;
153 const MCSection *MergeableConst8Section;
154 const MCSection *MergeableConst16Section;
156 /// MachO specific sections.
159 /// TLSTLVSection - Section for thread local structure information.
160 /// Contains the source code name of the variable, visibility and a pointer
161 /// to the initial value (.tdata or .tbss).
162 const MCSection *TLSTLVSection; // Defaults to ".tlv".
164 /// TLSThreadInitSection - Section for thread local data initialization
166 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
168 const MCSection *CStringSection;
169 const MCSection *UStringSection;
170 const MCSection *TextCoalSection;
171 const MCSection *ConstTextCoalSection;
172 const MCSection *ConstDataSection;
173 const MCSection *DataCoalSection;
174 const MCSection *DataCommonSection;
175 const MCSection *DataBSSSection;
176 const MCSection *FourByteConstantSection;
177 const MCSection *EightByteConstantSection;
178 const MCSection *SixteenByteConstantSection;
179 const MCSection *LazySymbolPointerSection;
180 const MCSection *NonLazySymbolPointerSection;
182 /// COFF specific sections.
184 const MCSection *DrectveSection;
185 const MCSection *PDataSection;
186 const MCSection *XDataSection;
189 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
192 bool isFunctionEHFrameSymbolPrivate() const {
193 return IsFunctionEHFrameSymbolPrivate;
195 bool getSupportsWeakOmittedEHFrame() const {
196 return SupportsWeakOmittedEHFrame;
198 bool getCommDirectiveSupportsAlignment() const {
199 return CommDirectiveSupportsAlignment;
202 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
203 unsigned getLSDAEncoding() const { return LSDAEncoding; }
204 unsigned getFDEEncoding(bool CFI) const {
205 return CFI ? FDECFIEncoding : FDEEncoding;
207 unsigned getTTypeEncoding() const { return TTypeEncoding; }
209 unsigned getCompactUnwindDwarfEHFrameOnly() const {
210 return CompactUnwindDwarfEHFrameOnly;
213 const MCSection *getTextSection() const { return TextSection; }
214 const MCSection *getDataSection() const { return DataSection; }
215 const MCSection *getBSSSection() const { return BSSSection; }
216 const MCSection *getLSDASection() const { return LSDASection; }
217 const MCSection *getCompactUnwindSection() const{
218 return CompactUnwindSection;
220 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
221 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
222 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
223 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
224 const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
225 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
226 const MCSection *getDwarfDebugInlineSection() const {
227 return DwarfDebugInlineSection;
229 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
230 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
231 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
232 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
233 const MCSection *getDwarfMacroInfoSection() const {
234 return DwarfMacroInfoSection;
237 // DWARF5 Experimental Debug Info Sections
238 const MCSection *getDwarfAccelNamesSection() const {
239 return DwarfAccelNamesSection;
241 const MCSection *getDwarfAccelObjCSection() const {
242 return DwarfAccelObjCSection;
244 const MCSection *getDwarfAccelNamespaceSection() const {
245 return DwarfAccelNamespaceSection;
247 const MCSection *getDwarfAccelTypesSection() const {
248 return DwarfAccelTypesSection;
250 const MCSection *getDwarfInfoDWOSection() const {
251 return DwarfInfoDWOSection;
253 const MCSection *getDwarfAbbrevDWOSection() const {
254 return DwarfAbbrevDWOSection;
256 const MCSection *getDwarfStrDWOSection() const {
257 return DwarfStrDWOSection;
259 const MCSection *getDwarfLineDWOSection() const {
260 return DwarfLineDWOSection;
262 const MCSection *getDwarfLocDWOSection() const {
263 return DwarfLocDWOSection;
265 const MCSection *getDwarfStrOffDWOSection() const {
266 return DwarfStrOffDWOSection;
268 const MCSection *getDwarfAddrSection() const {
269 return DwarfAddrSection;
272 const MCSection *getTLSExtraDataSection() const {
273 return TLSExtraDataSection;
275 const MCSection *getTLSDataSection() const { return TLSDataSection; }
276 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
278 /// ELF specific sections.
280 const MCSection *getDataRelSection() const { return DataRelSection; }
281 const MCSection *getDataRelLocalSection() const {
282 return DataRelLocalSection;
284 const MCSection *getDataRelROSection() const { return DataRelROSection; }
285 const MCSection *getDataRelROLocalSection() const {
286 return DataRelROLocalSection;
288 const MCSection *getMergeableConst4Section() const {
289 return MergeableConst4Section;
291 const MCSection *getMergeableConst8Section() const {
292 return MergeableConst8Section;
294 const MCSection *getMergeableConst16Section() const {
295 return MergeableConst16Section;
298 /// MachO specific sections.
300 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
301 const MCSection *getTLSThreadInitSection() const {
302 return TLSThreadInitSection;
304 const MCSection *getCStringSection() const { return CStringSection; }
305 const MCSection *getUStringSection() const { return UStringSection; }
306 const MCSection *getTextCoalSection() const { return TextCoalSection; }
307 const MCSection *getConstTextCoalSection() const {
308 return ConstTextCoalSection;
310 const MCSection *getConstDataSection() const { return ConstDataSection; }
311 const MCSection *getDataCoalSection() const { return DataCoalSection; }
312 const MCSection *getDataCommonSection() const { return DataCommonSection; }
313 const MCSection *getDataBSSSection() const { return DataBSSSection; }
314 const MCSection *getFourByteConstantSection() const {
315 return FourByteConstantSection;
317 const MCSection *getEightByteConstantSection() const {
318 return EightByteConstantSection;
320 const MCSection *getSixteenByteConstantSection() const {
321 return SixteenByteConstantSection;
323 const MCSection *getLazySymbolPointerSection() const {
324 return LazySymbolPointerSection;
326 const MCSection *getNonLazySymbolPointerSection() const {
327 return NonLazySymbolPointerSection;
330 /// COFF specific sections.
332 const MCSection *getDrectveSection() const { return DrectveSection; }
333 const MCSection *getPDataSection() const { return PDataSection; }
334 const MCSection *getXDataSection() const { return XDataSection; }
336 const MCSection *getEHFrameSection() {
338 InitEHFrameSection();
339 return EHFrameSection;
343 enum Environment { IsMachO, IsELF, IsCOFF };
346 CodeModel::Model CMModel;
349 void InitMachOMCObjectFileInfo(Triple T);
350 void InitELFMCObjectFileInfo(Triple T);
351 void InitCOFFMCObjectFileInfo(Triple T);
353 /// InitEHFrameSection - Initialize EHFrameSection on demand.
355 void InitEHFrameSection();
358 } // end namespace llvm