Split address information for DWARF5 split dwarf proposal. This involves
[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   const MCSection *DwarfInfoDWOSection;
113   const MCSection *DwarfAbbrevDWOSection;
114   const MCSection *DwarfStrDWOSection;
115   const MCSection *DwarfLineDWOSection;
116   const MCSection *DwarfLocDWOSection;
117   const MCSection *DwarfStrOffDWOSection;
118   const MCSection *DwarfAddrSection;
119
120   // Extra TLS Variable Data section.  If the target needs to put additional
121   // information for a TLS variable, it'll go here.
122   const MCSection *TLSExtraDataSection;
123
124   /// TLSDataSection - Section directive for Thread Local data.
125   /// ELF, MachO and COFF.
126   const MCSection *TLSDataSection;        // Defaults to ".tdata".
127
128   /// TLSBSSSection - Section directive for Thread Local uninitialized data.
129   /// Null if this target doesn't support a BSS section.
130   /// ELF and MachO only.
131   const MCSection *TLSBSSSection;         // Defaults to ".tbss".
132
133
134   /// EHFrameSection - EH frame section. It is initialized on demand so it
135   /// can be overwritten (with uniquing).
136   const MCSection *EHFrameSection;
137
138   /// ELF specific sections.
139   ///
140   const MCSection *DataRelSection;
141   const MCSection *DataRelLocalSection;
142   const MCSection *DataRelROSection;
143   const MCSection *DataRelROLocalSection;
144   const MCSection *MergeableConst4Section;
145   const MCSection *MergeableConst8Section;
146   const MCSection *MergeableConst16Section;
147
148   /// MachO specific sections.
149   ///
150
151   /// TLSTLVSection - Section for thread local structure information.
152   /// Contains the source code name of the variable, visibility and a pointer
153   /// to the initial value (.tdata or .tbss).
154   const MCSection *TLSTLVSection;         // Defaults to ".tlv".
155
156   /// TLSThreadInitSection - Section for thread local data initialization
157   /// functions.
158   const MCSection *TLSThreadInitSection;  // Defaults to ".thread_init_func".
159
160   const MCSection *CStringSection;
161   const MCSection *UStringSection;
162   const MCSection *TextCoalSection;
163   const MCSection *ConstTextCoalSection;
164   const MCSection *ConstDataSection;
165   const MCSection *DataCoalSection;
166   const MCSection *DataCommonSection;
167   const MCSection *DataBSSSection;
168   const MCSection *FourByteConstantSection;
169   const MCSection *EightByteConstantSection;
170   const MCSection *SixteenByteConstantSection;
171   const MCSection *LazySymbolPointerSection;
172   const MCSection *NonLazySymbolPointerSection;
173
174   /// COFF specific sections.
175   ///
176   const MCSection *DrectveSection;
177   const MCSection *PDataSection;
178   const MCSection *XDataSection;
179
180 public:
181   void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
182                             MCContext &ctx);
183
184   bool isFunctionEHFrameSymbolPrivate() const {
185     return IsFunctionEHFrameSymbolPrivate;
186   }
187   bool getSupportsWeakOmittedEHFrame() const {
188     return SupportsWeakOmittedEHFrame;
189   }
190   bool getCommDirectiveSupportsAlignment() const {
191     return CommDirectiveSupportsAlignment;
192   }
193
194   unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
195   unsigned getLSDAEncoding() const { return LSDAEncoding; }
196   unsigned getFDEEncoding(bool CFI) const {
197     return CFI ? FDECFIEncoding : FDEEncoding;
198   }
199   unsigned getTTypeEncoding() const { return TTypeEncoding; }
200
201   const MCSection *getTextSection() const { return TextSection; }
202   const MCSection *getDataSection() const { return DataSection; }
203   const MCSection *getBSSSection() const { return BSSSection; }
204   const MCSection *getLSDASection() const { return LSDASection; }
205   const MCSection *getCompactUnwindSection() const{
206     return CompactUnwindSection;
207   }
208   const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
209   const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
210   const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
211   const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
212   const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
213   const MCSection *getDwarfDebugInlineSection() const {
214     return DwarfDebugInlineSection;
215   }
216   const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
217   const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
218   const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
219   const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
220   const MCSection *getDwarfMacroInfoSection() const {
221     return DwarfMacroInfoSection;
222   }
223
224   // DWARF5 Experimental Debug Info Sections
225   const MCSection *getDwarfAccelNamesSection() const {
226     return DwarfAccelNamesSection;
227   }
228   const MCSection *getDwarfAccelObjCSection() const {
229     return DwarfAccelObjCSection;
230   }
231   const MCSection *getDwarfAccelNamespaceSection() const {
232     return DwarfAccelNamespaceSection;
233   }
234   const MCSection *getDwarfAccelTypesSection() const {
235     return DwarfAccelTypesSection;
236   }
237   const MCSection *getDwarfInfoDWOSection() const {
238     return DwarfInfoDWOSection;
239   }
240   const MCSection *getDwarfAbbrevDWOSection() const {
241     return DwarfAbbrevDWOSection;
242   }
243   const MCSection *getDwarfStrDWOSection() const {
244     return DwarfStrDWOSection;
245   }
246   const MCSection *getDwarfLineDWOSection() const {
247     return DwarfLineDWOSection;
248   }
249   const MCSection *getDwarfLocDWOSection() const {
250     return DwarfLocDWOSection;
251   }
252   const MCSection *getDwarfStrOffDWOSection() const {
253     return DwarfStrOffDWOSection;
254   }
255   const MCSection *getDwarfAddrSection() const {
256     return DwarfAddrSection;
257   }
258
259   const MCSection *getTLSExtraDataSection() const {
260     return TLSExtraDataSection;
261   }
262   const MCSection *getTLSDataSection() const { return TLSDataSection; }
263   const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
264
265   /// ELF specific sections.
266   ///
267   const MCSection *getDataRelSection() const { return DataRelSection; }
268   const MCSection *getDataRelLocalSection() const {
269     return DataRelLocalSection;
270   }
271   const MCSection *getDataRelROSection() const { return DataRelROSection; }
272   const MCSection *getDataRelROLocalSection() const {
273     return DataRelROLocalSection;
274   }
275   const MCSection *getMergeableConst4Section() const {
276     return MergeableConst4Section;
277   }
278   const MCSection *getMergeableConst8Section() const {
279     return MergeableConst8Section;
280   }
281   const MCSection *getMergeableConst16Section() const {
282     return MergeableConst16Section;
283   }
284
285   /// MachO specific sections.
286   ///
287   const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
288   const MCSection *getTLSThreadInitSection() const {
289     return TLSThreadInitSection;
290   }
291   const MCSection *getCStringSection() const { return CStringSection; }
292   const MCSection *getUStringSection() const { return UStringSection; }
293   const MCSection *getTextCoalSection() const { return TextCoalSection; }
294   const MCSection *getConstTextCoalSection() const {
295     return ConstTextCoalSection;
296   }
297   const MCSection *getConstDataSection() const { return ConstDataSection; }
298   const MCSection *getDataCoalSection() const { return DataCoalSection; }
299   const MCSection *getDataCommonSection() const { return DataCommonSection; }
300   const MCSection *getDataBSSSection() const { return DataBSSSection; }
301   const MCSection *getFourByteConstantSection() const {
302     return FourByteConstantSection;
303   }
304   const MCSection *getEightByteConstantSection() const {
305     return EightByteConstantSection;
306   }
307   const MCSection *getSixteenByteConstantSection() const {
308     return SixteenByteConstantSection;
309   }
310   const MCSection *getLazySymbolPointerSection() const {
311     return LazySymbolPointerSection;
312   }
313   const MCSection *getNonLazySymbolPointerSection() const {
314     return NonLazySymbolPointerSection;
315   }
316
317   /// COFF specific sections.
318   ///
319   const MCSection *getDrectveSection() const { return DrectveSection; }
320   const MCSection *getPDataSection() const { return PDataSection; }
321   const MCSection *getXDataSection() const { return XDataSection; }
322
323   const MCSection *getEHFrameSection() {
324     if (!EHFrameSection)
325       InitEHFrameSection();
326     return EHFrameSection;
327   }
328
329 private:
330   enum Environment { IsMachO, IsELF, IsCOFF };
331   Environment Env;
332   Reloc::Model RelocM;
333   CodeModel::Model CMModel;
334   MCContext *Ctx;
335
336   void InitMachOMCObjectFileInfo(Triple T);
337   void InitELFMCObjectFileInfo(Triple T);
338   void InitCOFFMCObjectFileInfo(Triple T);
339
340   /// InitEHFrameSection - Initialize EHFrameSection on demand.
341   ///
342   void InitEHFrameSection();
343 };
344
345 } // end namespace llvm
346
347 #endif