MCObjectFileInfo.h revision 0cb2a45cceaefb48ec7efb902c453aaae4e24cb2
1//===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This file describes common object file formats. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef LLVM_MC_MCBJECTFILEINFO_H 15#define LLVM_MC_MCBJECTFILEINFO_H 16 17#include "llvm/MC/MCCodeGenInfo.h" 18#include "llvm/ADT/StringRef.h" 19#include "llvm/MC/SectionKind.h" 20 21namespace llvm { 22 class MCContext; 23 class MCSection; 24 class Triple; 25 26 namespace Structors { 27 enum OutputOrder { None, PriorityOrder, ReversePriorityOrder }; 28 } 29 30class MCObjectFileInfo { 31protected: 32 /// CommDirectiveSupportsAlignment - True if .comm supports alignment. This 33 /// is a hack for as long as we support 10.4 Tiger, whose assembler doesn't 34 /// support alignment on comm. 35 bool CommDirectiveSupportsAlignment; 36 37 /// SupportsWeakEmptyEHFrame - True if target object file supports a 38 /// weak_definition of constant 0 for an omitted EH frame. 39 bool SupportsWeakOmittedEHFrame; 40 41 /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the 42 /// "EH_frame" symbol for EH information should be an assembler temporary (aka 43 /// private linkage, aka an L or .L label) or false if it should be a normal 44 /// non-.globl label. This defaults to true. 45 bool IsFunctionEHFrameSymbolPrivate; 46 47 /// PersonalityEncoding, LSDAEncoding, FDEEncoding, TTypeEncoding - Some 48 /// encoding values for EH. 49 unsigned PersonalityEncoding; 50 unsigned LSDAEncoding; 51 unsigned FDEEncoding; 52 unsigned FDECFIEncoding; 53 unsigned TTypeEncoding; 54 55 /// TextSection - Section directive for standard text. 56 /// 57 const MCSection *TextSection; 58 59 /// DataSection - Section directive for standard data. 60 /// 61 const MCSection *DataSection; 62 63 /// BSSSection - Section that is default initialized to zero. 64 const MCSection *BSSSection; 65 66 /// ReadOnlySection - Section that is readonly and can contain arbitrary 67 /// initialized data. Targets are not required to have a readonly section. 68 /// If they don't, various bits of code will fall back to using the data 69 /// section for constants. 70 const MCSection *ReadOnlySection; 71 72 /// StaticCtorSection - This section contains the static constructor pointer 73 /// list. 74 const MCSection *StaticCtorSection; 75 76 /// StaticDtorSection - This section contains the static destructor pointer 77 /// list. 78 const MCSection *StaticDtorSection; 79 80 /// LSDASection - If exception handling is supported by the target, this is 81 /// the section the Language Specific Data Area information is emitted to. 82 const MCSection *LSDASection; 83 84 /// CompactUnwindSection - If exception handling is supported by the target 85 /// and the target can support a compact representation of the CIE and FDE, 86 /// this is the section to emit them into. 87 const MCSection *CompactUnwindSection; 88 89 /// DwarfAccelNamesSection, DwarfAccelObjCSection 90 /// If we use the DWARF accelerated hash tables then we want toe emit these 91 /// sections. 92 const MCSection *DwarfAccelNamesSection; 93 const MCSection *DwarfAccelObjCSection; 94 const MCSection *DwarfAccelNamespaceSection; 95 const MCSection *DwarfAccelTypesSection; 96 97 // Dwarf sections for debug info. If a target supports debug info, these must 98 // be set. 99 const MCSection *DwarfAbbrevSection; 100 const MCSection *DwarfInfoSection; 101 const MCSection *DwarfLineSection; 102 const MCSection *DwarfFrameSection; 103 const MCSection *DwarfPubTypesSection; 104 const MCSection *DwarfDebugInlineSection; 105 const MCSection *DwarfStrSection; 106 const MCSection *DwarfLocSection; 107 const MCSection *DwarfARangesSection; 108 const MCSection *DwarfRangesSection; 109 const MCSection *DwarfMacroInfoSection; 110 111 // Extra TLS Variable Data section. If the target needs to put additional 112 // information for a TLS variable, it'll go here. 113 const MCSection *TLSExtraDataSection; 114 115 /// TLSDataSection - Section directive for Thread Local data. 116 /// ELF and MachO only. 117 const MCSection *TLSDataSection; // Defaults to ".tdata". 118 119 /// TLSBSSSection - Section directive for Thread Local uninitialized data. 120 /// Null if this target doesn't support a BSS section. 121 /// ELF and MachO only. 122 const MCSection *TLSBSSSection; // Defaults to ".tbss". 123 124 125 /// EHFrameSection - EH frame section. It is initialized on demand so it 126 /// can be overwritten (with uniquing). 127 const MCSection *EHFrameSection; 128 129 /// ELF specific sections. 130 /// 131 const MCSection *DataRelSection; 132 const MCSection *DataRelLocalSection; 133 const MCSection *DataRelROSection; 134 const MCSection *DataRelROLocalSection; 135 const MCSection *MergeableConst4Section; 136 const MCSection *MergeableConst8Section; 137 const MCSection *MergeableConst16Section; 138 139 /// MachO specific sections. 140 /// 141 142 /// TLSTLVSection - Section for thread local structure information. 143 /// Contains the source code name of the variable, visibility and a pointer 144 /// to the initial value (.tdata or .tbss). 145 const MCSection *TLSTLVSection; // Defaults to ".tlv". 146 147 /// TLSThreadInitSection - Section for thread local data initialization 148 /// functions. 149 const MCSection *TLSThreadInitSection; // Defaults to ".thread_init_func". 150 151 const MCSection *CStringSection; 152 const MCSection *UStringSection; 153 const MCSection *TextCoalSection; 154 const MCSection *ConstTextCoalSection; 155 const MCSection *ConstDataSection; 156 const MCSection *DataCoalSection; 157 const MCSection *DataCommonSection; 158 const MCSection *DataBSSSection; 159 const MCSection *FourByteConstantSection; 160 const MCSection *EightByteConstantSection; 161 const MCSection *SixteenByteConstantSection; 162 const MCSection *LazySymbolPointerSection; 163 const MCSection *NonLazySymbolPointerSection; 164 165 /// COFF specific sections. 166 /// 167 const MCSection *DrectveSection; 168 const MCSection *PDataSection; 169 const MCSection *XDataSection; 170 171 /// StructorOutputOrder - Whether the static ctor/dtor list should be output 172 /// in no particular order, in order of increasing priority or the reverse: 173 /// in order of decreasing priority (the default). 174 Structors::OutputOrder StructorOutputOrder; // Default is reverse order. 175 176public: 177 void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, 178 MCContext &ctx); 179 180 bool isFunctionEHFrameSymbolPrivate() const { 181 return IsFunctionEHFrameSymbolPrivate; 182 } 183 bool getSupportsWeakOmittedEHFrame() const { 184 return SupportsWeakOmittedEHFrame; 185 } 186 bool getCommDirectiveSupportsAlignment() const { 187 return CommDirectiveSupportsAlignment; 188 } 189 190 unsigned getPersonalityEncoding() const { return PersonalityEncoding; } 191 unsigned getLSDAEncoding() const { return LSDAEncoding; } 192 unsigned getFDEEncoding(bool CFI) const { 193 return CFI ? FDECFIEncoding : FDEEncoding; 194 } 195 unsigned getTTypeEncoding() const { return TTypeEncoding; } 196 197 const MCSection *getTextSection() const { return TextSection; } 198 const MCSection *getDataSection() const { return DataSection; } 199 const MCSection *getBSSSection() const { return BSSSection; } 200 const MCSection *getStaticCtorSection() const { return StaticCtorSection; } 201 const MCSection *getStaticDtorSection() const { return StaticDtorSection; } 202 const MCSection *getLSDASection() const { return LSDASection; } 203 const MCSection *getCompactUnwindSection() const{ 204 return CompactUnwindSection; 205 } 206 const MCSection *getDwarfAccelNamesSection() const { 207 return DwarfAccelNamesSection; 208 } 209 const MCSection *getDwarfAccelObjCSection() const { 210 return DwarfAccelObjCSection; 211 } 212 const MCSection *getDwarfAccelNamespaceSection() const { 213 return DwarfAccelNamespaceSection; 214 } 215 const MCSection *getDwarfAccelTypesSection() const { 216 return DwarfAccelTypesSection; 217 } 218 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; } 219 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; } 220 const MCSection *getDwarfLineSection() const { return DwarfLineSection; } 221 const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; } 222 const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;} 223 const MCSection *getDwarfDebugInlineSection() const { 224 return DwarfDebugInlineSection; 225 } 226 const MCSection *getDwarfStrSection() const { return DwarfStrSection; } 227 const MCSection *getDwarfLocSection() const { return DwarfLocSection; } 228 const MCSection *getDwarfARangesSection() const { return DwarfARangesSection;} 229 const MCSection *getDwarfRangesSection() const { return DwarfRangesSection; } 230 const MCSection *getDwarfMacroInfoSection() const { 231 return DwarfMacroInfoSection; 232 } 233 const MCSection *getTLSExtraDataSection() const { 234 return TLSExtraDataSection; 235 } 236 const MCSection *getTLSDataSection() const { return TLSDataSection; } 237 const MCSection *getTLSBSSSection() const { return TLSBSSSection; } 238 239 /// ELF specific sections. 240 /// 241 const MCSection *getDataRelSection() const { return DataRelSection; } 242 const MCSection *getDataRelLocalSection() const { 243 return DataRelLocalSection; 244 } 245 const MCSection *getDataRelROSection() const { return DataRelROSection; } 246 const MCSection *getDataRelROLocalSection() const { 247 return DataRelROLocalSection; 248 } 249 const MCSection *getMergeableConst4Section() const { 250 return MergeableConst4Section; 251 } 252 const MCSection *getMergeableConst8Section() const { 253 return MergeableConst8Section; 254 } 255 const MCSection *getMergeableConst16Section() const { 256 return MergeableConst16Section; 257 } 258 259 /// MachO specific sections. 260 /// 261 const MCSection *getTLSTLVSection() const { return TLSTLVSection; } 262 const MCSection *getTLSThreadInitSection() const { 263 return TLSThreadInitSection; 264 } 265 const MCSection *getCStringSection() const { return CStringSection; } 266 const MCSection *getUStringSection() const { return UStringSection; } 267 const MCSection *getTextCoalSection() const { return TextCoalSection; } 268 const MCSection *getConstTextCoalSection() const { 269 return ConstTextCoalSection; 270 } 271 const MCSection *getConstDataSection() const { return ConstDataSection; } 272 const MCSection *getDataCoalSection() const { return DataCoalSection; } 273 const MCSection *getDataCommonSection() const { return DataCommonSection; } 274 const MCSection *getDataBSSSection() const { return DataBSSSection; } 275 const MCSection *getFourByteConstantSection() const { 276 return FourByteConstantSection; 277 } 278 const MCSection *getEightByteConstantSection() const { 279 return EightByteConstantSection; 280 } 281 const MCSection *getSixteenByteConstantSection() const { 282 return SixteenByteConstantSection; 283 } 284 const MCSection *getLazySymbolPointerSection() const { 285 return LazySymbolPointerSection; 286 } 287 const MCSection *getNonLazySymbolPointerSection() const { 288 return NonLazySymbolPointerSection; 289 } 290 291 /// COFF specific sections. 292 /// 293 const MCSection *getDrectveSection() const { return DrectveSection; } 294 const MCSection *getPDataSection() const { return PDataSection; } 295 const MCSection *getXDataSection() const { return XDataSection; } 296 297 const MCSection *getEHFrameSection() { 298 if (!EHFrameSection) 299 InitEHFrameSection(); 300 return EHFrameSection; 301 } 302 303 Structors::OutputOrder getStructorOutputOrder() const { 304 return StructorOutputOrder; 305 } 306 307private: 308 enum Environment { IsMachO, IsELF, IsCOFF }; 309 Environment Env; 310 Reloc::Model RelocM; 311 CodeModel::Model CMModel; 312 MCContext *Ctx; 313 314 void InitMachOMCObjectFileInfo(Triple T); 315 void InitELFMCObjectFileInfo(Triple T); 316 void InitCOFFMCObjectFileInfo(Triple T); 317 318 /// InitEHFrameSection - Initialize EHFrameSection on demand. 319 /// 320 void InitEHFrameSection(); 321}; 322 323} // end namespace llvm 324 325#endif 326