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 /// Some encoding values for EH.
39 unsigned PersonalityEncoding;
40 unsigned LSDAEncoding;
41 unsigned FDECFIEncoding;
42 unsigned TTypeEncoding;
44 /// Section flags for eh_frame
45 unsigned EHSectionType;
46 unsigned EHSectionFlags;
48 /// Compact unwind encoding indicating that we should emit only an EH frame.
49 unsigned CompactUnwindDwarfEHFrameOnly;
51 /// Section directive for standard text.
52 MCSection *TextSection;
54 /// Section directive for standard data.
55 MCSection *DataSection;
57 /// Section that is default initialized to zero.
58 MCSection *BSSSection;
60 /// Section that is readonly and can contain arbitrary initialized data.
61 /// Targets are not required to have a readonly section. If they don't,
62 /// various bits of code will fall back to using the data section for
64 MCSection *ReadOnlySection;
66 /// This section contains the static constructor pointer list.
67 MCSection *StaticCtorSection;
69 /// This section contains the static destructor pointer list.
70 MCSection *StaticDtorSection;
72 /// If exception handling is supported by the target, this is the section the
73 /// Language Specific Data Area information is emitted to.
74 MCSection *LSDASection;
76 /// If exception handling is supported by the target and the target can
77 /// support a compact representation of the CIE and FDE, this is the section
78 /// to emit them into.
79 MCSection *CompactUnwindSection;
81 // Dwarf sections for debug info. If a target supports debug info, these must
83 MCSection *DwarfAbbrevSection;
84 MCSection *DwarfInfoSection;
85 MCSection *DwarfLineSection;
86 MCSection *DwarfFrameSection;
87 MCSection *DwarfPubTypesSection;
88 const MCSection *DwarfDebugInlineSection;
89 MCSection *DwarfStrSection;
90 MCSection *DwarfLocSection;
91 MCSection *DwarfARangesSection;
92 MCSection *DwarfRangesSection;
93 // The pubnames section is no longer generated by default. The generation
94 // can be enabled by a compiler flag.
95 MCSection *DwarfPubNamesSection;
97 /// DWARF5 Experimental Debug Info Sections
98 /// DwarfAccelNamesSection, DwarfAccelObjCSection,
99 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection -
100 /// If we use the DWARF accelerated hash tables then we want to emit these
102 MCSection *DwarfAccelNamesSection;
103 MCSection *DwarfAccelObjCSection;
104 MCSection *DwarfAccelNamespaceSection;
105 MCSection *DwarfAccelTypesSection;
107 // These are used for the Fission separate debug information files.
108 MCSection *DwarfInfoDWOSection;
109 MCSection *DwarfTypesDWOSection;
110 MCSection *DwarfAbbrevDWOSection;
111 MCSection *DwarfStrDWOSection;
112 MCSection *DwarfLineDWOSection;
113 MCSection *DwarfLocDWOSection;
114 MCSection *DwarfStrOffDWOSection;
115 MCSection *DwarfAddrSection;
117 /// Section for newer gnu pubnames.
118 MCSection *DwarfGnuPubNamesSection;
119 /// Section for newer gnu pubtypes.
120 MCSection *DwarfGnuPubTypesSection;
122 MCSection *COFFDebugSymbolsSection;
124 /// Extra TLS Variable Data section.
126 /// If the target needs to put additional information for a TLS variable,
128 MCSection *TLSExtraDataSection;
130 /// Section directive for Thread Local data. ELF, MachO and COFF.
131 MCSection *TLSDataSection; // Defaults to ".tdata".
133 /// Section directive for Thread Local uninitialized data.
135 /// Null if this target doesn't support a BSS section. ELF and MachO only.
136 MCSection *TLSBSSSection; // Defaults to ".tbss".
138 /// StackMap section.
139 MCSection *StackMapSection;
141 /// FaultMap section.
142 MCSection *FaultMapSection;
144 /// EH frame section.
146 /// It is initialized on demand so it can be overwritten (with uniquing).
147 MCSection *EHFrameSection;
149 // 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.
160 /// Section for thread local structure information.
162 /// Contains the source code name of the variable, visibility and a pointer to
163 /// the initial value (.tdata or .tbss).
164 MCSection *TLSTLVSection; // Defaults to ".tlv".
166 /// Section for thread local data initialization functions.
167 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
169 MCSection *CStringSection;
170 MCSection *UStringSection;
171 MCSection *TextCoalSection;
172 MCSection *ConstTextCoalSection;
173 MCSection *ConstDataSection;
174 MCSection *DataCoalSection;
175 MCSection *DataCommonSection;
176 MCSection *DataBSSSection;
177 MCSection *FourByteConstantSection;
178 MCSection *EightByteConstantSection;
179 MCSection *SixteenByteConstantSection;
180 MCSection *LazySymbolPointerSection;
181 MCSection *NonLazySymbolPointerSection;
183 /// COFF specific sections.
184 MCSection *DrectveSection;
185 MCSection *PDataSection;
186 MCSection *XDataSection;
187 MCSection *SXDataSection;
190 void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM,
191 CodeModel::Model CM, MCContext &ctx);
192 LLVM_ATTRIBUTE_DEPRECATED(
193 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM,
194 CodeModel::Model CM, MCContext &ctx),
195 "StringRef GNU Triple argument replaced by a llvm::Triple object");
197 bool getSupportsWeakOmittedEHFrame() const {
198 return SupportsWeakOmittedEHFrame;
200 bool getSupportsCompactUnwindWithoutEHFrame() const {
201 return SupportsCompactUnwindWithoutEHFrame;
203 bool getCommDirectiveSupportsAlignment() const {
204 return CommDirectiveSupportsAlignment;
207 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
208 unsigned getLSDAEncoding() const { return LSDAEncoding; }
209 unsigned getFDEEncoding() const { return FDECFIEncoding; }
210 unsigned getTTypeEncoding() const { return TTypeEncoding; }
212 unsigned getCompactUnwindDwarfEHFrameOnly() const {
213 return CompactUnwindDwarfEHFrameOnly;
216 MCSection *getTextSection() const { return TextSection; }
217 MCSection *getDataSection() const { return DataSection; }
218 MCSection *getBSSSection() const { return BSSSection; }
219 MCSection *getReadOnlySection() const { return ReadOnlySection; }
220 MCSection *getLSDASection() const { return LSDASection; }
221 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
222 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
223 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
224 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
225 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
226 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
227 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
228 MCSection *getDwarfGnuPubNamesSection() const {
229 return DwarfGnuPubNamesSection;
231 MCSection *getDwarfGnuPubTypesSection() const {
232 return DwarfGnuPubTypesSection;
234 const MCSection *getDwarfDebugInlineSection() const {
235 return DwarfDebugInlineSection;
237 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
238 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
239 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
240 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
242 // DWARF5 Experimental Debug Info Sections
243 MCSection *getDwarfAccelNamesSection() const {
244 return DwarfAccelNamesSection;
246 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
247 MCSection *getDwarfAccelNamespaceSection() const {
248 return DwarfAccelNamespaceSection;
250 MCSection *getDwarfAccelTypesSection() const {
251 return DwarfAccelTypesSection;
253 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
254 MCSection *getDwarfTypesSection(uint64_t Hash) const;
255 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
256 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
257 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
258 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
259 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
260 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
261 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
263 MCSection *getCOFFDebugSymbolsSection() const {
264 return COFFDebugSymbolsSection;
267 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
268 const MCSection *getTLSDataSection() const { return TLSDataSection; }
269 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
271 MCSection *getStackMapSection() const { return StackMapSection; }
272 MCSection *getFaultMapSection() const { return FaultMapSection; }
274 // ELF specific sections.
275 MCSection *getDataRelSection() const { return DataRelSection; }
276 const MCSection *getDataRelLocalSection() const {
277 return DataRelLocalSection;
279 MCSection *getDataRelROSection() const { return DataRelROSection; }
280 MCSection *getDataRelROLocalSection() const { return DataRelROLocalSection; }
281 const MCSection *getMergeableConst4Section() const {
282 return MergeableConst4Section;
284 const MCSection *getMergeableConst8Section() const {
285 return MergeableConst8Section;
287 const MCSection *getMergeableConst16Section() const {
288 return MergeableConst16Section;
291 // MachO specific sections.
292 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
293 const MCSection *getTLSThreadInitSection() const {
294 return TLSThreadInitSection;
296 const MCSection *getCStringSection() const { return CStringSection; }
297 const MCSection *getUStringSection() const { return UStringSection; }
298 MCSection *getTextCoalSection() const { return TextCoalSection; }
299 const MCSection *getConstTextCoalSection() const {
300 return ConstTextCoalSection;
302 const MCSection *getConstDataSection() const { return ConstDataSection; }
303 const MCSection *getDataCoalSection() const { return DataCoalSection; }
304 const MCSection *getDataCommonSection() const { return DataCommonSection; }
305 MCSection *getDataBSSSection() const { return DataBSSSection; }
306 const MCSection *getFourByteConstantSection() const {
307 return FourByteConstantSection;
309 const MCSection *getEightByteConstantSection() const {
310 return EightByteConstantSection;
312 const MCSection *getSixteenByteConstantSection() const {
313 return SixteenByteConstantSection;
315 MCSection *getLazySymbolPointerSection() const {
316 return LazySymbolPointerSection;
318 MCSection *getNonLazySymbolPointerSection() const {
319 return NonLazySymbolPointerSection;
322 // COFF specific sections.
323 MCSection *getDrectveSection() const { return DrectveSection; }
324 MCSection *getPDataSection() const { return PDataSection; }
325 MCSection *getXDataSection() const { return XDataSection; }
326 MCSection *getSXDataSection() const { return SXDataSection; }
328 MCSection *getEHFrameSection() {
330 InitEHFrameSection();
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);
350 /// Initialize EHFrameSection on demand.
351 void InitEHFrameSection();
354 const Triple &getTargetTriple() const { return TT; }
357 } // end namespace llvm