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_MCBJECTFILEINFO_H
15 #define LLVM_MC_MCBJECTFILEINFO_H
17 #include "llvm/MC/MCCodeGenInfo.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
26 class MCObjectFileInfo {
28 /// CommDirectiveSupportsAlignment - True if .comm supports alignment. This
29 /// is a hack for as long as we support 10.4 Tiger, whose assembler doesn't
30 /// support alignment on comm.
31 bool CommDirectiveSupportsAlignment;
33 /// SupportsWeakEmptyEHFrame - True if target object file supports a
34 /// weak_definition of constant 0 for an omitted EH frame.
35 bool SupportsWeakOmittedEHFrame;
37 /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the
38 /// "EH_frame" symbol for EH information should be an assembler temporary (aka
39 /// private linkage, aka an L or .L label) or false if it should be a normal
40 /// non-.globl label. This defaults to true.
41 bool IsFunctionEHFrameSymbolPrivate;
43 /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some
44 /// encoding values for EH.
45 unsigned PersonalityEncoding;
46 unsigned LSDAEncoding;
48 unsigned FDECFIEncoding;
49 unsigned TTypeEncoding;
51 /// TextSection - Section directive for standard text.
53 const MCSection *TextSection;
55 /// DataSection - Section directive for standard data.
57 const MCSection *DataSection;
59 /// BSSSection - Section that is default initialized to zero.
60 const MCSection *BSSSection;
62 /// ReadOnlySection - Section that is readonly and can contain arbitrary
63 /// initialized data. Targets are not required to have a readonly section.
64 /// If they don't, various bits of code will fall back to using the data
65 /// section for constants.
66 const MCSection *ReadOnlySection;
68 /// StaticCtorSection - This section contains the static constructor pointer
70 const MCSection *StaticCtorSection;
72 /// StaticDtorSection - This section contains the static destructor pointer
74 const MCSection *StaticDtorSection;
76 /// LSDASection - If exception handling is supported by the target, this is
77 /// the section the Language Specific Data Area information is emitted to.
78 const MCSection *LSDASection;
80 /// CompactUnwindSection - If exception handling is supported by the target
81 /// and the target can support a compact representation of the CIE and FDE,
82 /// this is the section to emit them into.
83 const MCSection *CompactUnwindSection;
85 /// DwarfAccelNamesSection, DwarfAccelObjCSection
86 /// If we use the DWARF accelerated hash tables then we want toe emit these
88 const MCSection *DwarfAccelNamesSection;
89 const MCSection *DwarfAccelObjCSection;
90 const MCSection *DwarfAccelNamespaceSection;
91 const MCSection *DwarfAccelTypesSection;
93 // Dwarf sections for debug info. If a target supports debug info, these must
95 const MCSection *DwarfAbbrevSection;
96 const MCSection *DwarfInfoSection;
97 const MCSection *DwarfLineSection;
98 const MCSection *DwarfFrameSection;
99 const MCSection *DwarfPubTypesSection;
100 const MCSection *DwarfDebugInlineSection;
101 const MCSection *DwarfStrSection;
102 const MCSection *DwarfLocSection;
103 const MCSection *DwarfARangesSection;
104 const MCSection *DwarfRangesSection;
105 const MCSection *DwarfMacroInfoSection;
107 // Extra TLS Variable Data section. If the target needs to put additional
108 // information for a TLS variable, it'll go here.
109 const MCSection *TLSExtraDataSection;
111 /// TLSDataSection - Section directive for Thread Local data.
112 /// ELF and MachO only.
113 const MCSection *TLSDataSection; // Defaults to ".tdata".
115 /// TLSBSSSection - Section directive for Thread Local uninitialized data.
116 /// Null if this target doesn't support a BSS section.
117 /// ELF and MachO only.
118 const MCSection *TLSBSSSection; // Defaults to ".tbss".
121 /// EHFrameSection - EH frame section. It is initialized on demand so it
122 /// can be overwritten (with uniquing).
123 const MCSection *EHFrameSection;
125 /// ELF specific sections.
127 const MCSection *DataRelSection;
128 const MCSection *DataRelLocalSection;
129 const MCSection *DataRelROSection;
130 const MCSection *DataRelROLocalSection;
131 const MCSection *MergeableConst4Section;
132 const MCSection *MergeableConst8Section;
133 const MCSection *MergeableConst16Section;
135 /// MachO specific sections.
138 /// TLSTLVSection - Section for thread local structure information.
139 /// Contains the source code name of the variable, visibility and a pointer
140 /// to the initial value (.tdata or .tbss).
141 const MCSection *TLSTLVSection; // Defaults to ".tlv".
143 /// TLSThreadInitSection - Section for thread local data initialization
145 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func".
147 const MCSection *CStringSection;
148 const MCSection *UStringSection;
149 const MCSection *TextCoalSection;
150 const MCSection *ConstTextCoalSection;
151 const MCSection *ConstDataSection;
152 const MCSection *DataCoalSection;
153 const MCSection *DataCommonSection;
154 const MCSection *DataBSSSection;
155 const MCSection *FourByteConstantSection;
156 const MCSection *EightByteConstantSection;
157 const MCSection *SixteenByteConstantSection;
158 const MCSection *LazySymbolPointerSection;
159 const MCSection *NonLazySymbolPointerSection;
161 /// COFF specific sections.
163 const MCSection *DrectveSection;
164 const MCSection *PDataSection;
165 const MCSection *XDataSection;
168 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM,
171 bool isFunctionEHFrameSymbolPrivate() const {
172 return IsFunctionEHFrameSymbolPrivate;
174 bool getSupportsWeakOmittedEHFrame() const {
175 return SupportsWeakOmittedEHFrame;
177 bool getCommDirectiveSupportsAlignment() const {
178 return CommDirectiveSupportsAlignment;
181 unsigned getPersonalityEncoding() const { return PersonalityEncoding; }
182 unsigned getLSDAEncoding() const { return LSDAEncoding; }
183 unsigned getFDEEncoding(bool CFI) const {
184 return CFI ? FDECFIEncoding : FDEEncoding;
186 unsigned getTTypeEncoding() const { return TTypeEncoding; }
188 const MCSection *getTextSection() const { return TextSection; }
189 const MCSection *getDataSection() const { return DataSection; }
190 const MCSection *getBSSSection() const { return BSSSection; }
191 const MCSection *getLSDASection() const { return LSDASection; }
192 const MCSection *getCompactUnwindSection() const{
193 return CompactUnwindSection;
195 const MCSection *getDwarfAccelNamesSection() const {
196 return DwarfAccelNamesSection;
198 const MCSection *getDwarfAccelObjCSection() const {
199 return DwarfAccelObjCSection;
201 const MCSection *getDwarfAccelNamespaceSection() const {
202 return DwarfAccelNamespaceSection;
204 const MCSection *getDwarfAccelTypesSection() const {
205 return DwarfAccelTypesSection;
207 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
208 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
209 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
210 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
211 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;}
212 const MCSection *getDwarfDebugInlineSection() const {
213 return DwarfDebugInlineSection;
215 const MCSection *getDwarfStrSection() const { return DwarfStrSection; }
216 const MCSection *getDwarfLocSection() const { return DwarfLocSection; }
217 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;}
218 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
219 const MCSection *getDwarfMacroInfoSection() const {
220 return DwarfMacroInfoSection;
222 const MCSection *getTLSExtraDataSection() const {
223 return TLSExtraDataSection;
225 const MCSection *getTLSDataSection() const { return TLSDataSection; }
226 const MCSection *getTLSBSSSection() const { return TLSBSSSection; }
228 /// ELF specific sections.
230 const MCSection *getDataRelSection() const { return DataRelSection; }
231 const MCSection *getDataRelLocalSection() const {
232 return DataRelLocalSection;
234 const MCSection *getDataRelROSection() const { return DataRelROSection; }
235 const MCSection *getDataRelROLocalSection() const {
236 return DataRelROLocalSection;
238 const MCSection *getMergeableConst4Section() const {
239 return MergeableConst4Section;
241 const MCSection *getMergeableConst8Section() const {
242 return MergeableConst8Section;
244 const MCSection *getMergeableConst16Section() const {
245 return MergeableConst16Section;
248 /// MachO specific sections.
250 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
251 const MCSection *getTLSThreadInitSection() const {
252 return TLSThreadInitSection;
254 const MCSection *getCStringSection() const { return CStringSection; }
255 const MCSection *getUStringSection() const { return UStringSection; }
256 const MCSection *getTextCoalSection() const { return TextCoalSection; }
257 const MCSection *getConstTextCoalSection() const {
258 return ConstTextCoalSection;
260 const MCSection *getConstDataSection() const { return ConstDataSection; }
261 const MCSection *getDataCoalSection() const { return DataCoalSection; }
262 const MCSection *getDataCommonSection() const { return DataCommonSection; }
263 const MCSection *getDataBSSSection() const { return DataBSSSection; }
264 const MCSection *getFourByteConstantSection() const {
265 return FourByteConstantSection;
267 const MCSection *getEightByteConstantSection() const {
268 return EightByteConstantSection;
270 const MCSection *getSixteenByteConstantSection() const {
271 return SixteenByteConstantSection;
273 const MCSection *getLazySymbolPointerSection() const {
274 return LazySymbolPointerSection;
276 const MCSection *getNonLazySymbolPointerSection() const {
277 return NonLazySymbolPointerSection;
280 /// COFF specific sections.
282 const MCSection *getDrectveSection() const { return DrectveSection; }
283 const MCSection *getPDataSection() const { return PDataSection; }
284 const MCSection *getXDataSection() const { return XDataSection; }
286 const MCSection *getEHFrameSection() {
288 InitEHFrameSection();
289 return EHFrameSection;
293 enum Environment { IsMachO, IsELF, IsCOFF };
296 CodeModel::Model CMModel;
299 void InitMachOMCObjectFileInfo(Triple T);
300 void InitELFMCObjectFileInfo(Triple T);
301 void InitCOFFMCObjectFileInfo(Triple T);
303 /// InitEHFrameSection - Initialize EHFrameSection on demand.
305 void InitEHFrameSection();
308 } // end namespace llvm