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 // Extra TLS Variable Data section. If the target needs to put additional
133 // information for a TLS variable, it'll go here.
134 const MCSection *TLSExtraDataSection;
136 /// TLSDataSection - Section directive for Thread Local data.
137 /// ELF, MachO and COFF.
138 const MCSection *TLSDataSection; // Defaults to ".tdata".
140 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
141 /// Null if this target doesn't support a BSS section.
142 /// ELF and MachO only.
143 const MCSection *TLSBSSSection; // Defaults to ".tbss".
146 /// EHFrameSection - EH frame section. It is initialized on demand so it
147 /// can be overwritten (with uniquing).
148 const MCSection *EHFrameSection;
150 /// ELF specific sections.
152 const MCSection *DataRelSection;
153 const MCSection *DataRelLocalSection;
154 const MCSection *DataRelROSection;
155 const MCSection *DataRelROLocalSection;
156 const MCSection *MergeableConst4Section;
157 const MCSection *MergeableConst8Section;
158 const MCSection *MergeableConst16Section;
160 /// MachO specific sections.
163 /// TLSTLVSection - Section for thread local structure information.
164 /// Contains the source code name of the variable, visibility and a pointer
165 /// to the initial value (.tdata or .tbss).
166 const MCSection *TLSTLVSection; // Defaults to ".tlv".
168 /// TLSThreadInitSection - Section for thread local data initialization
170 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
172 const MCSection *CStringSection;
173 const MCSection *UStringSection;
174 const MCSection *TextCoalSection;
175 const MCSection *ConstTextCoalSection;
176 const MCSection *ConstDataSection;
177 const MCSection *DataCoalSection;
178 const MCSection *DataCommonSection;
179 const MCSection *DataBSSSection;
180 const MCSection *FourByteConstantSection;
181 const MCSection *EightByteConstantSection;
182 const MCSection *SixteenByteConstantSection;
183 const MCSection *LazySymbolPointerSection;
184 const MCSection *NonLazySymbolPointerSection;
186 /// COFF specific sections.
188 const MCSection *DrectveSection;
189 const MCSection *PDataSection;
190 const MCSection *XDataSection;
193 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
196 bool isFunctionEHFrameSymbolPrivate() const {
197 return IsFunctionEHFrameSymbolPrivate;
199 bool getSupportsWeakOmittedEHFrame() const {
200 return SupportsWeakOmittedEHFrame;
202 bool getCommDirectiveSupportsAlignment() const {
203 return CommDirectiveSupportsAlignment;
206 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
207 unsigned getLSDAEncoding() const { return LSDAEncoding; }
208 unsigned getFDEEncoding(bool CFI) const {
209 return CFI ? FDECFIEncoding : FDEEncoding;
211 unsigned getTTypeEncoding() const { return TTypeEncoding; }
213 unsigned getCompactUnwindDwarfEHFrameOnly() const {
214 return CompactUnwindDwarfEHFrameOnly;
217 const MCSection *getTextSection() const { return TextSection; }
218 const MCSection *getDataSection() const { return DataSection; }
219 const MCSection *getBSSSection() const { return BSSSection; }
220 const MCSection *getLSDASection() const { return LSDASection; }
221 const MCSection *getCompactUnwindSection() const{
222 return CompactUnwindSection;
224 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
225 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
226 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
227 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
228 const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;}
229 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
230 const MCSection *getDwarfGnuPubNamesSection() const {
231 return DwarfGnuPubNamesSection;
233 const MCSection *getDwarfGnuPubTypesSection() const {
234 return DwarfGnuPubTypesSection;
236 const MCSection *getDwarfDebugInlineSection() const {
237 return DwarfDebugInlineSection;
239 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
240 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
241 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
242 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
243 const MCSection *getDwarfMacroInfoSection() const {
244 return DwarfMacroInfoSection;
247 // DWARF5 Experimental Debug Info Sections
248 const MCSection *getDwarfAccelNamesSection() const {
249 return DwarfAccelNamesSection;
251 const MCSection *getDwarfAccelObjCSection() const {
252 return DwarfAccelObjCSection;
254 const MCSection *getDwarfAccelNamespaceSection() const {
255 return DwarfAccelNamespaceSection;
257 const MCSection *getDwarfAccelTypesSection() const {
258 return DwarfAccelTypesSection;
260 const MCSection *getDwarfInfoDWOSection() const {
261 return DwarfInfoDWOSection;
263 const MCSection *getDwarfAbbrevDWOSection() const {
264 return DwarfAbbrevDWOSection;
266 const MCSection *getDwarfStrDWOSection() const {
267 return DwarfStrDWOSection;
269 const MCSection *getDwarfLineDWOSection() const {
270 return DwarfLineDWOSection;
272 const MCSection *getDwarfLocDWOSection() const {
273 return DwarfLocDWOSection;
275 const MCSection *getDwarfStrOffDWOSection() const {
276 return DwarfStrOffDWOSection;
278 const MCSection *getDwarfAddrSection() const {
279 return DwarfAddrSection;
282 const MCSection *getTLSExtraDataSection() const {
283 return TLSExtraDataSection;
285 const MCSection *getTLSDataSection() const { return TLSDataSection; }
286 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
288 /// ELF specific sections.
290 const MCSection *getDataRelSection() const { return DataRelSection; }
291 const MCSection *getDataRelLocalSection() const {
292 return DataRelLocalSection;
294 const MCSection *getDataRelROSection() const { return DataRelROSection; }
295 const MCSection *getDataRelROLocalSection() const {
296 return DataRelROLocalSection;
298 const MCSection *getMergeableConst4Section() const {
299 return MergeableConst4Section;
301 const MCSection *getMergeableConst8Section() const {
302 return MergeableConst8Section;
304 const MCSection *getMergeableConst16Section() const {
305 return MergeableConst16Section;
308 /// MachO specific sections.
310 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
311 const MCSection *getTLSThreadInitSection() const {
312 return TLSThreadInitSection;
314 const MCSection *getCStringSection() const { return CStringSection; }
315 const MCSection *getUStringSection() const { return UStringSection; }
316 const MCSection *getTextCoalSection() const { return TextCoalSection; }
317 const MCSection *getConstTextCoalSection() const {
318 return ConstTextCoalSection;
320 const MCSection *getConstDataSection() const { return ConstDataSection; }
321 const MCSection *getDataCoalSection() const { return DataCoalSection; }
322 const MCSection *getDataCommonSection() const { return DataCommonSection; }
323 const MCSection *getDataBSSSection() const { return DataBSSSection; }
324 const MCSection *getFourByteConstantSection() const {
325 return FourByteConstantSection;
327 const MCSection *getEightByteConstantSection() const {
328 return EightByteConstantSection;
330 const MCSection *getSixteenByteConstantSection() const {
331 return SixteenByteConstantSection;
333 const MCSection *getLazySymbolPointerSection() const {
334 return LazySymbolPointerSection;
336 const MCSection *getNonLazySymbolPointerSection() const {
337 return NonLazySymbolPointerSection;
340 /// COFF specific sections.
342 const MCSection *getDrectveSection() const { return DrectveSection; }
343 const MCSection *getPDataSection() const { return PDataSection; }
344 const MCSection *getXDataSection() const { return XDataSection; }
346 const MCSection *getEHFrameSection() {
348 InitEHFrameSection();
349 return EHFrameSection;
353 enum Environment { IsMachO, IsELF, IsCOFF };
356 CodeModel::Model CMModel;
359 void InitMachOMCObjectFileInfo(Triple T);
360 void InitELFMCObjectFileInfo(Triple T);
361 void InitCOFFMCObjectFileInfo(Triple T);
363 /// InitEHFrameSection - Initialize EHFrameSection on demand.
365 void InitEHFrameSection();
368 } // end namespace llvm