1 //===-- MObjectFileInfo.cpp - Object File Information ---------------------===//
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 #include "llvm/MC/MCObjectFileInfo.h"
11 #include "llvm/ADT/Triple.h"
12 #include "llvm/MC/MCContext.h"
13 #include "llvm/MC/MCSection.h"
14 #include "llvm/MC/MCSectionCOFF.h"
15 #include "llvm/MC/MCSectionELF.h"
16 #include "llvm/MC/MCSectionMachO.h"
19 void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
21 IsFunctionEHFrameSymbolPrivate = false;
22 SupportsWeakOmittedEHFrame = false;
24 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel
25 | dwarf::DW_EH_PE_sdata4;
26 LSDAEncoding = FDEEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
27 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
28 dwarf::DW_EH_PE_sdata4;
30 // .comm doesn't support alignment before Leopard.
31 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5))
32 CommDirectiveSupportsAlignment = false;
35 = Ctx->getMachOSection("__TEXT", "__text",
36 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
37 SectionKind::getText());
39 = Ctx->getMachOSection("__DATA", "__data", 0,
40 SectionKind::getDataRel());
42 TLSDataSection // .tdata
43 = Ctx->getMachOSection("__DATA", "__thread_data",
44 MCSectionMachO::S_THREAD_LOCAL_REGULAR,
45 SectionKind::getDataRel());
46 TLSBSSSection // .tbss
47 = Ctx->getMachOSection("__DATA", "__thread_bss",
48 MCSectionMachO::S_THREAD_LOCAL_ZEROFILL,
49 SectionKind::getThreadBSS());
51 // TODO: Verify datarel below.
53 = Ctx->getMachOSection("__DATA", "__thread_vars",
54 MCSectionMachO::S_THREAD_LOCAL_VARIABLES,
55 SectionKind::getDataRel());
58 = Ctx->getMachOSection("__DATA", "__thread_init",
59 MCSectionMachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
60 SectionKind::getDataRel());
62 CStringSection // .cstring
63 = Ctx->getMachOSection("__TEXT", "__cstring",
64 MCSectionMachO::S_CSTRING_LITERALS,
65 SectionKind::getMergeable1ByteCString());
67 = Ctx->getMachOSection("__TEXT","__ustring", 0,
68 SectionKind::getMergeable2ByteCString());
69 FourByteConstantSection // .literal4
70 = Ctx->getMachOSection("__TEXT", "__literal4",
71 MCSectionMachO::S_4BYTE_LITERALS,
72 SectionKind::getMergeableConst4());
73 EightByteConstantSection // .literal8
74 = Ctx->getMachOSection("__TEXT", "__literal8",
75 MCSectionMachO::S_8BYTE_LITERALS,
76 SectionKind::getMergeableConst8());
78 // ld_classic doesn't support .literal16 in 32-bit mode, and ld64 falls back
79 // to using it in -static mode.
80 SixteenByteConstantSection = 0;
81 if (RelocM != Reloc::Static &&
82 T.getArch() != Triple::x86_64 && T.getArch() != Triple::ppc64)
83 SixteenByteConstantSection = // .literal16
84 Ctx->getMachOSection("__TEXT", "__literal16",
85 MCSectionMachO::S_16BYTE_LITERALS,
86 SectionKind::getMergeableConst16());
88 ReadOnlySection // .const
89 = Ctx->getMachOSection("__TEXT", "__const", 0,
90 SectionKind::getReadOnly());
93 = Ctx->getMachOSection("__TEXT", "__textcoal_nt",
94 MCSectionMachO::S_COALESCED |
95 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
96 SectionKind::getText());
98 = Ctx->getMachOSection("__TEXT", "__const_coal",
99 MCSectionMachO::S_COALESCED,
100 SectionKind::getReadOnly());
101 ConstDataSection // .const_data
102 = Ctx->getMachOSection("__DATA", "__const", 0,
103 SectionKind::getReadOnlyWithRel());
105 = Ctx->getMachOSection("__DATA","__datacoal_nt",
106 MCSectionMachO::S_COALESCED,
107 SectionKind::getDataRel());
109 = Ctx->getMachOSection("__DATA","__common",
110 MCSectionMachO::S_ZEROFILL,
111 SectionKind::getBSS());
113 = Ctx->getMachOSection("__DATA","__bss", MCSectionMachO::S_ZEROFILL,
114 SectionKind::getBSS());
117 LazySymbolPointerSection
118 = Ctx->getMachOSection("__DATA", "__la_symbol_ptr",
119 MCSectionMachO::S_LAZY_SYMBOL_POINTERS,
120 SectionKind::getMetadata());
121 NonLazySymbolPointerSection
122 = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr",
123 MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS,
124 SectionKind::getMetadata());
126 if (RelocM == Reloc::Static) {
128 = Ctx->getMachOSection("__TEXT", "__constructor", 0,
129 SectionKind::getDataRel());
131 = Ctx->getMachOSection("__TEXT", "__destructor", 0,
132 SectionKind::getDataRel());
135 = Ctx->getMachOSection("__DATA", "__mod_init_func",
136 MCSectionMachO::S_MOD_INIT_FUNC_POINTERS,
137 SectionKind::getDataRel());
139 = Ctx->getMachOSection("__DATA", "__mod_term_func",
140 MCSectionMachO::S_MOD_TERM_FUNC_POINTERS,
141 SectionKind::getDataRel());
144 // Exception Handling.
145 LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0,
146 SectionKind::getReadOnlyWithRel());
148 if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6))
149 CompactUnwindSection =
150 Ctx->getMachOSection("__LD", "__compact_unwind",
151 MCSectionMachO::S_ATTR_DEBUG,
152 SectionKind::getReadOnly());
154 // Debug Information.
155 DwarfAccelNamesSection =
156 Ctx->getMachOSection("__DWARF", "__apple_names",
157 MCSectionMachO::S_ATTR_DEBUG,
158 SectionKind::getMetadata());
159 DwarfAccelObjCSection =
160 Ctx->getMachOSection("__DWARF", "__apple_objc",
161 MCSectionMachO::S_ATTR_DEBUG,
162 SectionKind::getMetadata());
163 // 16 character section limit...
164 DwarfAccelNamespaceSection =
165 Ctx->getMachOSection("__DWARF", "__apple_namespac",
166 MCSectionMachO::S_ATTR_DEBUG,
167 SectionKind::getMetadata());
168 DwarfAccelTypesSection =
169 Ctx->getMachOSection("__DWARF", "__apple_types",
170 MCSectionMachO::S_ATTR_DEBUG,
171 SectionKind::getMetadata());
174 Ctx->getMachOSection("__DWARF", "__debug_abbrev",
175 MCSectionMachO::S_ATTR_DEBUG,
176 SectionKind::getMetadata());
178 Ctx->getMachOSection("__DWARF", "__debug_info",
179 MCSectionMachO::S_ATTR_DEBUG,
180 SectionKind::getMetadata());
182 Ctx->getMachOSection("__DWARF", "__debug_line",
183 MCSectionMachO::S_ATTR_DEBUG,
184 SectionKind::getMetadata());
186 Ctx->getMachOSection("__DWARF", "__debug_frame",
187 MCSectionMachO::S_ATTR_DEBUG,
188 SectionKind::getMetadata());
189 DwarfPubNamesSection =
190 Ctx->getMachOSection("__DWARF", "__debug_pubnames",
191 MCSectionMachO::S_ATTR_DEBUG,
192 SectionKind::getMetadata());
193 DwarfPubTypesSection =
194 Ctx->getMachOSection("__DWARF", "__debug_pubtypes",
195 MCSectionMachO::S_ATTR_DEBUG,
196 SectionKind::getMetadata());
198 Ctx->getMachOSection("__DWARF", "__debug_str",
199 MCSectionMachO::S_ATTR_DEBUG,
200 SectionKind::getMetadata());
202 Ctx->getMachOSection("__DWARF", "__debug_loc",
203 MCSectionMachO::S_ATTR_DEBUG,
204 SectionKind::getMetadata());
205 DwarfARangesSection =
206 Ctx->getMachOSection("__DWARF", "__debug_aranges",
207 MCSectionMachO::S_ATTR_DEBUG,
208 SectionKind::getMetadata());
210 Ctx->getMachOSection("__DWARF", "__debug_ranges",
211 MCSectionMachO::S_ATTR_DEBUG,
212 SectionKind::getMetadata());
213 DwarfMacroInfoSection =
214 Ctx->getMachOSection("__DWARF", "__debug_macinfo",
215 MCSectionMachO::S_ATTR_DEBUG,
216 SectionKind::getMetadata());
217 DwarfDebugInlineSection =
218 Ctx->getMachOSection("__DWARF", "__debug_inlined",
219 MCSectionMachO::S_ATTR_DEBUG,
220 SectionKind::getMetadata());
222 TLSExtraDataSection = TLSTLVSection;
225 void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
226 if (T.getArch() != Triple::mips &&
227 T.getArch() != Triple::mipsel &&
228 T.getArch() != Triple::mips64 &&
229 T.getArch() != Triple::mips64el )
230 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
232 if (T.getArch() == Triple::x86) {
233 PersonalityEncoding = (RelocM == Reloc::PIC_)
234 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
235 : dwarf::DW_EH_PE_absptr;
236 LSDAEncoding = (RelocM == Reloc::PIC_)
237 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
238 : dwarf::DW_EH_PE_absptr;
239 FDEEncoding = (RelocM == Reloc::PIC_)
240 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
241 : dwarf::DW_EH_PE_absptr;
242 TTypeEncoding = (RelocM == Reloc::PIC_)
243 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
244 : dwarf::DW_EH_PE_absptr;
245 } else if (T.getArch() == Triple::x86_64) {
246 if (RelocM == Reloc::PIC_) {
247 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
248 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
249 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
250 LSDAEncoding = dwarf::DW_EH_PE_pcrel |
251 (CMModel == CodeModel::Small
252 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
253 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
254 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
255 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
256 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
258 PersonalityEncoding =
259 (CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
260 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
261 LSDAEncoding = (CMModel == CodeModel::Small)
262 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
263 FDEEncoding = dwarf::DW_EH_PE_udata4;
264 TTypeEncoding = (CMModel == CodeModel::Small)
265 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
267 } else if (T.getArch() == Triple::aarch64) {
268 // The small model guarantees static code/data size < 4GB, but not where it
269 // will be in memory. Most of these could end up >2GB away so even a signed
270 // pc-relative 32-bit address is insufficient, theoretically.
271 if (RelocM == Reloc::PIC_) {
272 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
273 dwarf::DW_EH_PE_sdata8;
274 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8;
275 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
276 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
277 dwarf::DW_EH_PE_sdata8;
279 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
280 LSDAEncoding = dwarf::DW_EH_PE_absptr;
281 FDEEncoding = dwarf::DW_EH_PE_udata4;
282 TTypeEncoding = dwarf::DW_EH_PE_absptr;
284 } else if (T.getArch() == Triple::ppc64) {
285 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
286 dwarf::DW_EH_PE_udata8;
287 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
288 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
289 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
290 dwarf::DW_EH_PE_udata8;
293 // Solaris requires different flags for .eh_frame to seemingly every other
295 EHSectionType = ELF::SHT_PROGBITS;
296 EHSectionFlags = ELF::SHF_ALLOC;
297 if (T.getOS() == Triple::Solaris) {
298 if (T.getArch() == Triple::x86_64)
299 EHSectionType = ELF::SHT_X86_64_UNWIND;
301 EHSectionFlags |= ELF::SHF_WRITE;
307 Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
308 ELF::SHF_WRITE | ELF::SHF_ALLOC,
309 SectionKind::getBSS());
312 Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
315 SectionKind::getText());
318 Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
319 ELF::SHF_WRITE |ELF::SHF_ALLOC,
320 SectionKind::getDataRel());
323 Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS,
325 SectionKind::getReadOnly());
328 Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
329 ELF::SHF_ALLOC | ELF::SHF_TLS |
331 SectionKind::getThreadData());
334 Ctx->getELFSection(".tbss", ELF::SHT_NOBITS,
335 ELF::SHF_ALLOC | ELF::SHF_TLS |
337 SectionKind::getThreadBSS());
340 Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS,
341 ELF::SHF_ALLOC |ELF::SHF_WRITE,
342 SectionKind::getDataRel());
344 DataRelLocalSection =
345 Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS,
346 ELF::SHF_ALLOC |ELF::SHF_WRITE,
347 SectionKind::getDataRelLocal());
350 Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
351 ELF::SHF_ALLOC |ELF::SHF_WRITE,
352 SectionKind::getReadOnlyWithRel());
354 DataRelROLocalSection =
355 Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS,
356 ELF::SHF_ALLOC |ELF::SHF_WRITE,
357 SectionKind::getReadOnlyWithRelLocal());
359 MergeableConst4Section =
360 Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
361 ELF::SHF_ALLOC |ELF::SHF_MERGE,
362 SectionKind::getMergeableConst4());
364 MergeableConst8Section =
365 Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
366 ELF::SHF_ALLOC |ELF::SHF_MERGE,
367 SectionKind::getMergeableConst8());
369 MergeableConst16Section =
370 Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
371 ELF::SHF_ALLOC |ELF::SHF_MERGE,
372 SectionKind::getMergeableConst16());
375 Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS,
376 ELF::SHF_ALLOC |ELF::SHF_WRITE,
377 SectionKind::getDataRel());
380 Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS,
381 ELF::SHF_ALLOC |ELF::SHF_WRITE,
382 SectionKind::getDataRel());
384 // Exception Handling Sections.
386 // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
387 // it contains relocatable pointers. In PIC mode, this is probably a big
388 // runtime hit for C++ apps. Either the contents of the LSDA need to be
389 // adjusted or this should be a data section.
391 Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
393 SectionKind::getReadOnly());
395 // Debug Info Sections.
397 Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0,
398 SectionKind::getMetadata());
400 Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0,
401 SectionKind::getMetadata());
403 Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0,
404 SectionKind::getMetadata());
406 Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0,
407 SectionKind::getMetadata());
408 DwarfPubNamesSection =
409 Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0,
410 SectionKind::getMetadata());
411 DwarfPubTypesSection =
412 Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0,
413 SectionKind::getMetadata());
415 Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS,
416 ELF::SHF_MERGE | ELF::SHF_STRINGS,
417 SectionKind::getMergeable1ByteCString());
419 Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0,
420 SectionKind::getMetadata());
421 DwarfARangesSection =
422 Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0,
423 SectionKind::getMetadata());
425 Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0,
426 SectionKind::getMetadata());
427 DwarfMacroInfoSection =
428 Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0,
429 SectionKind::getMetadata());
431 // DWARF5 Experimental Debug Info
433 // Accelerator Tables
434 DwarfAccelNamesSection =
435 Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0,
436 SectionKind::getMetadata());
437 DwarfAccelObjCSection =
438 Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0,
439 SectionKind::getMetadata());
440 DwarfAccelNamespaceSection =
441 Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0,
442 SectionKind::getMetadata());
443 DwarfAccelTypesSection =
444 Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0,
445 SectionKind::getMetadata());
448 DwarfInfoDWOSection =
449 Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0,
450 SectionKind::getMetadata());
451 DwarfAbbrevDWOSection =
452 Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0,
453 SectionKind::getMetadata());
455 Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS,
456 ELF::SHF_MERGE | ELF::SHF_STRINGS,
457 SectionKind::getMergeable1ByteCString());
458 DwarfLineDWOSection =
459 Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0,
460 SectionKind::getMetadata());
462 Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0,
463 SectionKind::getMetadata());
464 DwarfStrOffDWOSection =
465 Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0,
466 SectionKind::getMetadata());
468 Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0,
469 SectionKind::getMetadata());
473 void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
476 Ctx->getCOFFSection(".text",
477 COFF::IMAGE_SCN_CNT_CODE |
478 COFF::IMAGE_SCN_MEM_EXECUTE |
479 COFF::IMAGE_SCN_MEM_READ,
480 SectionKind::getText());
482 Ctx->getCOFFSection(".data",
483 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
484 COFF::IMAGE_SCN_MEM_READ |
485 COFF::IMAGE_SCN_MEM_WRITE,
486 SectionKind::getDataRel());
488 Ctx->getCOFFSection(".rdata",
489 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
490 COFF::IMAGE_SCN_MEM_READ,
491 SectionKind::getReadOnly());
492 if (T.getOS() == Triple::Win32) {
494 Ctx->getCOFFSection(".CRT$XCU",
495 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
496 COFF::IMAGE_SCN_MEM_READ,
497 SectionKind::getReadOnly());
500 Ctx->getCOFFSection(".ctors",
501 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
502 COFF::IMAGE_SCN_MEM_READ |
503 COFF::IMAGE_SCN_MEM_WRITE,
504 SectionKind::getDataRel());
508 if (T.getOS() == Triple::Win32) {
510 Ctx->getCOFFSection(".CRT$XTX",
511 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
512 COFF::IMAGE_SCN_MEM_READ,
513 SectionKind::getReadOnly());
516 Ctx->getCOFFSection(".dtors",
517 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
518 COFF::IMAGE_SCN_MEM_READ |
519 COFF::IMAGE_SCN_MEM_WRITE,
520 SectionKind::getDataRel());
523 // FIXME: We're emitting LSDA info into a readonly section on COFF, even
524 // though it contains relocatable pointers. In PIC mode, this is probably a
525 // big runtime hit for C++ apps. Either the contents of the LSDA need to be
526 // adjusted or this should be a data section.
528 Ctx->getCOFFSection(".gcc_except_table",
529 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
530 COFF::IMAGE_SCN_MEM_READ,
531 SectionKind::getReadOnly());
535 Ctx->getCOFFSection(".debug_abbrev",
536 COFF::IMAGE_SCN_MEM_DISCARDABLE |
537 COFF::IMAGE_SCN_MEM_READ,
538 SectionKind::getMetadata());
540 Ctx->getCOFFSection(".debug_info",
541 COFF::IMAGE_SCN_MEM_DISCARDABLE |
542 COFF::IMAGE_SCN_MEM_READ,
543 SectionKind::getMetadata());
545 Ctx->getCOFFSection(".debug_line",
546 COFF::IMAGE_SCN_MEM_DISCARDABLE |
547 COFF::IMAGE_SCN_MEM_READ,
548 SectionKind::getMetadata());
550 Ctx->getCOFFSection(".debug_frame",
551 COFF::IMAGE_SCN_MEM_DISCARDABLE |
552 COFF::IMAGE_SCN_MEM_READ,
553 SectionKind::getMetadata());
554 DwarfPubNamesSection =
555 Ctx->getCOFFSection(".debug_pubnames",
556 COFF::IMAGE_SCN_MEM_DISCARDABLE |
557 COFF::IMAGE_SCN_MEM_READ,
558 SectionKind::getMetadata());
559 DwarfPubTypesSection =
560 Ctx->getCOFFSection(".debug_pubtypes",
561 COFF::IMAGE_SCN_MEM_DISCARDABLE |
562 COFF::IMAGE_SCN_MEM_READ,
563 SectionKind::getMetadata());
565 Ctx->getCOFFSection(".debug_str",
566 COFF::IMAGE_SCN_MEM_DISCARDABLE |
567 COFF::IMAGE_SCN_MEM_READ,
568 SectionKind::getMetadata());
570 Ctx->getCOFFSection(".debug_loc",
571 COFF::IMAGE_SCN_MEM_DISCARDABLE |
572 COFF::IMAGE_SCN_MEM_READ,
573 SectionKind::getMetadata());
574 DwarfARangesSection =
575 Ctx->getCOFFSection(".debug_aranges",
576 COFF::IMAGE_SCN_MEM_DISCARDABLE |
577 COFF::IMAGE_SCN_MEM_READ,
578 SectionKind::getMetadata());
580 Ctx->getCOFFSection(".debug_ranges",
581 COFF::IMAGE_SCN_MEM_DISCARDABLE |
582 COFF::IMAGE_SCN_MEM_READ,
583 SectionKind::getMetadata());
584 DwarfMacroInfoSection =
585 Ctx->getCOFFSection(".debug_macinfo",
586 COFF::IMAGE_SCN_MEM_DISCARDABLE |
587 COFF::IMAGE_SCN_MEM_READ,
588 SectionKind::getMetadata());
591 Ctx->getCOFFSection(".drectve",
592 COFF::IMAGE_SCN_LNK_INFO,
593 SectionKind::getMetadata());
596 Ctx->getCOFFSection(".pdata",
597 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
598 COFF::IMAGE_SCN_MEM_READ,
599 SectionKind::getDataRel());
602 Ctx->getCOFFSection(".xdata",
603 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
604 COFF::IMAGE_SCN_MEM_READ,
605 SectionKind::getDataRel());
607 Ctx->getCOFFSection(".tls$",
608 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
609 COFF::IMAGE_SCN_MEM_READ |
610 COFF::IMAGE_SCN_MEM_WRITE,
611 SectionKind::getDataRel());
614 void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
622 CommDirectiveSupportsAlignment = true;
623 SupportsWeakOmittedEHFrame = true;
624 IsFunctionEHFrameSymbolPrivate = true;
626 PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding =
627 TTypeEncoding = dwarf::DW_EH_PE_absptr;
629 EHFrameSection = 0; // Created on demand.
630 CompactUnwindSection = 0; // Used only by selected targets.
631 DwarfAccelNamesSection = 0; // Used only by selected targets.
632 DwarfAccelObjCSection = 0; // Used only by selected targets.
633 DwarfAccelNamespaceSection = 0; // Used only by selected targets.
634 DwarfAccelTypesSection = 0; // Used only by selected targets.
637 Triple::ArchType Arch = T.getArch();
638 // FIXME: Checking for Arch here to filter out bogus triples such as
639 // cellspu-apple-darwin. Perhaps we should fix in Triple?
640 if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
641 Arch == Triple::arm || Arch == Triple::thumb ||
642 Arch == Triple::ppc || Arch == Triple::ppc64 ||
643 Arch == Triple::UnknownArch) &&
644 (T.isOSDarwin() || T.getEnvironment() == Triple::MachO)) {
646 InitMachOMCObjectFileInfo(T);
647 } else if ((Arch == Triple::x86 || Arch == Triple::x86_64) &&
648 (T.getEnvironment() != Triple::ELF) &&
649 (T.getOS() == Triple::MinGW32 || T.getOS() == Triple::Cygwin ||
650 T.getOS() == Triple::Win32)) {
652 InitCOFFMCObjectFileInfo(T);
655 InitELFMCObjectFileInfo(T);
659 void MCObjectFileInfo::InitEHFrameSection() {
662 Ctx->getMachOSection("__TEXT", "__eh_frame",
663 MCSectionMachO::S_COALESCED |
664 MCSectionMachO::S_ATTR_NO_TOC |
665 MCSectionMachO::S_ATTR_STRIP_STATIC_SYMS |
666 MCSectionMachO::S_ATTR_LIVE_SUPPORT,
667 SectionKind::getReadOnly());
668 else if (Env == IsELF)
670 Ctx->getELFSection(".eh_frame", EHSectionType,
672 SectionKind::getDataRel());
675 Ctx->getCOFFSection(".eh_frame",
676 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
677 COFF::IMAGE_SCN_MEM_READ |
678 COFF::IMAGE_SCN_MEM_WRITE,
679 SectionKind::getDataRel());