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 // Dwarf sections for debug info. If a target supports debug info, these must
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;
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
106 const MCSection *DwarfAccelNamesSection;
107 const MCSection *DwarfAccelObjCSection;
108 const MCSection *DwarfAccelNamespaceSection;
109 const MCSection *DwarfAccelTypesSection;
111 /// These are used for the Fission separate debug information files.
112 /// DwarfInfoDWOSection
113 const MCSection *DwarfInfoDWOSection;
115 // Extra TLS Variable Data section. If the target needs to put additional
116 // information for a TLS variable, it'll go here.
117 const MCSection *TLSExtraDataSection;
119 /// TLSDataSection - Section directive for Thread Local data.
120 /// ELF, MachO and COFF.
121 const MCSection *TLSDataSection; // Defaults to ".tdata".
123 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
124 /// Null if this target doesn't support a BSS section.
125 /// ELF and MachO only.
126 const MCSection *TLSBSSSection; // Defaults to ".tbss".
129 /// EHFrameSection - EH frame section. It is initialized on demand so it
130 /// can be overwritten (with uniquing).
131 const MCSection *EHFrameSection;
133 /// ELF specific sections.
135 const MCSection *DataRelSection;
136 const MCSection *DataRelLocalSection;
137 const MCSection *DataRelROSection;
138 const MCSection *DataRelROLocalSection;
139 const MCSection *MergeableConst4Section;
140 const MCSection *MergeableConst8Section;
141 const MCSection *MergeableConst16Section;
143 /// MachO specific sections.
146 /// TLSTLVSection - Section for thread local structure information.
147 /// Contains the source code name of the variable, visibility and a pointer
148 /// to the initial value (.tdata or .tbss).
149 const MCSection *TLSTLVSection; // Defaults to ".tlv".
151 /// TLSThreadInitSection - Section for thread local data initialization
153 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
155 const MCSection *CStringSection;
156 const MCSection *UStringSection;
157 const MCSection *TextCoalSection;
158 const MCSection *ConstTextCoalSection;
159 const MCSection *ConstDataSection;
160 const MCSection *DataCoalSection;
161 const MCSection *DataCommonSection;
162 const MCSection *DataBSSSection;
163 const MCSection *FourByteConstantSection;
164 const MCSection *EightByteConstantSection;
165 const MCSection *SixteenByteConstantSection;
166 const MCSection *LazySymbolPointerSection;
167 const MCSection *NonLazySymbolPointerSection;
169 /// COFF specific sections.
171 const MCSection *DrectveSection;
172 const MCSection *PDataSection;
173 const MCSection *XDataSection;
176 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
179 bool isFunctionEHFrameSymbolPrivate() const {
180 return IsFunctionEHFrameSymbolPrivate;
182 bool getSupportsWeakOmittedEHFrame() const {
183 return SupportsWeakOmittedEHFrame;
185 bool getCommDirectiveSupportsAlignment() const {
186 return CommDirectiveSupportsAlignment;
189 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
190 unsigned getLSDAEncoding() const { return LSDAEncoding; }
191 unsigned getFDEEncoding(bool CFI) const {
192 return CFI ? FDECFIEncoding : FDEEncoding;
194 unsigned getTTypeEncoding() const { return TTypeEncoding; }
196 const MCSection *getTextSection() const { return TextSection; }
197 const MCSection *getDataSection() const { return DataSection; }
198 const MCSection *getBSSSection() const { return BSSSection; }
199 const MCSection *getLSDASection() const { return LSDASection; }
200 const MCSection *getCompactUnwindSection() const{
201 return CompactUnwindSection;
203 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
204 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
205 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
206 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
207 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
208 const MCSection *getDwarfDebugInlineSection() const {
209 return DwarfDebugInlineSection;
211 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
212 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
213 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
214 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
215 const MCSection *getDwarfMacroInfoSection() const {
216 return DwarfMacroInfoSection;
219 // DWARF5 Experimental Debug Info Sections
220 const MCSection *getDwarfAccelNamesSection() const {
221 return DwarfAccelNamesSection;
223 const MCSection *getDwarfAccelObjCSection() const {
224 return DwarfAccelObjCSection;
226 const MCSection *getDwarfAccelNamespaceSection() const {
227 return DwarfAccelNamespaceSection;
229 const MCSection *getDwarfAccelTypesSection() const {
230 return DwarfAccelTypesSection;
232 const MCSection *getDwarfInfoDWOSection() const {
233 return DwarfInfoDWOSection;
236 const MCSection *getTLSExtraDataSection() const {
237 return TLSExtraDataSection;
239 const MCSection *getTLSDataSection() const { return TLSDataSection; }
240 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
242 /// ELF specific sections.
244 const MCSection *getDataRelSection() const { return DataRelSection; }
245 const MCSection *getDataRelLocalSection() const {
246 return DataRelLocalSection;
248 const MCSection *getDataRelROSection() const { return DataRelROSection; }
249 const MCSection *getDataRelROLocalSection() const {
250 return DataRelROLocalSection;
252 const MCSection *getMergeableConst4Section() const {
253 return MergeableConst4Section;
255 const MCSection *getMergeableConst8Section() const {
256 return MergeableConst8Section;
258 const MCSection *getMergeableConst16Section() const {
259 return MergeableConst16Section;
262 /// MachO specific sections.
264 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
265 const MCSection *getTLSThreadInitSection() const {
266 return TLSThreadInitSection;
268 const MCSection *getCStringSection() const { return CStringSection; }
269 const MCSection *getUStringSection() const { return UStringSection; }
270 const MCSection *getTextCoalSection() const { return TextCoalSection; }
271 const MCSection *getConstTextCoalSection() const {
272 return ConstTextCoalSection;
274 const MCSection *getConstDataSection() const { return ConstDataSection; }
275 const MCSection *getDataCoalSection() const { return DataCoalSection; }
276 const MCSection *getDataCommonSection() const { return DataCommonSection; }
277 const MCSection *getDataBSSSection() const { return DataBSSSection; }
278 const MCSection *getFourByteConstantSection() const {
279 return FourByteConstantSection;
281 const MCSection *getEightByteConstantSection() const {
282 return EightByteConstantSection;
284 const MCSection *getSixteenByteConstantSection() const {
285 return SixteenByteConstantSection;
287 const MCSection *getLazySymbolPointerSection() const {
288 return LazySymbolPointerSection;
290 const MCSection *getNonLazySymbolPointerSection() const {
291 return NonLazySymbolPointerSection;
294 /// COFF specific sections.
296 const MCSection *getDrectveSection() const { return DrectveSection; }
297 const MCSection *getPDataSection() const { return PDataSection; }
298 const MCSection *getXDataSection() const { return XDataSection; }
300 const MCSection *getEHFrameSection() {
302 InitEHFrameSection();
303 return EHFrameSection;
307 enum Environment { IsMachO, IsELF, IsCOFF };
310 CodeModel::Model CMModel;
313 void InitMachOMCObjectFileInfo(Triple T);
314 void InitELFMCObjectFileInfo(Triple T);
315 void InitCOFFMCObjectFileInfo(Triple T);
317 /// InitEHFrameSection - Initialize EHFrameSection on demand.
319 void InitEHFrameSection();
322 } // end namespace llvm