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_MCOBJECTFILEINFO_H
15 #define LLVM_MC_MCOBJECTFILEINFO_H
17 #include "llvm/ADT/Triple.h"
18 #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 /// SupportsCompactUnwindWithoutEHFrame - True if the target object file
37 /// supports emitting a compact unwind section without an associated EH frame
39 bool SupportsCompactUnwindWithoutEHFrame;
41 /// PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values
43 unsigned PersonalityEncoding;
44 unsigned LSDAEncoding;
45 unsigned FDECFIEncoding;
46 unsigned TTypeEncoding;
48 /// Section flags for eh_frame
49 unsigned EHSectionType;
50 unsigned EHSectionFlags;
52 /// CompactUnwindDwarfEHFrameOnly - Compact unwind encoding indicating that we
53 /// should emit only an EH frame.
54 unsigned CompactUnwindDwarfEHFrameOnly;
56 /// Section directive for standard text.
58 MCSection *TextSection;
60 /// Section directive for standard data.
62 MCSection *DataSection;
64 /// Section that is default initialized to zero.
65 MCSection *BSSSection;
67 /// Section that is readonly and can contain arbitrary initialized data.
68 /// Targets are not required to have a readonly section. If they don't,
69 /// various bits of code will fall back to using the data section for
71 MCSection *ReadOnlySection;
73 /// This section contains the static constructor pointer list.
74 MCSection *StaticCtorSection;
76 /// This section contains the static destructor pointer list.
77 MCSection *StaticDtorSection;
79 /// If exception handling is supported by the target, this is the section the
80 /// Language Specific Data Area information is emitted to.
81 MCSection *LSDASection;
83 /// If exception handling is supported by the target and the target can
84 /// support a compact representation of the CIE and FDE, this is the section
85 /// to emit them into.
86 MCSection *CompactUnwindSection;
88 // Dwarf sections for debug info. If a target supports debug info, these must
90 MCSection *DwarfAbbrevSection;
91 MCSection *DwarfInfoSection;
92 MCSection *DwarfLineSection;
93 MCSection *DwarfFrameSection;
94 MCSection *DwarfPubTypesSection;
95 const MCSection *DwarfDebugInlineSection;
96 MCSection *DwarfStrSection;
97 MCSection *DwarfLocSection;
98 MCSection *DwarfARangesSection;
99 MCSection *DwarfRangesSection;
100 // The pubnames section is no longer generated by default. The generation
101 // can be enabled by a compiler flag.
102 MCSection *DwarfPubNamesSection;
104 // DWARF5 Experimental Debug Info Sections
105 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
106 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
107 /// If we use the DWARF accelerated hash tables then we want to emit these
109 MCSection *DwarfAccelNamesSection;
110 MCSection *DwarfAccelObjCSection;
111 MCSection *DwarfAccelNamespaceSection;
112 MCSection *DwarfAccelTypesSection;
114 /// These are used for the Fission separate debug information files.
115 MCSection *DwarfInfoDWOSection;
116 MCSection *DwarfTypesDWOSection;
117 MCSection *DwarfAbbrevDWOSection;
118 MCSection *DwarfStrDWOSection;
119 MCSection *DwarfLineDWOSection;
120 MCSection *DwarfLocDWOSection;
121 MCSection *DwarfStrOffDWOSection;
122 MCSection *DwarfAddrSection;
124 /// Sections for newer gnu pubnames and pubtypes.
125 MCSection *DwarfGnuPubNamesSection;
126 MCSection *DwarfGnuPubTypesSection;
128 MCSection *COFFDebugSymbolsSection;
130 // Extra TLS Variable Data section. If the target needs to put additional
131 // information for a TLS variable, it'll go here.
132 MCSection *TLSExtraDataSection;
134 /// Section directive for Thread Local data. ELF, MachO and COFF.
135 MCSection *TLSDataSection; // Defaults to ".tdata".
137 /// Section directive for Thread Local uninitialized data. Null if this target
138 /// doesn't support a BSS section. ELF and MachO only.
139 MCSection *TLSBSSSection; // Defaults to ".tbss".
141 /// StackMap section.
142 MCSection *StackMapSection;
144 /// EH frame section. It is initialized on demand so it can be overwritten
146 MCSection *EHFrameSection;
148 /// ELF specific sections.
150 MCSection *DataRelSection;
151 const MCSection *DataRelLocalSection;
152 MCSection *DataRelROSection;
153 MCSection *DataRelROLocalSection;
154 MCSection *MergeableConst4Section;
155 MCSection *MergeableConst8Section;
156 MCSection *MergeableConst16Section;
158 /// MachO specific sections.
161 /// Section for thread local structure information. Contains the source code
162 /// name of the variable, visibility and a pointer to the initial value
163 /// (.tdata or .tbss).
164 MCSection *TLSTLVSection; // Defaults to ".tlv".
166 /// TLSThreadInitSection - Section for thread local data initialization
168 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
170 MCSection *CStringSection;
171 MCSection *UStringSection;
172 MCSection *TextCoalSection;
173 MCSection *ConstTextCoalSection;
174 MCSection *ConstDataSection;
175 MCSection *DataCoalSection;
176 MCSection *DataCommonSection;
177 MCSection *DataBSSSection;
178 MCSection *FourByteConstantSection;
179 MCSection *EightByteConstantSection;
180 MCSection *SixteenByteConstantSection;
181 MCSection *LazySymbolPointerSection;
182 MCSection *NonLazySymbolPointerSection;
184 /// COFF specific sections.
186 MCSection *DrectveSection;
187 MCSection *PDataSection;
188 MCSection *XDataSection;
191 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
194 bool getSupportsWeakOmittedEHFrame() const {
195 return SupportsWeakOmittedEHFrame;
197 bool getSupportsCompactUnwindWithoutEHFrame() const {
198 return SupportsCompactUnwindWithoutEHFrame;
200 bool getCommDirectiveSupportsAlignment() const {
201 return CommDirectiveSupportsAlignment;
204 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
205 unsigned getLSDAEncoding() const { return LSDAEncoding; }
206 unsigned getFDEEncoding() const { return FDECFIEncoding; }
207 unsigned getTTypeEncoding() const { return TTypeEncoding; }
209 unsigned getCompactUnwindDwarfEHFrameOnly() const {
210 return CompactUnwindDwarfEHFrameOnly;
213 MCSection *getTextSection() const { return TextSection; }
214 MCSection *getDataSection() const { return DataSection; }
215 MCSection *getBSSSection() const { return BSSSection; }
216 MCSection *getLSDASection() const { return LSDASection; }
217 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
218 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
219 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
220 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
221 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
222 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
223 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
224 MCSection *getDwarfGnuPubNamesSection() const {
225 return DwarfGnuPubNamesSection;
227 MCSection *getDwarfGnuPubTypesSection() const {
228 return DwarfGnuPubTypesSection;
230 const MCSection *getDwarfDebugInlineSection() const {
231 return DwarfDebugInlineSection;
233 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
234 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
235 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
236 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
238 // DWARF5 Experimental Debug Info Sections
239 MCSection *getDwarfAccelNamesSection() const {
240 return DwarfAccelNamesSection;
242 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
243 MCSection *getDwarfAccelNamespaceSection() const {
244 return DwarfAccelNamespaceSection;
246 MCSection *getDwarfAccelTypesSection() const {
247 return DwarfAccelTypesSection;
249 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
250 MCSection *getDwarfTypesSection(uint64_t Hash) const;
251 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
252 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
253 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
254 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
255 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
256 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
257 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
259 MCSection *getCOFFDebugSymbolsSection() const {
260 return COFFDebugSymbolsSection;
263 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
264 const MCSection *getTLSDataSection() const { return TLSDataSection; }
265 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
267 MCSection *getStackMapSection() const { return StackMapSection; }
269 /// ELF specific sections.
271 MCSection *getDataRelSection() const { return DataRelSection; }
272 const MCSection *getDataRelLocalSection() const {
273 return DataRelLocalSection;
275 MCSection *getDataRelROSection() const { return DataRelROSection; }
276 MCSection *getDataRelROLocalSection() const { return DataRelROLocalSection; }
277 const MCSection *getMergeableConst4Section() const {
278 return MergeableConst4Section;
280 const MCSection *getMergeableConst8Section() const {
281 return MergeableConst8Section;
283 const MCSection *getMergeableConst16Section() const {
284 return MergeableConst16Section;
287 /// MachO specific sections.
289 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
290 const MCSection *getTLSThreadInitSection() const {
291 return TLSThreadInitSection;
293 const MCSection *getCStringSection() const { return CStringSection; }
294 const MCSection *getUStringSection() const { return UStringSection; }
295 MCSection *getTextCoalSection() const { return TextCoalSection; }
296 const MCSection *getConstTextCoalSection() const {
297 return ConstTextCoalSection;
299 const MCSection *getConstDataSection() const { return ConstDataSection; }
300 const MCSection *getDataCoalSection() const { return DataCoalSection; }
301 const MCSection *getDataCommonSection() const { return DataCommonSection; }
302 MCSection *getDataBSSSection() const { return DataBSSSection; }
303 const MCSection *getFourByteConstantSection() const {
304 return FourByteConstantSection;
306 const MCSection *getEightByteConstantSection() const {
307 return EightByteConstantSection;
309 const MCSection *getSixteenByteConstantSection() const {
310 return SixteenByteConstantSection;
312 MCSection *getLazySymbolPointerSection() const {
313 return LazySymbolPointerSection;
315 MCSection *getNonLazySymbolPointerSection() const {
316 return NonLazySymbolPointerSection;
319 /// COFF specific sections.
321 MCSection *getDrectveSection() const { return DrectveSection; }
322 MCSection *getPDataSection() const { return PDataSection; }
323 MCSection *getXDataSection() const { return XDataSection; }
325 MCSection *getEHFrameSection() {
327 InitEHFrameSection();
328 return EHFrameSection;
331 enum Environment { IsMachO, IsELF, IsCOFF };
332 Environment getObjectFileType() const {
336 Reloc::Model getRelocM() const {
343 CodeModel::Model CMModel;
347 void InitMachOMCObjectFileInfo(Triple T);
348 void InitELFMCObjectFileInfo(Triple T);
349 void InitCOFFMCObjectFileInfo(Triple T);
351 /// InitEHFrameSection - Initialize EHFrameSection on demand.
353 void InitEHFrameSection();
356 const Triple &getTargetTriple() const { return TT; }
359 } // end namespace llvm