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/MC/MCCodeGenInfo.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
27 enum OutputOrder { None, PriorityOrder, ReversePriorityOrder };
30 class MCObjectFileInfo {
32 /// CommDirectiveSupportsAlignment - True if .comm supports alignment. This
33 /// is a hack for as long as we support 10.4 Tiger, whose assembler doesn't
34 /// support alignment on comm.
35 bool CommDirectiveSupportsAlignment;
37 /// SupportsWeakEmptyEHFrame - True if target object file supports a
38 /// weak_definition of constant 0 for an omitted EH frame.
39 bool SupportsWeakOmittedEHFrame;
41 /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the
42 /// "EH_frame" symbol for EH information should be an assembler temporary (aka
43 /// private linkage, aka an L or .L label) or false if it should be a normal
44 /// non-.globl label. This defaults to true.
45 bool IsFunctionEHFrameSymbolPrivate;
47 /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
48 /// encoding values for EH.
49 unsigned PersonalityEncoding;
50 unsigned LSDAEncoding;
52 unsigned FDECFIEncoding;
53 unsigned TTypeEncoding;
55 /// TextSection - Section directive for standard text.
57 const MCSection *TextSection;
59 /// DataSection - Section directive for standard data.
61 const MCSection *DataSection;
63 /// BSSSection - Section that is default initialized to zero.
64 const MCSection *BSSSection;
66 /// ReadOnlySection - Section that is readonly and can contain arbitrary
67 /// initialized data. Targets are not required to have a readonly section.
68 /// If they don't, various bits of code will fall back to using the data
69 /// section for constants.
70 const MCSection *ReadOnlySection;
72 /// StaticCtorSection - This section contains the static constructor pointer
74 const MCSection *StaticCtorSection;
76 /// StaticDtorSection - This section contains the static destructor pointer
78 const MCSection *StaticDtorSection;
80 /// LSDASection - If exception handling is supported by the target, this is
81 /// the section the Language Specific Data Area information is emitted to.
82 const MCSection *LSDASection;
84 /// CompactUnwindSection - If exception handling is supported by the target
85 /// and the target can support a compact representation of the CIE and FDE,
86 /// this is the section to emit them into.
87 const MCSection *CompactUnwindSection;
89 /// DwarfAccelNamesSection, DwarfAccelObjCSection
90 /// If we use the DWARF accelerated hash tables then we want toe emit these
92 const MCSection *DwarfAccelNamesSection;
93 const MCSection *DwarfAccelObjCSection;
94 const MCSection *DwarfAccelNamespaceSection;
95 const MCSection *DwarfAccelTypesSection;
97 // Dwarf sections for debug info. If a target supports debug info, these must
99 const MCSection *DwarfAbbrevSection;
100 const MCSection *DwarfInfoSection;
101 const MCSection *DwarfLineSection;
102 const MCSection *DwarfFrameSection;
103 const MCSection *DwarfPubTypesSection;
104 const MCSection *DwarfDebugInlineSection;
105 const MCSection *DwarfStrSection;
106 const MCSection *DwarfLocSection;
107 const MCSection *DwarfARangesSection;
108 const MCSection *DwarfRangesSection;
109 const MCSection *DwarfMacroInfoSection;
111 // Extra TLS Variable Data section. If the target needs to put additional
112 // information for a TLS variable, it'll go here.
113 const MCSection *TLSExtraDataSection;
115 /// TLSDataSection - Section directive for Thread Local data.
116 /// ELF and MachO only.
117 const MCSection *TLSDataSection; // Defaults to ".tdata".
119 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
120 /// Null if this target doesn't support a BSS section.
121 /// ELF and MachO only.
122 const MCSection *TLSBSSSection; // Defaults to ".tbss".
125 /// EHFrameSection - EH frame section. It is initialized on demand so it
126 /// can be overwritten (with uniquing).
127 const MCSection *EHFrameSection;
129 /// ELF specific sections.
131 const MCSection *DataRelSection;
132 const MCSection *DataRelLocalSection;
133 const MCSection *DataRelROSection;
134 const MCSection *DataRelROLocalSection;
135 const MCSection *MergeableConst4Section;
136 const MCSection *MergeableConst8Section;
137 const MCSection *MergeableConst16Section;
139 /// MachO specific sections.
142 /// TLSTLVSection - Section for thread local structure information.
143 /// Contains the source code name of the variable, visibility and a pointer
144 /// to the initial value (.tdata or .tbss).
145 const MCSection *TLSTLVSection; // Defaults to ".tlv".
147 /// TLSThreadInitSection - Section for thread local data initialization
149 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
151 const MCSection *CStringSection;
152 const MCSection *UStringSection;
153 const MCSection *TextCoalSection;
154 const MCSection *ConstTextCoalSection;
155 const MCSection *ConstDataSection;
156 const MCSection *DataCoalSection;
157 const MCSection *DataCommonSection;
158 const MCSection *DataBSSSection;
159 const MCSection *FourByteConstantSection;
160 const MCSection *EightByteConstantSection;
161 const MCSection *SixteenByteConstantSection;
162 const MCSection *LazySymbolPointerSection;
163 const MCSection *NonLazySymbolPointerSection;
165 /// COFF specific sections.
167 const MCSection *DrectveSection;
168 const MCSection *PDataSection;
169 const MCSection *XDataSection;
171 /// StructorOutputOrder - Whether the static ctor/dtor list should be output
172 /// in no particular order, in order of increasing priority or the reverse:
173 /// in order of decreasing priority (the default).
174 Structors::OutputOrder StructorOutputOrder; // Default is reverse order.
177 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
180 bool isFunctionEHFrameSymbolPrivate() const {
181 return IsFunctionEHFrameSymbolPrivate;
183 bool getSupportsWeakOmittedEHFrame() const {
184 return SupportsWeakOmittedEHFrame;
186 bool getCommDirectiveSupportsAlignment() const {
187 return CommDirectiveSupportsAlignment;
190 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
191 unsigned getLSDAEncoding() const { return LSDAEncoding; }
192 unsigned getFDEEncoding(bool CFI) const {
193 return CFI ? FDECFIEncoding : FDEEncoding;
195 unsigned getTTypeEncoding() const { return TTypeEncoding; }
197 const MCSection *getTextSection() const { return TextSection; }
198 const MCSection *getDataSection() const { return DataSection; }
199 const MCSection *getBSSSection() const { return BSSSection; }
200 const MCSection *getStaticCtorSection() const { return StaticCtorSection; }
201 const MCSection *getStaticDtorSection() const { return StaticDtorSection; }
202 const MCSection *getLSDASection() const { return LSDASection; }
203 const MCSection *getCompactUnwindSection() const{
204 return CompactUnwindSection;
206 const MCSection *getDwarfAccelNamesSection() const {
207 return DwarfAccelNamesSection;
209 const MCSection *getDwarfAccelObjCSection() const {
210 return DwarfAccelObjCSection;
212 const MCSection *getDwarfAccelNamespaceSection() const {
213 return DwarfAccelNamespaceSection;
215 const MCSection *getDwarfAccelTypesSection() const {
216 return DwarfAccelTypesSection;
218 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
219 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
220 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
221 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
222 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
223 const MCSection *getDwarfDebugInlineSection() const {
224 return DwarfDebugInlineSection;
226 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
227 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
228 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
229 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
230 const MCSection *getDwarfMacroInfoSection() const {
231 return DwarfMacroInfoSection;
233 const MCSection *getTLSExtraDataSection() const {
234 return TLSExtraDataSection;
236 const MCSection *getTLSDataSection() const { return TLSDataSection; }
237 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
239 /// ELF specific sections.
241 const MCSection *getDataRelSection() const { return DataRelSection; }
242 const MCSection *getDataRelLocalSection() const {
243 return DataRelLocalSection;
245 const MCSection *getDataRelROSection() const { return DataRelROSection; }
246 const MCSection *getDataRelROLocalSection() const {
247 return DataRelROLocalSection;
249 const MCSection *getMergeableConst4Section() const {
250 return MergeableConst4Section;
252 const MCSection *getMergeableConst8Section() const {
253 return MergeableConst8Section;
255 const MCSection *getMergeableConst16Section() const {
256 return MergeableConst16Section;
259 /// MachO specific sections.
261 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
262 const MCSection *getTLSThreadInitSection() const {
263 return TLSThreadInitSection;
265 const MCSection *getCStringSection() const { return CStringSection; }
266 const MCSection *getUStringSection() const { return UStringSection; }
267 const MCSection *getTextCoalSection() const { return TextCoalSection; }
268 const MCSection *getConstTextCoalSection() const {
269 return ConstTextCoalSection;
271 const MCSection *getConstDataSection() const { return ConstDataSection; }
272 const MCSection *getDataCoalSection() const { return DataCoalSection; }
273 const MCSection *getDataCommonSection() const { return DataCommonSection; }
274 const MCSection *getDataBSSSection() const { return DataBSSSection; }
275 const MCSection *getFourByteConstantSection() const {
276 return FourByteConstantSection;
278 const MCSection *getEightByteConstantSection() const {
279 return EightByteConstantSection;
281 const MCSection *getSixteenByteConstantSection() const {
282 return SixteenByteConstantSection;
284 const MCSection *getLazySymbolPointerSection() const {
285 return LazySymbolPointerSection;
287 const MCSection *getNonLazySymbolPointerSection() const {
288 return NonLazySymbolPointerSection;
291 /// COFF specific sections.
293 const MCSection *getDrectveSection() const { return DrectveSection; }
294 const MCSection *getPDataSection() const { return PDataSection; }
295 const MCSection *getXDataSection() const { return XDataSection; }
297 const MCSection *getEHFrameSection() {
299 InitEHFrameSection();
300 return EHFrameSection;
303 Structors::OutputOrder getStructorOutputOrder() const {
304 return StructorOutputOrder;
308 enum Environment { IsMachO, IsELF, IsCOFF };
311 CodeModel::Model CMModel;
314 void InitMachOMCObjectFileInfo(Triple T);
315 void InitELFMCObjectFileInfo(Triple T);
316 void InitCOFFMCObjectFileInfo(Triple T);
318 /// InitEHFrameSection - Initialize EHFrameSection on demand.
320 void InitEHFrameSection();
323 } // end namespace llvm