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 virtual ~MCObjectFileInfo() { };
193 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
196 bool getSupportsWeakOmittedEHFrame() const {
197 return SupportsWeakOmittedEHFrame;
199 bool getSupportsCompactUnwindWithoutEHFrame() const {
200 return SupportsCompactUnwindWithoutEHFrame;
202 bool getCommDirectiveSupportsAlignment() const {
203 return CommDirectiveSupportsAlignment;
206 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
207 unsigned getLSDAEncoding() const { return LSDAEncoding; }
208 unsigned getFDEEncoding() const { return FDECFIEncoding; }
209 unsigned getTTypeEncoding() const { return TTypeEncoding; }
211 unsigned getCompactUnwindDwarfEHFrameOnly() const {
212 return CompactUnwindDwarfEHFrameOnly;
215 MCSection *getTextSection() const { return TextSection; }
216 MCSection *getDataSection() const { return DataSection; }
217 MCSection *getBSSSection() const { return BSSSection; }
218 MCSection *getLSDASection() const { return LSDASection; }
219 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
220 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
221 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
222 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
223 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
224 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
225 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
226 MCSection *getDwarfGnuPubNamesSection() const {
227 return DwarfGnuPubNamesSection;
229 MCSection *getDwarfGnuPubTypesSection() const {
230 return DwarfGnuPubTypesSection;
232 const MCSection *getDwarfDebugInlineSection() const {
233 return DwarfDebugInlineSection;
235 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
236 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
237 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
238 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
240 // DWARF5 Experimental Debug Info Sections
241 MCSection *getDwarfAccelNamesSection() const {
242 return DwarfAccelNamesSection;
244 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
245 MCSection *getDwarfAccelNamespaceSection() const {
246 return DwarfAccelNamespaceSection;
248 MCSection *getDwarfAccelTypesSection() const {
249 return DwarfAccelTypesSection;
251 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
252 MCSection *getDwarfTypesSection(uint64_t Hash) const;
253 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
254 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
255 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
256 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
257 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
258 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
259 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
261 MCSection *getCOFFDebugSymbolsSection() const {
262 return COFFDebugSymbolsSection;
265 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
266 const MCSection *getTLSDataSection() const { return TLSDataSection; }
267 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
269 MCSection *getStackMapSection() const { return StackMapSection; }
271 /// ELF specific sections.
273 MCSection *getDataRelSection() const { return DataRelSection; }
274 const MCSection *getDataRelLocalSection() const {
275 return DataRelLocalSection;
277 MCSection *getDataRelROSection() const { return DataRelROSection; }
278 MCSection *getDataRelROLocalSection() const { return DataRelROLocalSection; }
279 const MCSection *getMergeableConst4Section() const {
280 return MergeableConst4Section;
282 const MCSection *getMergeableConst8Section() const {
283 return MergeableConst8Section;
285 const MCSection *getMergeableConst16Section() const {
286 return MergeableConst16Section;
289 /// MachO specific sections.
291 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
292 const MCSection *getTLSThreadInitSection() const {
293 return TLSThreadInitSection;
295 const MCSection *getCStringSection() const { return CStringSection; }
296 const MCSection *getUStringSection() const { return UStringSection; }
297 MCSection *getTextCoalSection() const { return TextCoalSection; }
298 const MCSection *getConstTextCoalSection() const {
299 return ConstTextCoalSection;
301 const MCSection *getConstDataSection() const { return ConstDataSection; }
302 const MCSection *getDataCoalSection() const { return DataCoalSection; }
303 const MCSection *getDataCommonSection() const { return DataCommonSection; }
304 MCSection *getDataBSSSection() const { return DataBSSSection; }
305 const MCSection *getFourByteConstantSection() const {
306 return FourByteConstantSection;
308 const MCSection *getEightByteConstantSection() const {
309 return EightByteConstantSection;
311 const MCSection *getSixteenByteConstantSection() const {
312 return SixteenByteConstantSection;
314 MCSection *getLazySymbolPointerSection() const {
315 return LazySymbolPointerSection;
317 MCSection *getNonLazySymbolPointerSection() const {
318 return NonLazySymbolPointerSection;
321 /// COFF specific sections.
323 MCSection *getDrectveSection() const { return DrectveSection; }
324 MCSection *getPDataSection() const { return PDataSection; }
325 MCSection *getXDataSection() const { return XDataSection; }
327 MCSection *getEHFrameSection() {
329 InitEHFrameSection();
330 return EHFrameSection;
333 enum Environment { IsMachO, IsELF, IsCOFF };
334 Environment getObjectFileType() const {
338 Reloc::Model getRelocM() const {
345 CodeModel::Model CMModel;
349 void InitMachOMCObjectFileInfo(Triple T);
350 void InitELFMCObjectFileInfo(Triple T);
351 void InitCOFFMCObjectFileInfo(Triple T);
353 /// InitEHFrameSection - Initialize EHFrameSection on demand.
355 void InitEHFrameSection();
357 virtual unsigned SelectMipsTTypeEncoding() const;
360 const Triple &getTargetTriple() const { return TT; }
363 } // end namespace llvm