Fix warning introduced in r238190 about lack of virtual destructor in MCObjectFileInfo.
[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_MCOBJECTFILEINFO_H
15 #define LLVM_MC_MCOBJECTFILEINFO_H
16
17 #include "llvm/ADT/Triple.h"
18 #include "llvm/Support/CodeGen.h"
19
20 namespace llvm {
21   class MCContext;
22   class MCSection;
23   class StringRef;
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   /// SupportsCompactUnwindWithoutEHFrame - True if the target object file
37   /// supports emitting a compact unwind section without an associated EH frame
38   /// section.
39   bool SupportsCompactUnwindWithoutEHFrame;
40
41   /// PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values
42   /// for EH.
43   unsigned PersonalityEncoding;
44   unsigned LSDAEncoding;
45   unsigned FDECFIEncoding;
46   unsigned TTypeEncoding;
47
48   /// Section flags for eh_frame
49   unsigned EHSectionType;
50   unsigned EHSectionFlags;
51
52   /// CompactUnwindDwarfEHFrameOnly - Compact unwind encoding indicating that we
53   /// should emit only an EH frame.
54   unsigned CompactUnwindDwarfEHFrameOnly;
55
56   /// Section directive for standard text.
57   ///
58   MCSection *TextSection;
59
60   /// Section directive for standard data.
61   ///
62   MCSection *DataSection;
63
64   /// Section that is default initialized to zero.
65   MCSection *BSSSection;
66
67   /// Section that is readonly and can contain arbitrary initialized data.
68   /// Targets are not required to have a readonly section. If they don't,
69   /// various bits of code will fall back to using the data section for
70   /// constants.
71   MCSection *ReadOnlySection;
72
73   /// This section contains the static constructor pointer list.
74   MCSection *StaticCtorSection;
75
76   /// This section contains the static destructor pointer list.
77   MCSection *StaticDtorSection;
78
79   /// If exception handling is supported by the target, this is the section the
80   /// Language Specific Data Area information is emitted to.
81   MCSection *LSDASection;
82
83   /// If exception handling is supported by the target and the target can
84   /// support a compact representation of the CIE and FDE, this is the section
85   /// to emit them into.
86   MCSection *CompactUnwindSection;
87
88   // Dwarf sections for debug info.  If a target supports debug info, these must
89   // be set.
90   MCSection *DwarfAbbrevSection;
91   MCSection *DwarfInfoSection;
92   MCSection *DwarfLineSection;
93   MCSection *DwarfFrameSection;
94   MCSection *DwarfPubTypesSection;
95   const MCSection *DwarfDebugInlineSection;
96   MCSection *DwarfStrSection;
97   MCSection *DwarfLocSection;
98   MCSection *DwarfARangesSection;
99   MCSection *DwarfRangesSection;
100   // The pubnames section is no longer generated by default.  The generation
101   // can be enabled by a compiler flag.
102   MCSection *DwarfPubNamesSection;
103
104   // DWARF5 Experimental Debug Info Sections
105   /// DwarfAccelNamesSection, DwarfAccelObjCSection,
106   /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
107   /// If we use the DWARF accelerated hash tables then we want to emit these
108   /// sections.
109   MCSection *DwarfAccelNamesSection;
110   MCSection *DwarfAccelObjCSection;
111   MCSection *DwarfAccelNamespaceSection;
112   MCSection *DwarfAccelTypesSection;
113
114   /// These are used for the Fission separate debug information files.
115   MCSection *DwarfInfoDWOSection;
116   MCSection *DwarfTypesDWOSection;
117   MCSection *DwarfAbbrevDWOSection;
118   MCSection *DwarfStrDWOSection;
119   MCSection *DwarfLineDWOSection;
120   MCSection *DwarfLocDWOSection;
121   MCSection *DwarfStrOffDWOSection;
122   MCSection *DwarfAddrSection;
123
124   /// Sections for newer gnu pubnames and pubtypes.
125   MCSection *DwarfGnuPubNamesSection;
126   MCSection *DwarfGnuPubTypesSection;
127
128   MCSection *COFFDebugSymbolsSection;
129
130   // Extra TLS Variable Data section.  If the target needs to put additional
131   // information for a TLS variable, it'll go here.
132   MCSection *TLSExtraDataSection;
133
134   /// Section directive for Thread Local data. ELF, MachO and COFF.
135   MCSection *TLSDataSection; // Defaults to ".tdata".
136
137   /// Section directive for Thread Local uninitialized data. Null if this target
138   /// doesn't support a BSS section. ELF and MachO only.
139   MCSection *TLSBSSSection; // Defaults to ".tbss".
140
141   /// StackMap section.
142   MCSection *StackMapSection;
143
144   /// EH frame section. It is initialized on demand so it can be overwritten
145   /// (with uniquing).
146   MCSection *EHFrameSection;
147
148   /// ELF specific sections.
149   ///
150   MCSection *DataRelSection;
151   const MCSection *DataRelLocalSection;
152   MCSection *DataRelROSection;
153   MCSection *DataRelROLocalSection;
154   MCSection *MergeableConst4Section;
155   MCSection *MergeableConst8Section;
156   MCSection *MergeableConst16Section;
157
158   /// MachO specific sections.
159   ///
160
161   /// Section for thread local structure information. Contains the source code
162   /// name of the variable, visibility and a pointer to the initial value
163   /// (.tdata or .tbss).
164   MCSection *TLSTLVSection; // Defaults to ".tlv".
165
166   /// TLSThreadInitSection - Section for thread local data initialization
167   /// functions.
168   const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
169
170   MCSection *CStringSection;
171   MCSection *UStringSection;
172   MCSection *TextCoalSection;
173   MCSection *ConstTextCoalSection;
174   MCSection *ConstDataSection;
175   MCSection *DataCoalSection;
176   MCSection *DataCommonSection;
177   MCSection *DataBSSSection;
178   MCSection *FourByteConstantSection;
179   MCSection *EightByteConstantSection;
180   MCSection *SixteenByteConstantSection;
181   MCSection *LazySymbolPointerSection;
182   MCSection *NonLazySymbolPointerSection;
183
184   /// COFF specific sections.
185   ///
186   MCSection *DrectveSection;
187   MCSection *PDataSection;
188   MCSection *XDataSection;
189
190 public:
191   virtual ~MCObjectFileInfo() { };
192
193   void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
194                             MCContext &ctx);
195
196   bool getSupportsWeakOmittedEHFrame() const {
197     return SupportsWeakOmittedEHFrame;
198   }
199   bool getSupportsCompactUnwindWithoutEHFrame() const {
200     return SupportsCompactUnwindWithoutEHFrame;
201   }
202   bool getCommDirectiveSupportsAlignment() const {
203     return CommDirectiveSupportsAlignment;
204   }
205
206   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
207   unsigned getLSDAEncoding() const { return LSDAEncoding; }
208   unsigned getFDEEncoding() const { return FDECFIEncoding; }
209   unsigned getTTypeEncoding() const { return TTypeEncoding; }
210
211   unsigned getCompactUnwindDwarfEHFrameOnly() const {
212     return CompactUnwindDwarfEHFrameOnly;
213   }
214
215   MCSection *getTextSection() const { return TextSection; }
216   MCSection *getDataSection() const { return DataSection; }
217   MCSection *getBSSSection() const { return BSSSection; }
218   MCSection *getLSDASection() const { return LSDASection; }
219   MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
220   MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
221   MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
222   MCSection *getDwarfLineSection() const { return DwarfLineSection; }
223   MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
224   MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
225   MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
226   MCSection *getDwarfGnuPubNamesSection() const {
227     return DwarfGnuPubNamesSection;
228   }
229   MCSection *getDwarfGnuPubTypesSection() const {
230     return DwarfGnuPubTypesSection;
231   }
232   const MCSection *getDwarfDebugInlineSection() const {
233     return DwarfDebugInlineSection;
234   }
235   MCSection *getDwarfStrSection() const { return DwarfStrSection; }
236   MCSection *getDwarfLocSection() const { return DwarfLocSection; }
237   MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
238   MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
239
240   // DWARF5 Experimental Debug Info Sections
241   MCSection *getDwarfAccelNamesSection() const {
242     return DwarfAccelNamesSection;
243   }
244   MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
245   MCSection *getDwarfAccelNamespaceSection() const {
246     return DwarfAccelNamespaceSection;
247   }
248   MCSection *getDwarfAccelTypesSection() const {
249     return DwarfAccelTypesSection;
250   }
251   MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
252   MCSection *getDwarfTypesSection(uint64_t Hash) const;
253   MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
254   MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
255   MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
256   MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
257   MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
258   MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
259   MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
260
261   MCSection *getCOFFDebugSymbolsSection() const {
262     return COFFDebugSymbolsSection;
263   }
264
265   MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
266   const MCSection *getTLSDataSection() const { return TLSDataSection; }
267   MCSection *getTLSBSSSection() const { return TLSBSSSection; }
268
269   MCSection *getStackMapSection() const { return StackMapSection; }
270
271   /// ELF specific sections.
272   ///
273   MCSection *getDataRelSection() const { return DataRelSection; }
274   const MCSection *getDataRelLocalSection() const {
275     return DataRelLocalSection;
276   }
277   MCSection *getDataRelROSection() const { return DataRelROSection; }
278   MCSection *getDataRelROLocalSection() const { return DataRelROLocalSection; }
279   const MCSection *getMergeableConst4Section() const {
280     return MergeableConst4Section;
281   }
282   const MCSection *getMergeableConst8Section() const {
283     return MergeableConst8Section;
284   }
285   const MCSection *getMergeableConst16Section() const {
286     return MergeableConst16Section;
287   }
288
289   /// MachO specific sections.
290   ///
291   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
292   const MCSection *getTLSThreadInitSection() const {
293     return TLSThreadInitSection;
294   }
295   const MCSection *getCStringSection() const { return CStringSection; }
296   const MCSection *getUStringSection() const { return UStringSection; }
297   MCSection *getTextCoalSection() const { return TextCoalSection; }
298   const MCSection *getConstTextCoalSection() const {
299     return ConstTextCoalSection;
300   }
301   const MCSection *getConstDataSection() const { return ConstDataSection; }
302   const MCSection *getDataCoalSection() const { return DataCoalSection; }
303   const MCSection *getDataCommonSection() const { return DataCommonSection; }
304   MCSection *getDataBSSSection() const { return DataBSSSection; }
305   const MCSection *getFourByteConstantSection() const {
306     return FourByteConstantSection;
307   }
308   const MCSection *getEightByteConstantSection() const {
309     return EightByteConstantSection;
310   }
311   const MCSection *getSixteenByteConstantSection() const {
312     return SixteenByteConstantSection;
313   }
314   MCSection *getLazySymbolPointerSection() const {
315     return LazySymbolPointerSection;
316   }
317   MCSection *getNonLazySymbolPointerSection() const {
318     return NonLazySymbolPointerSection;
319   }
320
321   /// COFF specific sections.
322   ///
323   MCSection *getDrectveSection() const { return DrectveSection; }
324   MCSection *getPDataSection() const { return PDataSection; }
325   MCSection *getXDataSection() const { return XDataSection; }
326
327   MCSection *getEHFrameSection() {
328     if (!EHFrameSection)
329       InitEHFrameSection();
330     return EHFrameSection;
331   }
332
333   enum Environment { IsMachO, IsELF, IsCOFF };
334   Environment getObjectFileType() const {
335     return Env;
336   }
337
338   Reloc::Model getRelocM() const {
339     return RelocM;
340   }
341
342 private:
343   Environment Env;
344   Reloc::Model RelocM;
345   CodeModel::Model CMModel;
346   MCContext *Ctx;
347   Triple TT;
348
349   void InitMachOMCObjectFileInfo(Triple T);
350   void InitELFMCObjectFileInfo(Triple T);
351   void InitCOFFMCObjectFileInfo(Triple T);
352
353   /// InitEHFrameSection - Initialize EHFrameSection on demand.
354   ///
355   void InitEHFrameSection();
356
357   virtual unsigned SelectMipsTTypeEncoding() const;
358
359 public:
360   const Triple &getTargetTriple() const { return TT; }
361 };
362
363 } // end namespace llvm
364
365 #endif