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