1 //===-- MCObjectFileInfo.cpp - Object File Information --------------------===// 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 #include "llvm/MC/MCObjectFileInfo.h" 11 #include "llvm/ADT/StringExtras.h" 12 #include "llvm/ADT/Triple.h" 13 #include "llvm/MC/MCAsmInfo.h" 14 #include "llvm/MC/MCContext.h" 15 #include "llvm/MC/MCSection.h" 16 #include "llvm/MC/MCSectionCOFF.h" 17 #include "llvm/MC/MCSectionELF.h" 18 #include "llvm/MC/MCSectionMachO.h" 19 #include "llvm/MC/MCSectionWasm.h" 20 #include "llvm/Support/COFF.h" 21 #include "llvm/Support/ELF.h" 22 23 using namespace llvm; 24 25 static bool useCompactUnwind(const Triple &T) { 26 // Only on darwin. 27 if (!T.isOSDarwin()) 28 return false; 29 30 // aarch64 always has it. 31 if (T.getArch() == Triple::aarch64) 32 return true; 33 34 // armv7k always has it. 35 if (T.isWatchABI()) 36 return true; 37 38 // Use it on newer version of OS X. 39 if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6)) 40 return true; 41 42 // And the iOS simulator. 43 if (T.isiOS() && 44 (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)) 45 return true; 46 47 return false; 48 } 49 50 void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) { 51 // MachO 52 SupportsWeakOmittedEHFrame = false; 53 54 EHFrameSection = Ctx->getMachOSection( 55 "__TEXT", "__eh_frame", 56 MachO::S_COALESCED | MachO::S_ATTR_NO_TOC | 57 MachO::S_ATTR_STRIP_STATIC_SYMS | MachO::S_ATTR_LIVE_SUPPORT, 58 SectionKind::getReadOnly()); 59 60 if (T.isOSDarwin() && T.getArch() == Triple::aarch64) 61 SupportsCompactUnwindWithoutEHFrame = true; 62 63 if (T.isWatchABI()) 64 OmitDwarfIfHaveCompactUnwind = true; 65 66 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel 67 | dwarf::DW_EH_PE_sdata4; 68 LSDAEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel; 69 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 70 dwarf::DW_EH_PE_sdata4; 71 72 // .comm doesn't support alignment before Leopard. 73 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5)) 74 CommDirectiveSupportsAlignment = false; 75 76 TextSection // .text 77 = Ctx->getMachOSection("__TEXT", "__text", 78 MachO::S_ATTR_PURE_INSTRUCTIONS, 79 SectionKind::getText()); 80 DataSection // .data 81 = Ctx->getMachOSection("__DATA", "__data", 0, SectionKind::getData()); 82 83 // BSSSection might not be expected initialized on msvc. 84 BSSSection = nullptr; 85 86 TLSDataSection // .tdata 87 = Ctx->getMachOSection("__DATA", "__thread_data", 88 MachO::S_THREAD_LOCAL_REGULAR, 89 SectionKind::getData()); 90 TLSBSSSection // .tbss 91 = Ctx->getMachOSection("__DATA", "__thread_bss", 92 MachO::S_THREAD_LOCAL_ZEROFILL, 93 SectionKind::getThreadBSS()); 94 95 // TODO: Verify datarel below. 96 TLSTLVSection // .tlv 97 = Ctx->getMachOSection("__DATA", "__thread_vars", 98 MachO::S_THREAD_LOCAL_VARIABLES, 99 SectionKind::getData()); 100 101 TLSThreadInitSection = Ctx->getMachOSection( 102 "__DATA", "__thread_init", MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS, 103 SectionKind::getData()); 104 105 CStringSection // .cstring 106 = Ctx->getMachOSection("__TEXT", "__cstring", 107 MachO::S_CSTRING_LITERALS, 108 SectionKind::getMergeable1ByteCString()); 109 UStringSection 110 = Ctx->getMachOSection("__TEXT","__ustring", 0, 111 SectionKind::getMergeable2ByteCString()); 112 FourByteConstantSection // .literal4 113 = Ctx->getMachOSection("__TEXT", "__literal4", 114 MachO::S_4BYTE_LITERALS, 115 SectionKind::getMergeableConst4()); 116 EightByteConstantSection // .literal8 117 = Ctx->getMachOSection("__TEXT", "__literal8", 118 MachO::S_8BYTE_LITERALS, 119 SectionKind::getMergeableConst8()); 120 121 SixteenByteConstantSection // .literal16 122 = Ctx->getMachOSection("__TEXT", "__literal16", 123 MachO::S_16BYTE_LITERALS, 124 SectionKind::getMergeableConst16()); 125 126 ReadOnlySection // .const 127 = Ctx->getMachOSection("__TEXT", "__const", 0, 128 SectionKind::getReadOnly()); 129 130 // If the target is not powerpc, map the coal sections to the non-coal 131 // sections. 132 // 133 // "__TEXT/__textcoal_nt" => section "__TEXT/__text" 134 // "__TEXT/__const_coal" => section "__TEXT/__const" 135 // "__DATA/__datacoal_nt" => section "__DATA/__data" 136 Triple::ArchType ArchTy = T.getArch(); 137 138 if (ArchTy == Triple::ppc || ArchTy == Triple::ppc64) { 139 TextCoalSection 140 = Ctx->getMachOSection("__TEXT", "__textcoal_nt", 141 MachO::S_COALESCED | 142 MachO::S_ATTR_PURE_INSTRUCTIONS, 143 SectionKind::getText()); 144 ConstTextCoalSection 145 = Ctx->getMachOSection("__TEXT", "__const_coal", 146 MachO::S_COALESCED, 147 SectionKind::getReadOnly()); 148 DataCoalSection = Ctx->getMachOSection( 149 "__DATA", "__datacoal_nt", MachO::S_COALESCED, SectionKind::getData()); 150 } else { 151 TextCoalSection = TextSection; 152 ConstTextCoalSection = ReadOnlySection; 153 DataCoalSection = DataSection; 154 } 155 156 ConstDataSection // .const_data 157 = Ctx->getMachOSection("__DATA", "__const", 0, 158 SectionKind::getReadOnlyWithRel()); 159 DataCommonSection 160 = Ctx->getMachOSection("__DATA","__common", 161 MachO::S_ZEROFILL, 162 SectionKind::getBSS()); 163 DataBSSSection 164 = Ctx->getMachOSection("__DATA","__bss", MachO::S_ZEROFILL, 165 SectionKind::getBSS()); 166 167 168 LazySymbolPointerSection 169 = Ctx->getMachOSection("__DATA", "__la_symbol_ptr", 170 MachO::S_LAZY_SYMBOL_POINTERS, 171 SectionKind::getMetadata()); 172 NonLazySymbolPointerSection 173 = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr", 174 MachO::S_NON_LAZY_SYMBOL_POINTERS, 175 SectionKind::getMetadata()); 176 177 ThreadLocalPointerSection 178 = Ctx->getMachOSection("__DATA", "__thread_ptr", 179 MachO::S_THREAD_LOCAL_VARIABLE_POINTERS, 180 SectionKind::getMetadata()); 181 182 // Exception Handling. 183 LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0, 184 SectionKind::getReadOnlyWithRel()); 185 186 COFFDebugSymbolsSection = nullptr; 187 COFFDebugTypesSection = nullptr; 188 189 if (useCompactUnwind(T)) { 190 CompactUnwindSection = 191 Ctx->getMachOSection("__LD", "__compact_unwind", MachO::S_ATTR_DEBUG, 192 SectionKind::getReadOnly()); 193 194 if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86) 195 CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_X86_64_MODE_DWARF 196 else if (T.getArch() == Triple::aarch64) 197 CompactUnwindDwarfEHFrameOnly = 0x03000000; // UNWIND_ARM64_MODE_DWARF 198 else if (T.getArch() == Triple::arm || T.getArch() == Triple::thumb) 199 CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_ARM_MODE_DWARF 200 } 201 202 // Debug Information. 203 DwarfAccelNamesSection = 204 Ctx->getMachOSection("__DWARF", "__apple_names", MachO::S_ATTR_DEBUG, 205 SectionKind::getMetadata(), "names_begin"); 206 DwarfAccelObjCSection = 207 Ctx->getMachOSection("__DWARF", "__apple_objc", MachO::S_ATTR_DEBUG, 208 SectionKind::getMetadata(), "objc_begin"); 209 // 16 character section limit... 210 DwarfAccelNamespaceSection = 211 Ctx->getMachOSection("__DWARF", "__apple_namespac", MachO::S_ATTR_DEBUG, 212 SectionKind::getMetadata(), "namespac_begin"); 213 DwarfAccelTypesSection = 214 Ctx->getMachOSection("__DWARF", "__apple_types", MachO::S_ATTR_DEBUG, 215 SectionKind::getMetadata(), "types_begin"); 216 217 DwarfAbbrevSection = 218 Ctx->getMachOSection("__DWARF", "__debug_abbrev", MachO::S_ATTR_DEBUG, 219 SectionKind::getMetadata(), "section_abbrev"); 220 DwarfInfoSection = 221 Ctx->getMachOSection("__DWARF", "__debug_info", MachO::S_ATTR_DEBUG, 222 SectionKind::getMetadata(), "section_info"); 223 DwarfLineSection = 224 Ctx->getMachOSection("__DWARF", "__debug_line", MachO::S_ATTR_DEBUG, 225 SectionKind::getMetadata(), "section_line"); 226 DwarfFrameSection = 227 Ctx->getMachOSection("__DWARF", "__debug_frame", MachO::S_ATTR_DEBUG, 228 SectionKind::getMetadata()); 229 DwarfPubNamesSection = 230 Ctx->getMachOSection("__DWARF", "__debug_pubnames", MachO::S_ATTR_DEBUG, 231 SectionKind::getMetadata()); 232 DwarfPubTypesSection = 233 Ctx->getMachOSection("__DWARF", "__debug_pubtypes", MachO::S_ATTR_DEBUG, 234 SectionKind::getMetadata()); 235 DwarfGnuPubNamesSection = 236 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn", MachO::S_ATTR_DEBUG, 237 SectionKind::getMetadata()); 238 DwarfGnuPubTypesSection = 239 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt", MachO::S_ATTR_DEBUG, 240 SectionKind::getMetadata()); 241 DwarfStrSection = 242 Ctx->getMachOSection("__DWARF", "__debug_str", MachO::S_ATTR_DEBUG, 243 SectionKind::getMetadata(), "info_string"); 244 DwarfStrOffSection = 245 Ctx->getMachOSection("__DWARF", "__debug_str_offs", MachO::S_ATTR_DEBUG, 246 SectionKind::getMetadata(), "section_str_off"); 247 DwarfLocSection = 248 Ctx->getMachOSection("__DWARF", "__debug_loc", MachO::S_ATTR_DEBUG, 249 SectionKind::getMetadata(), "section_debug_loc"); 250 DwarfARangesSection = 251 Ctx->getMachOSection("__DWARF", "__debug_aranges", MachO::S_ATTR_DEBUG, 252 SectionKind::getMetadata()); 253 DwarfRangesSection = 254 Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG, 255 SectionKind::getMetadata(), "debug_range"); 256 DwarfMacinfoSection = 257 Ctx->getMachOSection("__DWARF", "__debug_macinfo", MachO::S_ATTR_DEBUG, 258 SectionKind::getMetadata(), "debug_macinfo"); 259 DwarfDebugInlineSection = 260 Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG, 261 SectionKind::getMetadata()); 262 DwarfCUIndexSection = 263 Ctx->getMachOSection("__DWARF", "__debug_cu_index", MachO::S_ATTR_DEBUG, 264 SectionKind::getMetadata()); 265 DwarfTUIndexSection = 266 Ctx->getMachOSection("__DWARF", "__debug_tu_index", MachO::S_ATTR_DEBUG, 267 SectionKind::getMetadata()); 268 StackMapSection = Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps", 269 0, SectionKind::getMetadata()); 270 271 FaultMapSection = Ctx->getMachOSection("__LLVM_FAULTMAPS", "__llvm_faultmaps", 272 0, SectionKind::getMetadata()); 273 274 TLSExtraDataSection = TLSTLVSection; 275 } 276 277 void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T) { 278 switch (T.getArch()) { 279 case Triple::mips: 280 case Triple::mipsel: 281 FDECFIEncoding = dwarf::DW_EH_PE_sdata4; 282 break; 283 case Triple::mips64: 284 case Triple::mips64el: 285 FDECFIEncoding = dwarf::DW_EH_PE_sdata8; 286 break; 287 case Triple::x86_64: 288 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | 289 ((CMModel == CodeModel::Large) ? dwarf::DW_EH_PE_sdata8 290 : dwarf::DW_EH_PE_sdata4); 291 break; 292 case Triple::bpfel: 293 case Triple::bpfeb: 294 FDECFIEncoding = dwarf::DW_EH_PE_sdata8; 295 break; 296 default: 297 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; 298 break; 299 } 300 301 switch (T.getArch()) { 302 case Triple::arm: 303 case Triple::armeb: 304 case Triple::thumb: 305 case Triple::thumbeb: 306 if (Ctx->getAsmInfo()->getExceptionHandlingType() == ExceptionHandling::ARM) 307 break; 308 // Fallthrough if not using EHABI 309 LLVM_FALLTHROUGH; 310 case Triple::ppc: 311 case Triple::x86: 312 PersonalityEncoding = PositionIndependent 313 ? dwarf::DW_EH_PE_indirect | 314 dwarf::DW_EH_PE_pcrel | 315 dwarf::DW_EH_PE_sdata4 316 : dwarf::DW_EH_PE_absptr; 317 LSDAEncoding = PositionIndependent 318 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 319 : dwarf::DW_EH_PE_absptr; 320 TTypeEncoding = PositionIndependent 321 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 322 dwarf::DW_EH_PE_sdata4 323 : dwarf::DW_EH_PE_absptr; 324 break; 325 case Triple::x86_64: 326 if (PositionIndependent) { 327 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 328 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium) 329 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); 330 LSDAEncoding = dwarf::DW_EH_PE_pcrel | 331 (CMModel == CodeModel::Small 332 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); 333 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 334 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium) 335 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8); 336 } else { 337 PersonalityEncoding = 338 (CMModel == CodeModel::Small || CMModel == CodeModel::Medium) 339 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; 340 LSDAEncoding = (CMModel == CodeModel::Small) 341 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; 342 TTypeEncoding = (CMModel == CodeModel::Small) 343 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr; 344 } 345 break; 346 case Triple::hexagon: 347 PersonalityEncoding = dwarf::DW_EH_PE_absptr; 348 LSDAEncoding = dwarf::DW_EH_PE_absptr; 349 FDECFIEncoding = dwarf::DW_EH_PE_absptr; 350 TTypeEncoding = dwarf::DW_EH_PE_absptr; 351 if (PositionIndependent) { 352 PersonalityEncoding |= dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel; 353 LSDAEncoding |= dwarf::DW_EH_PE_pcrel; 354 FDECFIEncoding |= dwarf::DW_EH_PE_pcrel; 355 TTypeEncoding |= dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel; 356 } 357 break; 358 case Triple::aarch64: 359 case Triple::aarch64_be: 360 // The small model guarantees static code/data size < 4GB, but not where it 361 // will be in memory. Most of these could end up >2GB away so even a signed 362 // pc-relative 32-bit address is insufficient, theoretically. 363 if (PositionIndependent) { 364 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 365 dwarf::DW_EH_PE_sdata8; 366 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8; 367 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 368 dwarf::DW_EH_PE_sdata8; 369 } else { 370 PersonalityEncoding = dwarf::DW_EH_PE_absptr; 371 LSDAEncoding = dwarf::DW_EH_PE_absptr; 372 TTypeEncoding = dwarf::DW_EH_PE_absptr; 373 } 374 break; 375 case Triple::lanai: 376 LSDAEncoding = dwarf::DW_EH_PE_absptr; 377 PersonalityEncoding = dwarf::DW_EH_PE_absptr; 378 TTypeEncoding = dwarf::DW_EH_PE_absptr; 379 break; 380 case Triple::mips: 381 case Triple::mipsel: 382 case Triple::mips64: 383 case Triple::mips64el: 384 // MIPS uses indirect pointer to refer personality functions and types, so 385 // that the eh_frame section can be read-only. DW.ref.personality will be 386 // generated for relocation. 387 PersonalityEncoding = dwarf::DW_EH_PE_indirect; 388 // FIXME: The N64 ABI probably ought to use DW_EH_PE_sdata8 but we can't 389 // identify N64 from just a triple. 390 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 391 dwarf::DW_EH_PE_sdata4; 392 // We don't support PC-relative LSDA references in GAS so we use the default 393 // DW_EH_PE_absptr for those. 394 395 // FreeBSD must be explicit about the data size and using pcrel since it's 396 // assembler/linker won't do the automatic conversion that the Linux tools 397 // do. 398 if (T.isOSFreeBSD()) { 399 PersonalityEncoding |= dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; 400 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; 401 } 402 break; 403 case Triple::ppc64: 404 case Triple::ppc64le: 405 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 406 dwarf::DW_EH_PE_udata8; 407 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8; 408 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 409 dwarf::DW_EH_PE_udata8; 410 break; 411 case Triple::sparcel: 412 case Triple::sparc: 413 if (PositionIndependent) { 414 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; 415 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 416 dwarf::DW_EH_PE_sdata4; 417 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 418 dwarf::DW_EH_PE_sdata4; 419 } else { 420 LSDAEncoding = dwarf::DW_EH_PE_absptr; 421 PersonalityEncoding = dwarf::DW_EH_PE_absptr; 422 TTypeEncoding = dwarf::DW_EH_PE_absptr; 423 } 424 break; 425 case Triple::sparcv9: 426 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; 427 if (PositionIndependent) { 428 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 429 dwarf::DW_EH_PE_sdata4; 430 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 431 dwarf::DW_EH_PE_sdata4; 432 } else { 433 PersonalityEncoding = dwarf::DW_EH_PE_absptr; 434 TTypeEncoding = dwarf::DW_EH_PE_absptr; 435 } 436 break; 437 case Triple::systemz: 438 // All currently-defined code models guarantee that 4-byte PC-relative 439 // values will be in range. 440 if (PositionIndependent) { 441 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 442 dwarf::DW_EH_PE_sdata4; 443 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4; 444 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | 445 dwarf::DW_EH_PE_sdata4; 446 } else { 447 PersonalityEncoding = dwarf::DW_EH_PE_absptr; 448 LSDAEncoding = dwarf::DW_EH_PE_absptr; 449 TTypeEncoding = dwarf::DW_EH_PE_absptr; 450 } 451 break; 452 default: 453 break; 454 } 455 456 unsigned EHSectionType = T.getArch() == Triple::x86_64 457 ? ELF::SHT_X86_64_UNWIND 458 : ELF::SHT_PROGBITS; 459 460 // Solaris requires different flags for .eh_frame to seemingly every other 461 // platform. 462 unsigned EHSectionFlags = ELF::SHF_ALLOC; 463 if (T.isOSSolaris() && T.getArch() != Triple::x86_64) 464 EHSectionFlags |= ELF::SHF_WRITE; 465 466 // ELF 467 BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS, 468 ELF::SHF_WRITE | ELF::SHF_ALLOC); 469 470 TextSection = Ctx->getELFSection(".text", ELF::SHT_PROGBITS, 471 ELF::SHF_EXECINSTR | ELF::SHF_ALLOC); 472 473 DataSection = Ctx->getELFSection(".data", ELF::SHT_PROGBITS, 474 ELF::SHF_WRITE | ELF::SHF_ALLOC); 475 476 ReadOnlySection = 477 Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC); 478 479 TLSDataSection = 480 Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS, 481 ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE); 482 483 TLSBSSSection = Ctx->getELFSection( 484 ".tbss", ELF::SHT_NOBITS, ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE); 485 486 DataRelROSection = Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS, 487 ELF::SHF_ALLOC | ELF::SHF_WRITE); 488 489 MergeableConst4Section = 490 Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS, 491 ELF::SHF_ALLOC | ELF::SHF_MERGE, 4, ""); 492 493 MergeableConst8Section = 494 Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS, 495 ELF::SHF_ALLOC | ELF::SHF_MERGE, 8, ""); 496 497 MergeableConst16Section = 498 Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS, 499 ELF::SHF_ALLOC | ELF::SHF_MERGE, 16, ""); 500 501 MergeableConst32Section = 502 Ctx->getELFSection(".rodata.cst32", ELF::SHT_PROGBITS, 503 ELF::SHF_ALLOC | ELF::SHF_MERGE, 32, ""); 504 505 // Exception Handling Sections. 506 507 // FIXME: We're emitting LSDA info into a readonly section on ELF, even though 508 // it contains relocatable pointers. In PIC mode, this is probably a big 509 // runtime hit for C++ apps. Either the contents of the LSDA need to be 510 // adjusted or this should be a data section. 511 LSDASection = Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS, 512 ELF::SHF_ALLOC); 513 514 COFFDebugSymbolsSection = nullptr; 515 COFFDebugTypesSection = nullptr; 516 517 unsigned DebugSecType = ELF::SHT_PROGBITS; 518 519 // MIPS .debug_* sections should have SHT_MIPS_DWARF section type 520 // to distinguish among sections contain DWARF and ECOFF debug formats. 521 // Sections with ECOFF debug format are obsoleted and marked by SHT_PROGBITS. 522 if (T.getArch() == Triple::mips || T.getArch() == Triple::mipsel || 523 T.getArch() == Triple::mips64 || T.getArch() == Triple::mips64el) 524 DebugSecType = ELF::SHT_MIPS_DWARF; 525 526 // Debug Info Sections. 527 DwarfAbbrevSection = 528 Ctx->getELFSection(".debug_abbrev", DebugSecType, 0); 529 DwarfInfoSection = Ctx->getELFSection(".debug_info", DebugSecType, 0); 530 DwarfLineSection = Ctx->getELFSection(".debug_line", DebugSecType, 0); 531 DwarfFrameSection = Ctx->getELFSection(".debug_frame", DebugSecType, 0); 532 DwarfPubNamesSection = 533 Ctx->getELFSection(".debug_pubnames", DebugSecType, 0); 534 DwarfPubTypesSection = 535 Ctx->getELFSection(".debug_pubtypes", DebugSecType, 0); 536 DwarfGnuPubNamesSection = 537 Ctx->getELFSection(".debug_gnu_pubnames", DebugSecType, 0); 538 DwarfGnuPubTypesSection = 539 Ctx->getELFSection(".debug_gnu_pubtypes", DebugSecType, 0); 540 DwarfStrSection = 541 Ctx->getELFSection(".debug_str", DebugSecType, 542 ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); 543 DwarfLocSection = Ctx->getELFSection(".debug_loc", DebugSecType, 0); 544 DwarfARangesSection = 545 Ctx->getELFSection(".debug_aranges", DebugSecType, 0); 546 DwarfRangesSection = 547 Ctx->getELFSection(".debug_ranges", DebugSecType, 0); 548 DwarfMacinfoSection = 549 Ctx->getELFSection(".debug_macinfo", DebugSecType, 0); 550 551 // DWARF5 Experimental Debug Info 552 553 // Accelerator Tables 554 DwarfAccelNamesSection = 555 Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0); 556 DwarfAccelObjCSection = 557 Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0); 558 DwarfAccelNamespaceSection = 559 Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0); 560 DwarfAccelTypesSection = 561 Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0); 562 563 // String Offset and Address Sections 564 DwarfStrOffSection = 565 Ctx->getELFSection(".debug_str_offsets", DebugSecType, 0); 566 DwarfAddrSection = Ctx->getELFSection(".debug_addr", DebugSecType, 0); 567 568 // Fission Sections 569 DwarfInfoDWOSection = 570 Ctx->getELFSection(".debug_info.dwo", DebugSecType, 0); 571 DwarfTypesDWOSection = 572 Ctx->getELFSection(".debug_types.dwo", DebugSecType, 0); 573 DwarfAbbrevDWOSection = 574 Ctx->getELFSection(".debug_abbrev.dwo", DebugSecType, 0); 575 DwarfStrDWOSection = 576 Ctx->getELFSection(".debug_str.dwo", DebugSecType, 577 ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); 578 DwarfLineDWOSection = 579 Ctx->getELFSection(".debug_line.dwo", DebugSecType, 0); 580 DwarfLocDWOSection = 581 Ctx->getELFSection(".debug_loc.dwo", DebugSecType, 0); 582 DwarfStrOffDWOSection = 583 Ctx->getELFSection(".debug_str_offsets.dwo", DebugSecType, 0); 584 585 // DWP Sections 586 DwarfCUIndexSection = 587 Ctx->getELFSection(".debug_cu_index", DebugSecType, 0); 588 DwarfTUIndexSection = 589 Ctx->getELFSection(".debug_tu_index", DebugSecType, 0); 590 591 StackMapSection = 592 Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC); 593 594 FaultMapSection = 595 Ctx->getELFSection(".llvm_faultmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC); 596 597 EHFrameSection = 598 Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags); 599 } 600 601 void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) { 602 EHFrameSection = Ctx->getCOFFSection( 603 ".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 604 COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE, 605 SectionKind::getData()); 606 607 // Set the `IMAGE_SCN_MEM_16BIT` flag when compiling for thumb mode. This is 608 // used to indicate to the linker that the text segment contains thumb instructions 609 // and to set the ISA selection bit for calls accordingly. 610 const bool IsThumb = T.getArch() == Triple::thumb; 611 612 CommDirectiveSupportsAlignment = true; 613 614 // COFF 615 BSSSection = Ctx->getCOFFSection( 616 ".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA | 617 COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE, 618 SectionKind::getBSS()); 619 TextSection = Ctx->getCOFFSection( 620 ".text", 621 (IsThumb ? COFF::IMAGE_SCN_MEM_16BIT : (COFF::SectionCharacteristics)0) | 622 COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE | 623 COFF::IMAGE_SCN_MEM_READ, 624 SectionKind::getText()); 625 DataSection = Ctx->getCOFFSection( 626 ".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ | 627 COFF::IMAGE_SCN_MEM_WRITE, 628 SectionKind::getData()); 629 ReadOnlySection = Ctx->getCOFFSection( 630 ".rdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ, 631 SectionKind::getReadOnly()); 632 633 // FIXME: We're emitting LSDA info into a readonly section on COFF, even 634 // though it contains relocatable pointers. In PIC mode, this is probably a 635 // big runtime hit for C++ apps. Either the contents of the LSDA need to be 636 // adjusted or this should be a data section. 637 if (T.getArch() == Triple::x86_64) { 638 // On Windows 64 with SEH, the LSDA is emitted into the .xdata section 639 LSDASection = nullptr; 640 } else { 641 LSDASection = Ctx->getCOFFSection(".gcc_except_table", 642 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 643 COFF::IMAGE_SCN_MEM_READ, 644 SectionKind::getReadOnly()); 645 } 646 647 // Debug info. 648 COFFDebugSymbolsSection = 649 Ctx->getCOFFSection(".debug$S", (COFF::IMAGE_SCN_MEM_DISCARDABLE | 650 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 651 COFF::IMAGE_SCN_MEM_READ), 652 SectionKind::getMetadata()); 653 COFFDebugTypesSection = 654 Ctx->getCOFFSection(".debug$T", (COFF::IMAGE_SCN_MEM_DISCARDABLE | 655 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 656 COFF::IMAGE_SCN_MEM_READ), 657 SectionKind::getMetadata()); 658 659 DwarfAbbrevSection = Ctx->getCOFFSection( 660 ".debug_abbrev", 661 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 662 COFF::IMAGE_SCN_MEM_READ, 663 SectionKind::getMetadata(), "section_abbrev"); 664 DwarfInfoSection = Ctx->getCOFFSection( 665 ".debug_info", 666 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 667 COFF::IMAGE_SCN_MEM_READ, 668 SectionKind::getMetadata(), "section_info"); 669 DwarfLineSection = Ctx->getCOFFSection( 670 ".debug_line", 671 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 672 COFF::IMAGE_SCN_MEM_READ, 673 SectionKind::getMetadata(), "section_line"); 674 675 DwarfFrameSection = Ctx->getCOFFSection( 676 ".debug_frame", 677 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 678 COFF::IMAGE_SCN_MEM_READ, 679 SectionKind::getMetadata()); 680 DwarfPubNamesSection = Ctx->getCOFFSection( 681 ".debug_pubnames", 682 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 683 COFF::IMAGE_SCN_MEM_READ, 684 SectionKind::getMetadata()); 685 DwarfPubTypesSection = Ctx->getCOFFSection( 686 ".debug_pubtypes", 687 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 688 COFF::IMAGE_SCN_MEM_READ, 689 SectionKind::getMetadata()); 690 DwarfGnuPubNamesSection = Ctx->getCOFFSection( 691 ".debug_gnu_pubnames", 692 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 693 COFF::IMAGE_SCN_MEM_READ, 694 SectionKind::getMetadata()); 695 DwarfGnuPubTypesSection = Ctx->getCOFFSection( 696 ".debug_gnu_pubtypes", 697 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 698 COFF::IMAGE_SCN_MEM_READ, 699 SectionKind::getMetadata()); 700 DwarfStrSection = Ctx->getCOFFSection( 701 ".debug_str", 702 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 703 COFF::IMAGE_SCN_MEM_READ, 704 SectionKind::getMetadata(), "info_string"); 705 DwarfStrOffSection = Ctx->getCOFFSection( 706 ".debug_str_offsets", 707 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 708 COFF::IMAGE_SCN_MEM_READ, 709 SectionKind::getMetadata(), "section_str_off"); 710 DwarfLocSection = Ctx->getCOFFSection( 711 ".debug_loc", 712 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 713 COFF::IMAGE_SCN_MEM_READ, 714 SectionKind::getMetadata(), "section_debug_loc"); 715 DwarfARangesSection = Ctx->getCOFFSection( 716 ".debug_aranges", 717 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 718 COFF::IMAGE_SCN_MEM_READ, 719 SectionKind::getMetadata()); 720 DwarfRangesSection = Ctx->getCOFFSection( 721 ".debug_ranges", 722 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 723 COFF::IMAGE_SCN_MEM_READ, 724 SectionKind::getMetadata(), "debug_range"); 725 DwarfMacinfoSection = Ctx->getCOFFSection( 726 ".debug_macinfo", 727 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 728 COFF::IMAGE_SCN_MEM_READ, 729 SectionKind::getMetadata(), "debug_macinfo"); 730 DwarfInfoDWOSection = Ctx->getCOFFSection( 731 ".debug_info.dwo", 732 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 733 COFF::IMAGE_SCN_MEM_READ, 734 SectionKind::getMetadata(), "section_info_dwo"); 735 DwarfTypesDWOSection = Ctx->getCOFFSection( 736 ".debug_types.dwo", 737 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 738 COFF::IMAGE_SCN_MEM_READ, 739 SectionKind::getMetadata(), "section_types_dwo"); 740 DwarfAbbrevDWOSection = Ctx->getCOFFSection( 741 ".debug_abbrev.dwo", 742 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 743 COFF::IMAGE_SCN_MEM_READ, 744 SectionKind::getMetadata(), "section_abbrev_dwo"); 745 DwarfStrDWOSection = Ctx->getCOFFSection( 746 ".debug_str.dwo", 747 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 748 COFF::IMAGE_SCN_MEM_READ, 749 SectionKind::getMetadata(), "skel_string"); 750 DwarfLineDWOSection = Ctx->getCOFFSection( 751 ".debug_line.dwo", 752 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 753 COFF::IMAGE_SCN_MEM_READ, 754 SectionKind::getMetadata()); 755 DwarfLocDWOSection = Ctx->getCOFFSection( 756 ".debug_loc.dwo", 757 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 758 COFF::IMAGE_SCN_MEM_READ, 759 SectionKind::getMetadata(), "skel_loc"); 760 DwarfStrOffDWOSection = Ctx->getCOFFSection( 761 ".debug_str_offsets.dwo", 762 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 763 COFF::IMAGE_SCN_MEM_READ, 764 SectionKind::getMetadata(), "section_str_off_dwo"); 765 DwarfAddrSection = Ctx->getCOFFSection( 766 ".debug_addr", 767 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 768 COFF::IMAGE_SCN_MEM_READ, 769 SectionKind::getMetadata(), "addr_sec"); 770 DwarfCUIndexSection = Ctx->getCOFFSection( 771 ".debug_cu_index", 772 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 773 COFF::IMAGE_SCN_MEM_READ, 774 SectionKind::getMetadata()); 775 DwarfTUIndexSection = Ctx->getCOFFSection( 776 ".debug_tu_index", 777 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 778 COFF::IMAGE_SCN_MEM_READ, 779 SectionKind::getMetadata()); 780 DwarfAccelNamesSection = Ctx->getCOFFSection( 781 ".apple_names", 782 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 783 COFF::IMAGE_SCN_MEM_READ, 784 SectionKind::getMetadata(), "names_begin"); 785 DwarfAccelNamespaceSection = Ctx->getCOFFSection( 786 ".apple_namespaces", 787 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 788 COFF::IMAGE_SCN_MEM_READ, 789 SectionKind::getMetadata(), "namespac_begin"); 790 DwarfAccelTypesSection = Ctx->getCOFFSection( 791 ".apple_types", 792 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 793 COFF::IMAGE_SCN_MEM_READ, 794 SectionKind::getMetadata(), "types_begin"); 795 DwarfAccelObjCSection = Ctx->getCOFFSection( 796 ".apple_objc", 797 COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 798 COFF::IMAGE_SCN_MEM_READ, 799 SectionKind::getMetadata(), "objc_begin"); 800 801 DrectveSection = Ctx->getCOFFSection( 802 ".drectve", COFF::IMAGE_SCN_LNK_INFO | COFF::IMAGE_SCN_LNK_REMOVE, 803 SectionKind::getMetadata()); 804 805 PDataSection = Ctx->getCOFFSection( 806 ".pdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ, 807 SectionKind::getData()); 808 809 XDataSection = Ctx->getCOFFSection( 810 ".xdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ, 811 SectionKind::getData()); 812 813 SXDataSection = Ctx->getCOFFSection(".sxdata", COFF::IMAGE_SCN_LNK_INFO, 814 SectionKind::getMetadata()); 815 816 TLSDataSection = Ctx->getCOFFSection( 817 ".tls$", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ | 818 COFF::IMAGE_SCN_MEM_WRITE, 819 SectionKind::getData()); 820 821 StackMapSection = Ctx->getCOFFSection(".llvm_stackmaps", 822 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | 823 COFF::IMAGE_SCN_MEM_READ, 824 SectionKind::getReadOnly()); 825 } 826 827 void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) { 828 // TODO: Set the section types and flags. 829 TextSection = Ctx->getWasmSection(".text", 0, 0); 830 DataSection = Ctx->getWasmSection(".data", 0, 0); 831 832 // TODO: Set the section types and flags. 833 DwarfLineSection = Ctx->getWasmSection(".debug_line", 0, 0); 834 DwarfStrSection = Ctx->getWasmSection(".debug_str", 0, 0); 835 DwarfLocSection = Ctx->getWasmSection(".debug_loc", 0, 0); 836 DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", 0, 0, "section_abbrev"); 837 DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", 0, 0); 838 DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", 0, 0, "debug_range"); 839 DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", 0, 0, "debug_macinfo"); 840 DwarfAddrSection = Ctx->getWasmSection(".debug_addr", 0, 0); 841 DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", 0, 0); 842 DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", 0, 0); 843 DwarfInfoSection = Ctx->getWasmSection(".debug_info", 0, 0, "section_info"); 844 DwarfFrameSection = Ctx->getWasmSection(".debug_frame", 0, 0); 845 DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", 0, 0); 846 DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", 0, 0); 847 848 // TODO: Define more sections. 849 } 850 851 void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC, 852 CodeModel::Model cm, 853 MCContext &ctx) { 854 PositionIndependent = PIC; 855 CMModel = cm; 856 Ctx = &ctx; 857 858 // Common. 859 CommDirectiveSupportsAlignment = true; 860 SupportsWeakOmittedEHFrame = true; 861 SupportsCompactUnwindWithoutEHFrame = false; 862 OmitDwarfIfHaveCompactUnwind = false; 863 864 PersonalityEncoding = LSDAEncoding = FDECFIEncoding = TTypeEncoding = 865 dwarf::DW_EH_PE_absptr; 866 867 CompactUnwindDwarfEHFrameOnly = 0; 868 869 EHFrameSection = nullptr; // Created on demand. 870 CompactUnwindSection = nullptr; // Used only by selected targets. 871 DwarfAccelNamesSection = nullptr; // Used only by selected targets. 872 DwarfAccelObjCSection = nullptr; // Used only by selected targets. 873 DwarfAccelNamespaceSection = nullptr; // Used only by selected targets. 874 DwarfAccelTypesSection = nullptr; // Used only by selected targets. 875 876 TT = TheTriple; 877 878 switch (TT.getObjectFormat()) { 879 case Triple::MachO: 880 Env = IsMachO; 881 initMachOMCObjectFileInfo(TT); 882 break; 883 case Triple::COFF: 884 if (!TT.isOSWindows()) 885 report_fatal_error( 886 "Cannot initialize MC for non-Windows COFF object files."); 887 888 Env = IsCOFF; 889 initCOFFMCObjectFileInfo(TT); 890 break; 891 case Triple::ELF: 892 Env = IsELF; 893 initELFMCObjectFileInfo(TT); 894 break; 895 case Triple::Wasm: 896 Env = IsWasm; 897 initWasmMCObjectFileInfo(TT); 898 break; 899 case Triple::UnknownObjectFormat: 900 report_fatal_error("Cannot initialize MC for unknown object file format."); 901 break; 902 } 903 } 904 905 MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const { 906 return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP, 907 0, utostr(Hash)); 908 } 909