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 /// Compact unwind encoding indicating that we should emit only an EH frame.
51 unsigned CompactUnwindDwarfEHFrameOnly;
53 /// Section directive for standard text.
54 MCSection *TextSection;
56 /// Section directive for standard data.
57 MCSection *DataSection;
59 /// Section that is default initialized to zero.
60 MCSection *BSSSection;
62 /// Section that is readonly and can contain arbitrary initialized data.
63 /// Targets are not required to have a readonly section. If they don't,
64 /// various bits of code will fall back to using the data section for
66 MCSection *ReadOnlySection;
68 /// This section contains the static constructor pointer list.
69 MCSection *StaticCtorSection;
71 /// This section contains the static destructor pointer list.
72 MCSection *StaticDtorSection;
74 /// If exception handling is supported by the target, this is the section the
75 /// Language Specific Data Area information is emitted to.
76 MCSection *LSDASection;
78 /// If exception handling is supported by the target and the target can
79 /// support a compact representation of the CIE and FDE, this is the section
80 /// to emit them into.
81 MCSection *CompactUnwindSection;
83 // Dwarf sections for debug info. If a target supports debug info, these must
85 MCSection *DwarfAbbrevSection;
86 MCSection *DwarfInfoSection;
87 MCSection *DwarfLineSection;
88 MCSection *DwarfFrameSection;
89 MCSection *DwarfPubTypesSection;
90 const MCSection *DwarfDebugInlineSection;
91 MCSection *DwarfStrSection;
92 MCSection *DwarfLocSection;
93 MCSection *DwarfARangesSection;
94 MCSection *DwarfRangesSection;
95 // The pubnames section is no longer generated by default. The generation
96 // can be enabled by a compiler flag.
97 MCSection *DwarfPubNamesSection;
99 /// DWARF5 Experimental Debug Info Sections
100 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
101 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
102 /// If we use the DWARF accelerated hash tables then we want to emit these
104 MCSection *DwarfAccelNamesSection;
105 MCSection *DwarfAccelObjCSection;
106 MCSection *DwarfAccelNamespaceSection;
107 MCSection *DwarfAccelTypesSection;
109 // These are used for the Fission separate debug information files.
110 MCSection *DwarfInfoDWOSection;
111 MCSection *DwarfTypesDWOSection;
112 MCSection *DwarfAbbrevDWOSection;
113 MCSection *DwarfStrDWOSection;
114 MCSection *DwarfLineDWOSection;
115 MCSection *DwarfLocDWOSection;
116 MCSection *DwarfStrOffDWOSection;
117 MCSection *DwarfAddrSection;
119 // These are for Fission DWP files.
120 MCSection *DwarfCUIndexSection;
122 /// Section for newer gnu pubnames.
123 MCSection *DwarfGnuPubNamesSection;
124 /// Section for newer gnu pubtypes.
125 MCSection *DwarfGnuPubTypesSection;
127 MCSection *COFFDebugSymbolsSection;
129 /// Extra TLS Variable Data section.
131 /// If the target needs to put additional information for a TLS variable,
133 MCSection *TLSExtraDataSection;
135 /// Section directive for Thread Local data. ELF, MachO and COFF.
136 MCSection *TLSDataSection; // Defaults to ".tdata".
138 /// Section directive for Thread Local uninitialized data.
140 /// Null if this target doesn't support a BSS section. ELF and MachO only.
141 MCSection *TLSBSSSection; // Defaults to ".tbss".
143 /// StackMap section.
144 MCSection *StackMapSection;
146 /// FaultMap section.
147 MCSection *FaultMapSection;
149 /// EH frame section.
151 /// It is initialized on demand so it can be overwritten (with uniquing).
152 MCSection *EHFrameSection;
154 // ELF specific sections.
155 MCSection *DataRelROSection;
156 MCSection *MergeableConst4Section;
157 MCSection *MergeableConst8Section;
158 MCSection *MergeableConst16Section;
160 // MachO specific sections.
162 /// Section for thread local structure information.
164 /// Contains the source code name of the variable, visibility and a pointer to
165 /// the initial value (.tdata or .tbss).
166 MCSection *TLSTLVSection; // Defaults to ".tlv".
168 /// Section for thread local data initialization functions.
169 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
171 MCSection *CStringSection;
172 MCSection *UStringSection;
173 MCSection *TextCoalSection;
174 MCSection *ConstTextCoalSection;
175 MCSection *ConstDataSection;
176 MCSection *DataCoalSection;
177 MCSection *DataCommonSection;
178 MCSection *DataBSSSection;
179 MCSection *FourByteConstantSection;
180 MCSection *EightByteConstantSection;
181 MCSection *SixteenByteConstantSection;
182 MCSection *LazySymbolPointerSection;
183 MCSection *NonLazySymbolPointerSection;
185 /// COFF specific sections.
186 MCSection *DrectveSection;
187 MCSection *PDataSection;
188 MCSection *XDataSection;
189 MCSection *SXDataSection;
192 void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM,
193 CodeModel::Model CM, MCContext &ctx);
194 LLVM_ATTRIBUTE_DEPRECATED(
195 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM,
196 CodeModel::Model CM, MCContext &ctx),
197 "StringRef GNU Triple argument replaced by a llvm::Triple object");
199 bool getSupportsWeakOmittedEHFrame() const {
200 return SupportsWeakOmittedEHFrame;
202 bool getSupportsCompactUnwindWithoutEHFrame() const {
203 return SupportsCompactUnwindWithoutEHFrame;
205 bool getOmitDwarfIfHaveCompactUnwind() const {
206 return OmitDwarfIfHaveCompactUnwind;
209 bool getCommDirectiveSupportsAlignment() const {
210 return CommDirectiveSupportsAlignment;
213 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
214 unsigned getLSDAEncoding() const { return LSDAEncoding; }
215 unsigned getFDEEncoding() const { return FDECFIEncoding; }
216 unsigned getTTypeEncoding() const { return TTypeEncoding; }
218 unsigned getCompactUnwindDwarfEHFrameOnly() const {
219 return CompactUnwindDwarfEHFrameOnly;
222 MCSection *getTextSection() const { return TextSection; }
223 MCSection *getDataSection() const { return DataSection; }
224 MCSection *getBSSSection() const { return BSSSection; }
225 MCSection *getReadOnlySection() const { return ReadOnlySection; }
226 MCSection *getLSDASection() const { return LSDASection; }
227 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
228 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
229 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
230 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
231 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
232 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
233 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
234 MCSection *getDwarfGnuPubNamesSection() const {
235 return DwarfGnuPubNamesSection;
237 MCSection *getDwarfGnuPubTypesSection() const {
238 return DwarfGnuPubTypesSection;
240 const MCSection *getDwarfDebugInlineSection() const {
241 return DwarfDebugInlineSection;
243 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
244 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
245 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
246 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
248 // DWARF5 Experimental Debug Info Sections
249 MCSection *getDwarfAccelNamesSection() const {
250 return DwarfAccelNamesSection;
252 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
253 MCSection *getDwarfAccelNamespaceSection() const {
254 return DwarfAccelNamespaceSection;
256 MCSection *getDwarfAccelTypesSection() const {
257 return DwarfAccelTypesSection;
259 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
260 MCSection *getDwarfTypesSection(uint64_t Hash) const;
261 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
262 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
263 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
264 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
265 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
266 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
267 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
268 MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
270 MCSection *getCOFFDebugSymbolsSection() const {
271 return COFFDebugSymbolsSection;
274 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
275 const MCSection *getTLSDataSection() const { return TLSDataSection; }
276 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
278 MCSection *getStackMapSection() const { return StackMapSection; }
279 MCSection *getFaultMapSection() const { return FaultMapSection; }
281 // ELF specific sections.
282 MCSection *getDataRelROSection() const { return DataRelROSection; }
283 const MCSection *getMergeableConst4Section() const {
284 return MergeableConst4Section;
286 const MCSection *getMergeableConst8Section() const {
287 return MergeableConst8Section;
289 const MCSection *getMergeableConst16Section() const {
290 return MergeableConst16Section;
293 // MachO specific sections.
294 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
295 const MCSection *getTLSThreadInitSection() const {
296 return TLSThreadInitSection;
298 const MCSection *getCStringSection() const { return CStringSection; }
299 const MCSection *getUStringSection() const { return UStringSection; }
300 MCSection *getTextCoalSection() const { return TextCoalSection; }
301 const MCSection *getConstTextCoalSection() const {
302 return ConstTextCoalSection;
304 const MCSection *getConstDataSection() const { return ConstDataSection; }
305 const MCSection *getDataCoalSection() const { return DataCoalSection; }
306 const MCSection *getDataCommonSection() const { return DataCommonSection; }
307 MCSection *getDataBSSSection() const { return DataBSSSection; }
308 const MCSection *getFourByteConstantSection() const {
309 return FourByteConstantSection;
311 const MCSection *getEightByteConstantSection() const {
312 return EightByteConstantSection;
314 const MCSection *getSixteenByteConstantSection() const {
315 return SixteenByteConstantSection;
317 MCSection *getLazySymbolPointerSection() const {
318 return LazySymbolPointerSection;
320 MCSection *getNonLazySymbolPointerSection() const {
321 return NonLazySymbolPointerSection;
324 // COFF specific sections.
325 MCSection *getDrectveSection() const { return DrectveSection; }
326 MCSection *getPDataSection() const { return PDataSection; }
327 MCSection *getXDataSection() const { return XDataSection; }
328 MCSection *getSXDataSection() const { return SXDataSection; }
330 MCSection *getEHFrameSection() {
331 return EHFrameSection;
334 enum Environment { IsMachO, IsELF, IsCOFF };
335 Environment getObjectFileType() const { return Env; }
337 Reloc::Model getRelocM() const { return RelocM; }
342 CodeModel::Model CMModel;
346 void initMachOMCObjectFileInfo(Triple T);
347 void initELFMCObjectFileInfo(Triple T);
348 void initCOFFMCObjectFileInfo(Triple T);
351 const Triple &getTargetTriple() const { return TT; }
354 } // end namespace llvm