1 //===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes common object file formats.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCBJECTFILEINFO_H
15 #define LLVM_MC_MCBJECTFILEINFO_H
17 #include "llvm/Support/CodeGen.h"
25 class MCObjectFileInfo {
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;
32 /// SupportsWeakEmptyEHFrame - True if target object file supports a
33 /// weak_definition of constant 0 for an omitted EH frame.
34 bool SupportsWeakOmittedEHFrame;
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;
42 /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
43 /// encoding values for EH.
44 unsigned PersonalityEncoding;
45 unsigned LSDAEncoding;
47 unsigned FDECFIEncoding;
48 unsigned TTypeEncoding;
49 // Section flags for eh_frame
50 unsigned EHSectionType;
51 unsigned EHSectionFlags;
53 /// TextSection - Section directive for standard text.
55 const MCSection *TextSection;
57 /// DataSection - Section directive for standard data.
59 const MCSection *DataSection;
61 /// BSSSection - Section that is default initialized to zero.
62 const MCSection *BSSSection;
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;
70 /// StaticCtorSection - This section contains the static constructor pointer
72 const MCSection *StaticCtorSection;
74 /// StaticDtorSection - This section contains the static destructor pointer
76 const MCSection *StaticDtorSection;
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;
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;
87 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
88 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
89 /// If we use the DWARF accelerated hash tables then we want toe emit these
91 const MCSection *DwarfAccelNamesSection;
92 const MCSection *DwarfAccelObjCSection;
93 const MCSection *DwarfAccelNamespaceSection;
94 const MCSection *DwarfAccelTypesSection;
96 // Dwarf sections for debug info. If a target supports debug info, these must
98 const MCSection *DwarfAbbrevSection;
99 const MCSection *DwarfInfoSection;
100 const MCSection *DwarfLineSection;
101 const MCSection *DwarfFrameSection;
102 const MCSection *DwarfPubTypesSection;
103 const MCSection *DwarfDebugInlineSection;
104 const MCSection *DwarfStrSection;
105 const MCSection *DwarfLocSection;
106 const MCSection *DwarfARangesSection;
107 const MCSection *DwarfRangesSection;
108 const MCSection *DwarfMacroInfoSection;
110 // Extra TLS Variable Data section. If the target needs to put additional
111 // information for a TLS variable, it'll go here.
112 const MCSection *TLSExtraDataSection;
114 /// TLSDataSection - Section directive for Thread Local data.
115 /// ELF, MachO and COFF.
116 const MCSection *TLSDataSection; // Defaults to ".tdata".
118 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
119 /// Null if this target doesn't support a BSS section.
120 /// ELF and MachO only.
121 const MCSection *TLSBSSSection; // Defaults to ".tbss".
124 /// EHFrameSection - EH frame section. It is initialized on demand so it
125 /// can be overwritten (with uniquing).
126 const MCSection *EHFrameSection;
128 /// ELF specific sections.
130 const MCSection *DataRelSection;
131 const MCSection *DataRelLocalSection;
132 const MCSection *DataRelROSection;
133 const MCSection *DataRelROLocalSection;
134 const MCSection *MergeableConst4Section;
135 const MCSection *MergeableConst8Section;
136 const MCSection *MergeableConst16Section;
138 /// MachO specific sections.
141 /// TLSTLVSection - Section for thread local structure information.
142 /// Contains the source code name of the variable, visibility and a pointer
143 /// to the initial value (.tdata or .tbss).
144 const MCSection *TLSTLVSection; // Defaults to ".tlv".
146 /// TLSThreadInitSection - Section for thread local data initialization
148 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
150 const MCSection *CStringSection;
151 const MCSection *UStringSection;
152 const MCSection *TextCoalSection;
153 const MCSection *ConstTextCoalSection;
154 const MCSection *ConstDataSection;
155 const MCSection *DataCoalSection;
156 const MCSection *DataCommonSection;
157 const MCSection *DataBSSSection;
158 const MCSection *FourByteConstantSection;
159 const MCSection *EightByteConstantSection;
160 const MCSection *SixteenByteConstantSection;
161 const MCSection *LazySymbolPointerSection;
162 const MCSection *NonLazySymbolPointerSection;
164 /// COFF specific sections.
166 const MCSection *DrectveSection;
167 const MCSection *PDataSection;
168 const MCSection *XDataSection;
171 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
174 bool isFunctionEHFrameSymbolPrivate() const {
175 return IsFunctionEHFrameSymbolPrivate;
177 bool getSupportsWeakOmittedEHFrame() const {
178 return SupportsWeakOmittedEHFrame;
180 bool getCommDirectiveSupportsAlignment() const {
181 return CommDirectiveSupportsAlignment;
184 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
185 unsigned getLSDAEncoding() const { return LSDAEncoding; }
186 unsigned getFDEEncoding(bool CFI) const {
187 return CFI ? FDECFIEncoding : FDEEncoding;
189 unsigned getTTypeEncoding() const { return TTypeEncoding; }
191 const MCSection *getTextSection() const { return TextSection; }
192 const MCSection *getDataSection() const { return DataSection; }
193 const MCSection *getBSSSection() const { return BSSSection; }
194 const MCSection *getLSDASection() const { return LSDASection; }
195 const MCSection *getCompactUnwindSection() const{
196 return CompactUnwindSection;
198 const MCSection *getDwarfAccelNamesSection() const {
199 return DwarfAccelNamesSection;
201 const MCSection *getDwarfAccelObjCSection() const {
202 return DwarfAccelObjCSection;
204 const MCSection *getDwarfAccelNamespaceSection() const {
205 return DwarfAccelNamespaceSection;
207 const MCSection *getDwarfAccelTypesSection() const {
208 return DwarfAccelTypesSection;
210 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
211 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
212 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
213 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
214 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
215 const MCSection *getDwarfDebugInlineSection() const {
216 return DwarfDebugInlineSection;
218 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
219 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
220 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
221 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
222 const MCSection *getDwarfMacroInfoSection() const {
223 return DwarfMacroInfoSection;
225 const MCSection *getTLSExtraDataSection() const {
226 return TLSExtraDataSection;
228 const MCSection *getTLSDataSection() const { return TLSDataSection; }
229 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
231 /// ELF specific sections.
233 const MCSection *getDataRelSection() const { return DataRelSection; }
234 const MCSection *getDataRelLocalSection() const {
235 return DataRelLocalSection;
237 const MCSection *getDataRelROSection() const { return DataRelROSection; }
238 const MCSection *getDataRelROLocalSection() const {
239 return DataRelROLocalSection;
241 const MCSection *getMergeableConst4Section() const {
242 return MergeableConst4Section;
244 const MCSection *getMergeableConst8Section() const {
245 return MergeableConst8Section;
247 const MCSection *getMergeableConst16Section() const {
248 return MergeableConst16Section;
251 /// MachO specific sections.
253 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
254 const MCSection *getTLSThreadInitSection() const {
255 return TLSThreadInitSection;
257 const MCSection *getCStringSection() const { return CStringSection; }
258 const MCSection *getUStringSection() const { return UStringSection; }
259 const MCSection *getTextCoalSection() const { return TextCoalSection; }
260 const MCSection *getConstTextCoalSection() const {
261 return ConstTextCoalSection;
263 const MCSection *getConstDataSection() const { return ConstDataSection; }
264 const MCSection *getDataCoalSection() const { return DataCoalSection; }
265 const MCSection *getDataCommonSection() const { return DataCommonSection; }
266 const MCSection *getDataBSSSection() const { return DataBSSSection; }
267 const MCSection *getFourByteConstantSection() const {
268 return FourByteConstantSection;
270 const MCSection *getEightByteConstantSection() const {
271 return EightByteConstantSection;
273 const MCSection *getSixteenByteConstantSection() const {
274 return SixteenByteConstantSection;
276 const MCSection *getLazySymbolPointerSection() const {
277 return LazySymbolPointerSection;
279 const MCSection *getNonLazySymbolPointerSection() const {
280 return NonLazySymbolPointerSection;
283 /// COFF specific sections.
285 const MCSection *getDrectveSection() const { return DrectveSection; }
286 const MCSection *getPDataSection() const { return PDataSection; }
287 const MCSection *getXDataSection() const { return XDataSection; }
289 const MCSection *getEHFrameSection() {
291 InitEHFrameSection();
292 return EHFrameSection;
296 enum Environment { IsMachO, IsELF, IsCOFF };
299 CodeModel::Model CMModel;
302 void InitMachOMCObjectFileInfo(Triple T);
303 void InitELFMCObjectFileInfo(Triple T);
304 void InitCOFFMCObjectFileInfo(Triple T);
306 /// InitEHFrameSection - Initialize EHFrameSection on demand.
308 void InitEHFrameSection();
311 } // end namespace llvm