blob: ba0146fd9fcac9671fe5f7a8903f5300b59b4784 [file] [log] [blame]
Sean Eveson661e4fb2017-11-30 12:43:25 +00001//===-- 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/BinaryFormat/COFF.h"
14#include "llvm/BinaryFormat/ELF.h"
15#include "llvm/MC/MCAsmInfo.h"
16#include "llvm/MC/MCContext.h"
17#include "llvm/MC/MCSection.h"
18#include "llvm/MC/MCSectionCOFF.h"
19#include "llvm/MC/MCSectionELF.h"
20#include "llvm/MC/MCSectionMachO.h"
21#include "llvm/MC/MCSectionWasm.h"
22
23using namespace llvm;
24
25static 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
50void 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 DwarfSwiftASTSection =
218 Ctx->getMachOSection("__DWARF", "__swift_ast", MachO::S_ATTR_DEBUG,
219 SectionKind::getMetadata());
220
221 DwarfAbbrevSection =
222 Ctx->getMachOSection("__DWARF", "__debug_abbrev", MachO::S_ATTR_DEBUG,
223 SectionKind::getMetadata(), "section_abbrev");
224 DwarfInfoSection =
225 Ctx->getMachOSection("__DWARF", "__debug_info", MachO::S_ATTR_DEBUG,
226 SectionKind::getMetadata(), "section_info");
227 DwarfLineSection =
228 Ctx->getMachOSection("__DWARF", "__debug_line", MachO::S_ATTR_DEBUG,
229 SectionKind::getMetadata(), "section_line");
230 DwarfFrameSection =
231 Ctx->getMachOSection("__DWARF", "__debug_frame", MachO::S_ATTR_DEBUG,
232 SectionKind::getMetadata());
233 DwarfPubNamesSection =
234 Ctx->getMachOSection("__DWARF", "__debug_pubnames", MachO::S_ATTR_DEBUG,
235 SectionKind::getMetadata());
236 DwarfPubTypesSection =
237 Ctx->getMachOSection("__DWARF", "__debug_pubtypes", MachO::S_ATTR_DEBUG,
238 SectionKind::getMetadata());
239 DwarfGnuPubNamesSection =
240 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn", MachO::S_ATTR_DEBUG,
241 SectionKind::getMetadata());
242 DwarfGnuPubTypesSection =
243 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt", MachO::S_ATTR_DEBUG,
244 SectionKind::getMetadata());
245 DwarfStrSection =
246 Ctx->getMachOSection("__DWARF", "__debug_str", MachO::S_ATTR_DEBUG,
247 SectionKind::getMetadata(), "info_string");
248 DwarfStrOffSection =
249 Ctx->getMachOSection("__DWARF", "__debug_str_offs", MachO::S_ATTR_DEBUG,
250 SectionKind::getMetadata(), "section_str_off");
251 DwarfLocSection =
252 Ctx->getMachOSection("__DWARF", "__debug_loc", MachO::S_ATTR_DEBUG,
253 SectionKind::getMetadata(), "section_debug_loc");
254 DwarfARangesSection =
255 Ctx->getMachOSection("__DWARF", "__debug_aranges", MachO::S_ATTR_DEBUG,
256 SectionKind::getMetadata());
257 DwarfRangesSection =
258 Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG,
259 SectionKind::getMetadata(), "debug_range");
260 DwarfMacinfoSection =
261 Ctx->getMachOSection("__DWARF", "__debug_macinfo", MachO::S_ATTR_DEBUG,
262 SectionKind::getMetadata(), "debug_macinfo");
263 DwarfDebugInlineSection =
264 Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG,
265 SectionKind::getMetadata());
266 DwarfCUIndexSection =
267 Ctx->getMachOSection("__DWARF", "__debug_cu_index", MachO::S_ATTR_DEBUG,
268 SectionKind::getMetadata());
269 DwarfTUIndexSection =
270 Ctx->getMachOSection("__DWARF", "__debug_tu_index", MachO::S_ATTR_DEBUG,
271 SectionKind::getMetadata());
272 StackMapSection = Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps",
273 0, SectionKind::getMetadata());
274
275 FaultMapSection = Ctx->getMachOSection("__LLVM_FAULTMAPS", "__llvm_faultmaps",
276 0, SectionKind::getMetadata());
277
278 TLSExtraDataSection = TLSTLVSection;
279}
280
281void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
282 switch (T.getArch()) {
283 case Triple::mips:
284 case Triple::mipsel:
285 FDECFIEncoding = dwarf::DW_EH_PE_sdata4;
286 break;
287 case Triple::mips64:
288 case Triple::mips64el:
289 FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
290 break;
291 case Triple::x86_64:
292 FDECFIEncoding = dwarf::DW_EH_PE_pcrel |
293 (Large ? dwarf::DW_EH_PE_sdata8 : dwarf::DW_EH_PE_sdata4);
294 break;
295 case Triple::bpfel:
296 case Triple::bpfeb:
297 FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
298 break;
299 default:
300 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
301 break;
302 }
303
304 switch (T.getArch()) {
305 case Triple::arm:
306 case Triple::armeb:
307 case Triple::thumb:
308 case Triple::thumbeb:
309 if (Ctx->getAsmInfo()->getExceptionHandlingType() == ExceptionHandling::ARM)
310 break;
311 // Fallthrough if not using EHABI
312 LLVM_FALLTHROUGH;
313 case Triple::ppc:
314 case Triple::x86:
315 PersonalityEncoding = PositionIndependent
316 ? dwarf::DW_EH_PE_indirect |
317 dwarf::DW_EH_PE_pcrel |
318 dwarf::DW_EH_PE_sdata4
319 : dwarf::DW_EH_PE_absptr;
320 LSDAEncoding = PositionIndependent
321 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
322 : dwarf::DW_EH_PE_absptr;
323 TTypeEncoding = PositionIndependent
324 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
325 dwarf::DW_EH_PE_sdata4
326 : dwarf::DW_EH_PE_absptr;
327 break;
328 case Triple::x86_64:
329 if (PositionIndependent) {
330 PersonalityEncoding =
331 dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
332 (Large ? dwarf::DW_EH_PE_sdata8 : dwarf::DW_EH_PE_sdata4);
333 LSDAEncoding = dwarf::DW_EH_PE_pcrel |
334 (Large ? dwarf::DW_EH_PE_sdata8 : dwarf::DW_EH_PE_sdata4);
335 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
336 (Large ? dwarf::DW_EH_PE_sdata8 : dwarf::DW_EH_PE_sdata4);
337 } else {
338 PersonalityEncoding =
339 Large ? dwarf::DW_EH_PE_absptr : dwarf::DW_EH_PE_udata4;
340 LSDAEncoding = Large ? dwarf::DW_EH_PE_absptr : dwarf::DW_EH_PE_udata4;
341 TTypeEncoding = Large ? dwarf::DW_EH_PE_absptr : dwarf::DW_EH_PE_udata4;
342 }
343 break;
344 case Triple::hexagon:
345 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
346 LSDAEncoding = dwarf::DW_EH_PE_absptr;
347 FDECFIEncoding = dwarf::DW_EH_PE_absptr;
348 TTypeEncoding = dwarf::DW_EH_PE_absptr;
349 if (PositionIndependent) {
350 PersonalityEncoding |= dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel;
351 LSDAEncoding |= dwarf::DW_EH_PE_pcrel;
352 FDECFIEncoding |= dwarf::DW_EH_PE_pcrel;
353 TTypeEncoding |= dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel;
354 }
355 break;
356 case Triple::aarch64:
357 case Triple::aarch64_be:
358 // The small model guarantees static code/data size < 4GB, but not where it
359 // will be in memory. Most of these could end up >2GB away so even a signed
360 // pc-relative 32-bit address is insufficient, theoretically.
361 if (PositionIndependent) {
362 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
363 dwarf::DW_EH_PE_sdata8;
364 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8;
365 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
366 dwarf::DW_EH_PE_sdata8;
367 } else {
368 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
369 LSDAEncoding = dwarf::DW_EH_PE_absptr;
370 TTypeEncoding = dwarf::DW_EH_PE_absptr;
371 }
372 break;
373 case Triple::lanai:
374 LSDAEncoding = dwarf::DW_EH_PE_absptr;
375 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
376 TTypeEncoding = dwarf::DW_EH_PE_absptr;
377 break;
378 case Triple::mips:
379 case Triple::mipsel:
380 case Triple::mips64:
381 case Triple::mips64el:
382 // MIPS uses indirect pointer to refer personality functions and types, so
383 // that the eh_frame section can be read-only. DW.ref.personality will be
384 // generated for relocation.
385 PersonalityEncoding = dwarf::DW_EH_PE_indirect;
386 // FIXME: The N64 ABI probably ought to use DW_EH_PE_sdata8 but we can't
387 // identify N64 from just a triple.
388 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
389 dwarf::DW_EH_PE_sdata4;
390 // We don't support PC-relative LSDA references in GAS so we use the default
391 // DW_EH_PE_absptr for those.
392
393 // FreeBSD must be explicit about the data size and using pcrel since it's
394 // assembler/linker won't do the automatic conversion that the Linux tools
395 // do.
396 if (T.isOSFreeBSD()) {
397 PersonalityEncoding |= dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
398 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
399 }
400 break;
401 case Triple::ppc64:
402 case Triple::ppc64le:
403 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
404 dwarf::DW_EH_PE_udata8;
405 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
406 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
407 dwarf::DW_EH_PE_udata8;
408 break;
409 case Triple::sparcel:
410 case Triple::sparc:
411 if (PositionIndependent) {
412 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
413 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
414 dwarf::DW_EH_PE_sdata4;
415 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
416 dwarf::DW_EH_PE_sdata4;
417 } else {
418 LSDAEncoding = dwarf::DW_EH_PE_absptr;
419 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
420 TTypeEncoding = dwarf::DW_EH_PE_absptr;
421 }
422 break;
423 case Triple::sparcv9:
424 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
425 if (PositionIndependent) {
426 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
427 dwarf::DW_EH_PE_sdata4;
428 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
429 dwarf::DW_EH_PE_sdata4;
430 } else {
431 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
432 TTypeEncoding = dwarf::DW_EH_PE_absptr;
433 }
434 break;
435 case Triple::systemz:
436 // All currently-defined code models guarantee that 4-byte PC-relative
437 // values will be in range.
438 if (PositionIndependent) {
439 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
440 dwarf::DW_EH_PE_sdata4;
441 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
442 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
443 dwarf::DW_EH_PE_sdata4;
444 } else {
445 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
446 LSDAEncoding = dwarf::DW_EH_PE_absptr;
447 TTypeEncoding = dwarf::DW_EH_PE_absptr;
448 }
449 break;
450 default:
451 break;
452 }
453
454 unsigned EHSectionType = T.getArch() == Triple::x86_64
455 ? ELF::SHT_X86_64_UNWIND
456 : ELF::SHT_PROGBITS;
457
458 // Solaris requires different flags for .eh_frame to seemingly every other
459 // platform.
460 unsigned EHSectionFlags = ELF::SHF_ALLOC;
461 if (T.isOSSolaris() && T.getArch() != Triple::x86_64)
462 EHSectionFlags |= ELF::SHF_WRITE;
463
464 // ELF
465 BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
466 ELF::SHF_WRITE | ELF::SHF_ALLOC);
467
468 TextSection = Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
469 ELF::SHF_EXECINSTR | ELF::SHF_ALLOC);
470
471 DataSection = Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
472 ELF::SHF_WRITE | ELF::SHF_ALLOC);
473
474 ReadOnlySection =
475 Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
476
477 TLSDataSection =
478 Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
479 ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
480
481 TLSBSSSection = Ctx->getELFSection(
482 ".tbss", ELF::SHT_NOBITS, ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
483
484 DataRelROSection = Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
485 ELF::SHF_ALLOC | ELF::SHF_WRITE);
486
487 MergeableConst4Section =
488 Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
489 ELF::SHF_ALLOC | ELF::SHF_MERGE, 4, "");
490
491 MergeableConst8Section =
492 Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
493 ELF::SHF_ALLOC | ELF::SHF_MERGE, 8, "");
494
495 MergeableConst16Section =
496 Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
497 ELF::SHF_ALLOC | ELF::SHF_MERGE, 16, "");
498
499 MergeableConst32Section =
500 Ctx->getELFSection(".rodata.cst32", ELF::SHT_PROGBITS,
501 ELF::SHF_ALLOC | ELF::SHF_MERGE, 32, "");
502
503 // Exception Handling Sections.
504
505 // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
506 // it contains relocatable pointers. In PIC mode, this is probably a big
507 // runtime hit for C++ apps. Either the contents of the LSDA need to be
508 // adjusted or this should be a data section.
509 LSDASection = Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
510 ELF::SHF_ALLOC);
511
512 COFFDebugSymbolsSection = nullptr;
513 COFFDebugTypesSection = nullptr;
514
515 unsigned DebugSecType = ELF::SHT_PROGBITS;
516
517 // MIPS .debug_* sections should have SHT_MIPS_DWARF section type
518 // to distinguish among sections contain DWARF and ECOFF debug formats.
519 // Sections with ECOFF debug format are obsoleted and marked by SHT_PROGBITS.
520 if (T.getArch() == Triple::mips || T.getArch() == Triple::mipsel ||
521 T.getArch() == Triple::mips64 || T.getArch() == Triple::mips64el)
522 DebugSecType = ELF::SHT_MIPS_DWARF;
523
524 // Debug Info Sections.
525 DwarfAbbrevSection =
526 Ctx->getELFSection(".debug_abbrev", DebugSecType, 0);
527 DwarfInfoSection = Ctx->getELFSection(".debug_info", DebugSecType, 0);
528 DwarfLineSection = Ctx->getELFSection(".debug_line", DebugSecType, 0);
529 DwarfFrameSection = Ctx->getELFSection(".debug_frame", DebugSecType, 0);
530 DwarfPubNamesSection =
531 Ctx->getELFSection(".debug_pubnames", DebugSecType, 0);
532 DwarfPubTypesSection =
533 Ctx->getELFSection(".debug_pubtypes", DebugSecType, 0);
534 DwarfGnuPubNamesSection =
535 Ctx->getELFSection(".debug_gnu_pubnames", DebugSecType, 0);
536 DwarfGnuPubTypesSection =
537 Ctx->getELFSection(".debug_gnu_pubtypes", DebugSecType, 0);
538 DwarfStrSection =
539 Ctx->getELFSection(".debug_str", DebugSecType,
540 ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
541 DwarfLocSection = Ctx->getELFSection(".debug_loc", DebugSecType, 0);
542 DwarfARangesSection =
543 Ctx->getELFSection(".debug_aranges", DebugSecType, 0);
544 DwarfRangesSection =
545 Ctx->getELFSection(".debug_ranges", DebugSecType, 0);
546 DwarfMacinfoSection =
547 Ctx->getELFSection(".debug_macinfo", DebugSecType, 0);
548
549 // DWARF5 Experimental Debug Info
550
551 // Accelerator Tables
552 DwarfAccelNamesSection =
553 Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0);
554 DwarfAccelObjCSection =
555 Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0);
556 DwarfAccelNamespaceSection =
557 Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0);
558 DwarfAccelTypesSection =
559 Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0);
560
561 // String Offset and Address Sections
562 DwarfStrOffSection =
563 Ctx->getELFSection(".debug_str_offsets", DebugSecType, 0);
564 DwarfAddrSection = Ctx->getELFSection(".debug_addr", DebugSecType, 0);
565
566 // Fission Sections
567 DwarfInfoDWOSection =
568 Ctx->getELFSection(".debug_info.dwo", DebugSecType, 0);
569 DwarfTypesDWOSection =
570 Ctx->getELFSection(".debug_types.dwo", DebugSecType, 0);
571 DwarfAbbrevDWOSection =
572 Ctx->getELFSection(".debug_abbrev.dwo", DebugSecType, 0);
573 DwarfStrDWOSection =
574 Ctx->getELFSection(".debug_str.dwo", DebugSecType,
575 ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
576 DwarfLineDWOSection =
577 Ctx->getELFSection(".debug_line.dwo", DebugSecType, 0);
578 DwarfLocDWOSection =
579 Ctx->getELFSection(".debug_loc.dwo", DebugSecType, 0);
580 DwarfStrOffDWOSection =
581 Ctx->getELFSection(".debug_str_offsets.dwo", DebugSecType, 0);
582
583 // DWP Sections
584 DwarfCUIndexSection =
585 Ctx->getELFSection(".debug_cu_index", DebugSecType, 0);
586 DwarfTUIndexSection =
587 Ctx->getELFSection(".debug_tu_index", DebugSecType, 0);
588
589 StackMapSection =
590 Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
591
592 FaultMapSection =
593 Ctx->getELFSection(".llvm_faultmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
594
595 EHFrameSection =
596 Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
Sean Evesona6bcd532017-11-30 13:05:14 +0000597
598 StackSizesSection = Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, 0);
Sean Eveson661e4fb2017-11-30 12:43:25 +0000599}
600
601void 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
827void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
828 // TODO: Set the section types and flags.
829 TextSection = Ctx->getWasmSection(".text", SectionKind::getText());
830 DataSection = Ctx->getWasmSection(".data", SectionKind::getData());
831
832 // TODO: Set the section types and flags.
833 DwarfLineSection = Ctx->getWasmSection(".debug_line", SectionKind::getMetadata());
834 DwarfStrSection = Ctx->getWasmSection(".debug_str", SectionKind::getMetadata());
835 DwarfLocSection = Ctx->getWasmSection(".debug_loc", SectionKind::getMetadata());
836 DwarfAbbrevSection = Ctx->getWasmSection(".debug_abbrev", SectionKind::getMetadata(), "section_abbrev");
837 DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", SectionKind::getMetadata());
838 DwarfRangesSection = Ctx->getWasmSection(".debug_ranges", SectionKind::getMetadata(), "debug_range");
839 DwarfMacinfoSection = Ctx->getWasmSection(".debug_macinfo", SectionKind::getMetadata(), "debug_macinfo");
840 DwarfAddrSection = Ctx->getWasmSection(".debug_addr", SectionKind::getMetadata());
841 DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata());
842 DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata());
843 DwarfInfoSection = Ctx->getWasmSection(".debug_info", SectionKind::getMetadata(), "section_info");
844 DwarfFrameSection = Ctx->getWasmSection(".debug_frame", SectionKind::getMetadata());
845 DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", SectionKind::getMetadata());
846 DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", SectionKind::getMetadata());
847
848 // TODO: Define more sections.
849}
850
851void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,
852 MCContext &ctx,
853 bool LargeCodeModel) {
854 PositionIndependent = PIC;
855 Ctx = &ctx;
856
857 // Common.
858 CommDirectiveSupportsAlignment = true;
859 SupportsWeakOmittedEHFrame = true;
860 SupportsCompactUnwindWithoutEHFrame = false;
861 OmitDwarfIfHaveCompactUnwind = false;
862
863 PersonalityEncoding = LSDAEncoding = FDECFIEncoding = TTypeEncoding =
864 dwarf::DW_EH_PE_absptr;
865
866 CompactUnwindDwarfEHFrameOnly = 0;
867
868 EHFrameSection = nullptr; // Created on demand.
869 CompactUnwindSection = nullptr; // Used only by selected targets.
870 DwarfAccelNamesSection = nullptr; // Used only by selected targets.
871 DwarfAccelObjCSection = nullptr; // Used only by selected targets.
872 DwarfAccelNamespaceSection = nullptr; // Used only by selected targets.
873 DwarfAccelTypesSection = nullptr; // Used only by selected targets.
874
875 TT = TheTriple;
876
877 switch (TT.getObjectFormat()) {
878 case Triple::MachO:
879 Env = IsMachO;
880 initMachOMCObjectFileInfo(TT);
881 break;
882 case Triple::COFF:
883 if (!TT.isOSWindows())
884 report_fatal_error(
885 "Cannot initialize MC for non-Windows COFF object files.");
886
887 Env = IsCOFF;
888 initCOFFMCObjectFileInfo(TT);
889 break;
890 case Triple::ELF:
891 Env = IsELF;
892 initELFMCObjectFileInfo(TT, LargeCodeModel);
893 break;
894 case Triple::Wasm:
895 Env = IsWasm;
896 initWasmMCObjectFileInfo(TT);
897 break;
898 case Triple::UnknownObjectFormat:
899 report_fatal_error("Cannot initialize MC for unknown object file format.");
900 break;
901 }
902}
903
904MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
905 return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
906 0, utostr(Hash));
907}