Add brief support for the fission .debug_info.dwo section for
[oota-llvm.git] / include / llvm / MC / MCObjectFileInfo.h
1 //===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes common object file formats.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCBJECTFILEINFO_H
15 #define LLVM_MC_MCBJECTFILEINFO_H
16
17 #include "llvm/Support/CodeGen.h"
18
19 namespace llvm {
20   class MCContext;
21   class MCSection;
22   class StringRef;
23   class Triple;
24
25 class MCObjectFileInfo {
26 protected:
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;
31
32   /// SupportsWeakEmptyEHFrame - True if target object file supports a
33   /// weak_definition of constant 0 for an omitted EH frame.
34   bool SupportsWeakOmittedEHFrame;
35
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;
41
42   /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
43   /// encoding values for EH.
44   unsigned PersonalityEncoding;
45   unsigned LSDAEncoding;
46   unsigned FDEEncoding;
47   unsigned FDECFIEncoding;
48   unsigned TTypeEncoding;
49   // Section flags for eh_frame
50   unsigned EHSectionType;
51   unsigned EHSectionFlags;
52
53   /// TextSection - Section directive for standard text.
54   ///
55   const MCSection *TextSection;
56
57   /// DataSection - Section directive for standard data.
58   ///
59   const MCSection *DataSection;
60
61   /// BSSSection - Section that is default initialized to zero.
62   const MCSection *BSSSection;
63
64   /// ReadOnlySection - Section that is readonly and can contain arbitrary
65   /// initialized data.  Targets are not required to have a readonly section.
66   /// If they don't, various bits of code will fall back to using the data
67   /// section for constants.
68   const MCSection *ReadOnlySection;
69
70   /// StaticCtorSection - This section contains the static constructor pointer
71   /// list.
72   const MCSection *StaticCtorSection;
73
74   /// StaticDtorSection - This section contains the static destructor pointer
75   /// list.
76   const MCSection *StaticDtorSection;
77
78   /// LSDASection - If exception handling is supported by the target, this is
79   /// the section the Language Specific Data Area information is emitted to.
80   const MCSection *LSDASection;
81
82   /// CompactUnwindSection - If exception handling is supported by the target
83   /// and the target can support a compact representation of the CIE and FDE,
84   /// this is the section to emit them into.
85   const MCSection *CompactUnwindSection;
86
87   // Dwarf sections for debug info.  If a target supports debug info, these must
88   // be set.
89   const MCSection *DwarfAbbrevSection;
90   const MCSection *DwarfInfoSection;
91   const MCSection *DwarfLineSection;
92   const MCSection *DwarfFrameSection;
93   const MCSection *DwarfPubTypesSection;
94   const MCSection *DwarfDebugInlineSection;
95   const MCSection *DwarfStrSection;
96   const MCSection *DwarfLocSection;
97   const MCSection *DwarfARangesSection;
98   const MCSection *DwarfRangesSection;
99   const MCSection *DwarfMacroInfoSection;
100
101   // DWARF5 Experimental Debug Info Sections
102   /// DwarfAccelNamesSection, DwarfAccelObjCSection,
103   /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
104   /// If we use the DWARF accelerated hash tables then we want to emit these
105   /// sections.
106   const MCSection *DwarfAccelNamesSection;
107   const MCSection *DwarfAccelObjCSection;
108   const MCSection *DwarfAccelNamespaceSection;
109   const MCSection *DwarfAccelTypesSection;
110
111   /// These are used for the Fission separate debug information files.
112   /// DwarfInfoDWOSection
113   const MCSection *DwarfInfoDWOSection;
114
115   // Extra TLS Variable Data section.  If the target needs to put additional
116   // information for a TLS variable, it'll go here.
117   const MCSection *TLSExtraDataSection;
118
119   /// TLSDataSection - Section directive for Thread Local data.
120   /// ELF, MachO and COFF.
121   const MCSection *TLSDataSection;        // Defaults to ".tdata".
122
123   /// TLSBSSSection - Section directive for Thread Local uninitialized data.
124   /// Null if this target doesn't support a BSS section.
125   /// ELF and MachO only.
126   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
127
128
129   /// EHFrameSection - EH frame section. It is initialized on demand so it
130   /// can be overwritten (with uniquing).
131   const MCSection *EHFrameSection;
132
133   /// ELF specific sections.
134   ///
135   const MCSection *DataRelSection;
136   const MCSection *DataRelLocalSection;
137   const MCSection *DataRelROSection;
138   const MCSection *DataRelROLocalSection;
139   const MCSection *MergeableConst4Section;
140   const MCSection *MergeableConst8Section;
141   const MCSection *MergeableConst16Section;
142
143   /// MachO specific sections.
144   ///
145
146   /// TLSTLVSection - Section for thread local structure information.
147   /// Contains the source code name of the variable, visibility and a pointer
148   /// to the initial value (.tdata or .tbss).
149   const MCSection *TLSTLVSection;         // Defaults to ".tlv".
150
151   /// TLSThreadInitSection - Section for thread local data initialization
152   /// functions.
153   const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
154
155   const MCSection *CStringSection;
156   const MCSection *UStringSection;
157   const MCSection *TextCoalSection;
158   const MCSection *ConstTextCoalSection;
159   const MCSection *ConstDataSection;
160   const MCSection *DataCoalSection;
161   const MCSection *DataCommonSection;
162   const MCSection *DataBSSSection;
163   const MCSection *FourByteConstantSection;
164   const MCSection *EightByteConstantSection;
165   const MCSection *SixteenByteConstantSection;
166   const MCSection *LazySymbolPointerSection;
167   const MCSection *NonLazySymbolPointerSection;
168
169   /// COFF specific sections.
170   ///
171   const MCSection *DrectveSection;
172   const MCSection *PDataSection;
173   const MCSection *XDataSection;
174
175 public:
176   void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
177                             MCContext &ctx);
178
179   bool isFunctionEHFrameSymbolPrivate() const {
180     return IsFunctionEHFrameSymbolPrivate;
181   }
182   bool getSupportsWeakOmittedEHFrame() const {
183     return SupportsWeakOmittedEHFrame;
184   }
185   bool getCommDirectiveSupportsAlignment() const {
186     return CommDirectiveSupportsAlignment;
187   }
188
189   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
190   unsigned getLSDAEncoding() const { return LSDAEncoding; }
191   unsigned getFDEEncoding(bool CFI) const {
192     return CFI ? FDECFIEncoding : FDEEncoding;
193   }
194   unsigned getTTypeEncoding() const { return TTypeEncoding; }
195
196   const MCSection *getTextSection() const { return TextSection; }
197   const MCSection *getDataSection() const { return DataSection; }
198   const MCSection *getBSSSection() const { return BSSSection; }
199   const MCSection *getLSDASection() const { return LSDASection; }
200   const MCSection *getCompactUnwindSection() const{
201     return CompactUnwindSection;
202   }
203   const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
204   const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
205   const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
206   const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
207   const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
208   const MCSection *getDwarfDebugInlineSection() const {
209     return DwarfDebugInlineSection;
210   }
211   const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
212   const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
213   const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
214   const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
215   const MCSection *getDwarfMacroInfoSection() const {
216     return DwarfMacroInfoSection;
217   }
218
219   // DWARF5 Experimental Debug Info Sections
220   const MCSection *getDwarfAccelNamesSection() const {
221     return DwarfAccelNamesSection;
222   }
223   const MCSection *getDwarfAccelObjCSection() const {
224     return DwarfAccelObjCSection;
225   }
226   const MCSection *getDwarfAccelNamespaceSection() const {
227     return DwarfAccelNamespaceSection;
228   }
229   const MCSection *getDwarfAccelTypesSection() const {
230     return DwarfAccelTypesSection;
231   }
232   const MCSection *getDwarfInfoDWOSection() const {
233     return DwarfInfoDWOSection;
234   }
235
236   const MCSection *getTLSExtraDataSection() const {
237     return TLSExtraDataSection;
238   }
239   const MCSection *getTLSDataSection() const { return TLSDataSection; }
240   const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
241
242   /// ELF specific sections.
243   ///
244   const MCSection *getDataRelSection() const { return DataRelSection; }
245   const MCSection *getDataRelLocalSection() const {
246     return DataRelLocalSection;
247   }
248   const MCSection *getDataRelROSection() const { return DataRelROSection; }
249   const MCSection *getDataRelROLocalSection() const {
250     return DataRelROLocalSection;
251   }
252   const MCSection *getMergeableConst4Section() const {
253     return MergeableConst4Section;
254   }
255   const MCSection *getMergeableConst8Section() const {
256     return MergeableConst8Section;
257   }
258   const MCSection *getMergeableConst16Section() const {
259     return MergeableConst16Section;
260   }
261
262   /// MachO specific sections.
263   ///
264   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
265   const MCSection *getTLSThreadInitSection() const {
266     return TLSThreadInitSection;
267   }
268   const MCSection *getCStringSection() const { return CStringSection; }
269   const MCSection *getUStringSection() const { return UStringSection; }
270   const MCSection *getTextCoalSection() const { return TextCoalSection; }
271   const MCSection *getConstTextCoalSection() const {
272     return ConstTextCoalSection;
273   }
274   const MCSection *getConstDataSection() const { return ConstDataSection; }
275   const MCSection *getDataCoalSection() const { return DataCoalSection; }
276   const MCSection *getDataCommonSection() const { return DataCommonSection; }
277   const MCSection *getDataBSSSection() const { return DataBSSSection; }
278   const MCSection *getFourByteConstantSection() const {
279     return FourByteConstantSection;
280   }
281   const MCSection *getEightByteConstantSection() const {
282     return EightByteConstantSection;
283   }
284   const MCSection *getSixteenByteConstantSection() const {
285     return SixteenByteConstantSection;
286   }
287   const MCSection *getLazySymbolPointerSection() const {
288     return LazySymbolPointerSection;
289   }
290   const MCSection *getNonLazySymbolPointerSection() const {
291     return NonLazySymbolPointerSection;
292   }
293
294   /// COFF specific sections.
295   ///
296   const MCSection *getDrectveSection() const { return DrectveSection; }
297   const MCSection *getPDataSection() const { return PDataSection; }
298   const MCSection *getXDataSection() const { return XDataSection; }
299
300   const MCSection *getEHFrameSection() {
301     if (!EHFrameSection)
302       InitEHFrameSection();
303     return EHFrameSection;
304   }
305
306 private:
307   enum Environment { IsMachO, IsELF, IsCOFF };
308   Environment Env;
309   Reloc::Model RelocM;
310   CodeModel::Model CMModel;
311   MCContext *Ctx;
312
313   void InitMachOMCObjectFileInfo(Triple T);
314   void InitELFMCObjectFileInfo(Triple T);
315   void InitCOFFMCObjectFileInfo(Triple T);
316
317   /// InitEHFrameSection - Initialize EHFrameSection on demand.
318   ///
319   void InitEHFrameSection();
320 };
321
322 } // end namespace llvm
323
324 #endif