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