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"
24 class MCObjectFileInfo {
26 /// True if .comm supports alignment. This is a hack for as long as we
27 /// support 10.4 Tiger, whose assembler doesn't support alignment on comm.
28 bool CommDirectiveSupportsAlignment;
30 /// True if target object file supports a weak_definition of constant 0 for an
32 bool SupportsWeakOmittedEHFrame;
34 /// True if the target object file supports emitting a compact unwind section
35 /// without an associated EH frame section.
36 bool SupportsCompactUnwindWithoutEHFrame;
38 /// OmitDwarfIfHaveCompactUnwind - True if the target object file
39 /// supports having some functions with compact unwind and other with
41 bool OmitDwarfIfHaveCompactUnwind;
43 /// PersonalityEncoding, LSDAEncoding, TTypeEncoding - Some encoding values
45 unsigned PersonalityEncoding;
46 unsigned LSDAEncoding;
47 unsigned FDECFIEncoding;
48 unsigned TTypeEncoding;
50 /// Section flags for eh_frame
51 unsigned EHSectionType;
52 unsigned EHSectionFlags;
54 /// Compact unwind encoding indicating that we should emit only an EH frame.
55 unsigned CompactUnwindDwarfEHFrameOnly;
57 /// Section directive for standard text.
58 MCSection *TextSection;
60 /// Section directive for standard data.
61 MCSection *DataSection;
63 /// Section that is default initialized to zero.
64 MCSection *BSSSection;
66 /// Section that is readonly and can contain arbitrary initialized data.
67 /// Targets are not required to have a readonly section. If they don't,
68 /// various bits of code will fall back to using the data section for
70 MCSection *ReadOnlySection;
72 /// This section contains the static constructor pointer list.
73 MCSection *StaticCtorSection;
75 /// This section contains the static destructor pointer list.
76 MCSection *StaticDtorSection;
78 /// If exception handling is supported by the target, this is the section the
79 /// Language Specific Data Area information is emitted to.
80 MCSection *LSDASection;
82 /// If exception handling is supported by the target and the target can
83 /// support a compact representation of the CIE and FDE, this is the section
84 /// to emit them into.
85 MCSection *CompactUnwindSection;
87 // Dwarf sections for debug info. If a target supports debug info, these must
89 MCSection *DwarfAbbrevSection;
90 MCSection *DwarfInfoSection;
91 MCSection *DwarfLineSection;
92 MCSection *DwarfFrameSection;
93 MCSection *DwarfPubTypesSection;
94 const MCSection *DwarfDebugInlineSection;
95 MCSection *DwarfStrSection;
96 MCSection *DwarfLocSection;
97 MCSection *DwarfARangesSection;
98 MCSection *DwarfRangesSection;
99 // The pubnames section is no longer generated by default. The generation
100 // can be enabled by a compiler flag.
101 MCSection *DwarfPubNamesSection;
103 /// DWARF5 Experimental Debug Info Sections
104 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
105 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
106 /// If we use the DWARF accelerated hash tables then we want to emit these
108 MCSection *DwarfAccelNamesSection;
109 MCSection *DwarfAccelObjCSection;
110 MCSection *DwarfAccelNamespaceSection;
111 MCSection *DwarfAccelTypesSection;
113 // These are used for the Fission separate debug information files.
114 MCSection *DwarfInfoDWOSection;
115 MCSection *DwarfTypesDWOSection;
116 MCSection *DwarfAbbrevDWOSection;
117 MCSection *DwarfStrDWOSection;
118 MCSection *DwarfLineDWOSection;
119 MCSection *DwarfLocDWOSection;
120 MCSection *DwarfStrOffDWOSection;
121 MCSection *DwarfAddrSection;
123 /// Section for newer gnu pubnames.
124 MCSection *DwarfGnuPubNamesSection;
125 /// Section for newer gnu pubtypes.
126 MCSection *DwarfGnuPubTypesSection;
128 MCSection *COFFDebugSymbolsSection;
130 /// Extra TLS Variable Data section.
132 /// If the target needs to put additional information for a TLS variable,
134 MCSection *TLSExtraDataSection;
136 /// Section directive for Thread Local data. ELF, MachO and COFF.
137 MCSection *TLSDataSection; // Defaults to ".tdata".
139 /// Section directive for Thread Local uninitialized data.
141 /// Null if this target doesn't support a BSS section. ELF and MachO only.
142 MCSection *TLSBSSSection; // Defaults to ".tbss".
144 /// StackMap section.
145 MCSection *StackMapSection;
147 /// FaultMap section.
148 MCSection *FaultMapSection;
150 /// EH frame section.
152 /// It is initialized on demand so it can be overwritten (with uniquing).
153 MCSection *EHFrameSection;
155 // ELF specific sections.
156 MCSection *DataRelSection;
157 const MCSection *DataRelLocalSection;
158 MCSection *DataRelROSection;
159 MCSection *DataRelROLocalSection;
160 MCSection *MergeableConst4Section;
161 MCSection *MergeableConst8Section;
162 MCSection *MergeableConst16Section;
164 // MachO specific sections.
166 /// Section for thread local structure information.
168 /// Contains the source code name of the variable, visibility and a pointer to
169 /// the initial value (.tdata or .tbss).
170 MCSection *TLSTLVSection; // Defaults to ".tlv".
172 /// Section for thread local data initialization functions.
173 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
175 MCSection *CStringSection;
176 MCSection *UStringSection;
177 MCSection *TextCoalSection;
178 MCSection *ConstTextCoalSection;
179 MCSection *ConstDataSection;
180 MCSection *DataCoalSection;
181 MCSection *DataCommonSection;
182 MCSection *DataBSSSection;
183 MCSection *FourByteConstantSection;
184 MCSection *EightByteConstantSection;
185 MCSection *SixteenByteConstantSection;
186 MCSection *LazySymbolPointerSection;
187 MCSection *NonLazySymbolPointerSection;
189 /// COFF specific sections.
190 MCSection *DrectveSection;
191 MCSection *PDataSection;
192 MCSection *XDataSection;
193 MCSection *SXDataSection;
196 void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM,
197 CodeModel::Model CM, MCContext &ctx);
198 LLVM_ATTRIBUTE_DEPRECATED(
199 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM,
200 CodeModel::Model CM, MCContext &ctx),
201 "StringRef GNU Triple argument replaced by a llvm::Triple object");
203 bool getSupportsWeakOmittedEHFrame() const {
204 return SupportsWeakOmittedEHFrame;
206 bool getSupportsCompactUnwindWithoutEHFrame() const {
207 return SupportsCompactUnwindWithoutEHFrame;
209 bool getOmitDwarfIfHaveCompactUnwind() const {
210 return OmitDwarfIfHaveCompactUnwind;
213 bool getCommDirectiveSupportsAlignment() const {
214 return CommDirectiveSupportsAlignment;
217 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
218 unsigned getLSDAEncoding() const { return LSDAEncoding; }
219 unsigned getFDEEncoding() const { return FDECFIEncoding; }
220 unsigned getTTypeEncoding() const { return TTypeEncoding; }
222 unsigned getCompactUnwindDwarfEHFrameOnly() const {
223 return CompactUnwindDwarfEHFrameOnly;
226 MCSection *getTextSection() const { return TextSection; }
227 MCSection *getDataSection() const { return DataSection; }
228 MCSection *getBSSSection() const { return BSSSection; }
229 MCSection *getReadOnlySection() const { return ReadOnlySection; }
230 MCSection *getLSDASection() const { return LSDASection; }
231 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
232 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
233 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
234 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
235 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
236 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
237 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
238 MCSection *getDwarfGnuPubNamesSection() const {
239 return DwarfGnuPubNamesSection;
241 MCSection *getDwarfGnuPubTypesSection() const {
242 return DwarfGnuPubTypesSection;
244 const MCSection *getDwarfDebugInlineSection() const {
245 return DwarfDebugInlineSection;
247 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
248 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
249 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
250 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
252 // DWARF5 Experimental Debug Info Sections
253 MCSection *getDwarfAccelNamesSection() const {
254 return DwarfAccelNamesSection;
256 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
257 MCSection *getDwarfAccelNamespaceSection() const {
258 return DwarfAccelNamespaceSection;
260 MCSection *getDwarfAccelTypesSection() const {
261 return DwarfAccelTypesSection;
263 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
264 MCSection *getDwarfTypesSection(uint64_t Hash) const;
265 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
266 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
267 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
268 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
269 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
270 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
271 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
273 MCSection *getCOFFDebugSymbolsSection() const {
274 return COFFDebugSymbolsSection;
277 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
278 const MCSection *getTLSDataSection() const { return TLSDataSection; }
279 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
281 MCSection *getStackMapSection() const { return StackMapSection; }
282 MCSection *getFaultMapSection() const { return FaultMapSection; }
284 // ELF specific sections.
285 MCSection *getDataRelSection() const { return DataRelSection; }
286 const MCSection *getDataRelLocalSection() const {
287 return DataRelLocalSection;
289 MCSection *getDataRelROSection() const { return DataRelROSection; }
290 MCSection *getDataRelROLocalSection() const { return DataRelROLocalSection; }
291 const MCSection *getMergeableConst4Section() const {
292 return MergeableConst4Section;
294 const MCSection *getMergeableConst8Section() const {
295 return MergeableConst8Section;
297 const MCSection *getMergeableConst16Section() const {
298 return MergeableConst16Section;
301 // MachO specific sections.
302 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
303 const MCSection *getTLSThreadInitSection() const {
304 return TLSThreadInitSection;
306 const MCSection *getCStringSection() const { return CStringSection; }
307 const MCSection *getUStringSection() const { return UStringSection; }
308 MCSection *getTextCoalSection() const { return TextCoalSection; }
309 const MCSection *getConstTextCoalSection() const {
310 return ConstTextCoalSection;
312 const MCSection *getConstDataSection() const { return ConstDataSection; }
313 const MCSection *getDataCoalSection() const { return DataCoalSection; }
314 const MCSection *getDataCommonSection() const { return DataCommonSection; }
315 MCSection *getDataBSSSection() const { return DataBSSSection; }
316 const MCSection *getFourByteConstantSection() const {
317 return FourByteConstantSection;
319 const MCSection *getEightByteConstantSection() const {
320 return EightByteConstantSection;
322 const MCSection *getSixteenByteConstantSection() const {
323 return SixteenByteConstantSection;
325 MCSection *getLazySymbolPointerSection() const {
326 return LazySymbolPointerSection;
328 MCSection *getNonLazySymbolPointerSection() const {
329 return NonLazySymbolPointerSection;
332 // COFF specific sections.
333 MCSection *getDrectveSection() const { return DrectveSection; }
334 MCSection *getPDataSection() const { return PDataSection; }
335 MCSection *getXDataSection() const { return XDataSection; }
336 MCSection *getSXDataSection() const { return SXDataSection; }
338 MCSection *getEHFrameSection() {
340 InitEHFrameSection();
341 return EHFrameSection;
344 enum Environment { IsMachO, IsELF, IsCOFF };
345 Environment getObjectFileType() const { return Env; }
347 Reloc::Model getRelocM() const { return RelocM; }
352 CodeModel::Model CMModel;
356 void initMachOMCObjectFileInfo(Triple T);
357 void initELFMCObjectFileInfo(Triple T);
358 void initCOFFMCObjectFileInfo(Triple T);
360 /// Initialize EHFrameSection on demand.
361 void InitEHFrameSection();
364 const Triple &getTargetTriple() const { return TT; }
367 } // end namespace llvm