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