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 if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)
155 CompactUnwindDwarfEHFrameOnly = 0x04000000;
158 // Debug Information.
159 DwarfAccelNamesSection =
160 Ctx->getMachOSection("__DWARF", "__apple_names",
161 MCSectionMachO::S_ATTR_DEBUG,
162 SectionKind::getMetadata());
163 DwarfAccelObjCSection =
164 Ctx->getMachOSection("__DWARF", "__apple_objc",
165 MCSectionMachO::S_ATTR_DEBUG,
166 SectionKind::getMetadata());
167 // 16 character section limit...
168 DwarfAccelNamespaceSection =
169 Ctx->getMachOSection("__DWARF", "__apple_namespac",
170 MCSectionMachO::S_ATTR_DEBUG,
171 SectionKind::getMetadata());
172 DwarfAccelTypesSection =
173 Ctx->getMachOSection("__DWARF", "__apple_types",
174 MCSectionMachO::S_ATTR_DEBUG,
175 SectionKind::getMetadata());
178 Ctx->getMachOSection("__DWARF", "__debug_abbrev",
179 MCSectionMachO::S_ATTR_DEBUG,
180 SectionKind::getMetadata());
182 Ctx->getMachOSection("__DWARF", "__debug_info",
183 MCSectionMachO::S_ATTR_DEBUG,
184 SectionKind::getMetadata());
186 Ctx->getMachOSection("__DWARF", "__debug_line",
187 MCSectionMachO::S_ATTR_DEBUG,
188 SectionKind::getMetadata());
190 Ctx->getMachOSection("__DWARF", "__debug_frame",
191 MCSectionMachO::S_ATTR_DEBUG,
192 SectionKind::getMetadata());
193 DwarfPubNamesSection =
194 Ctx->getMachOSection("__DWARF", "__debug_pubnames",
195 MCSectionMachO::S_ATTR_DEBUG,
196 SectionKind::getMetadata());
197 DwarfPubTypesSection =
198 Ctx->getMachOSection("__DWARF", "__debug_pubtypes",
199 MCSectionMachO::S_ATTR_DEBUG,
200 SectionKind::getMetadata());
202 Ctx->getMachOSection("__DWARF", "__debug_str",
203 MCSectionMachO::S_ATTR_DEBUG,
204 SectionKind::getMetadata());
206 Ctx->getMachOSection("__DWARF", "__debug_loc",
207 MCSectionMachO::S_ATTR_DEBUG,
208 SectionKind::getMetadata());
209 DwarfARangesSection =
210 Ctx->getMachOSection("__DWARF", "__debug_aranges",
211 MCSectionMachO::S_ATTR_DEBUG,
212 SectionKind::getMetadata());
214 Ctx->getMachOSection("__DWARF", "__debug_ranges",
215 MCSectionMachO::S_ATTR_DEBUG,
216 SectionKind::getMetadata());
217 DwarfMacroInfoSection =
218 Ctx->getMachOSection("__DWARF", "__debug_macinfo",
219 MCSectionMachO::S_ATTR_DEBUG,
220 SectionKind::getMetadata());
221 DwarfDebugInlineSection =
222 Ctx->getMachOSection("__DWARF", "__debug_inlined",
223 MCSectionMachO::S_ATTR_DEBUG,
224 SectionKind::getMetadata());
226 TLSExtraDataSection = TLSTLVSection;
229 void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
230 if (T.getArch() == Triple::mips ||
231 T.getArch() == Triple::mipsel)
232 FDECFIEncoding = dwarf::DW_EH_PE_sdata4;
233 else if (T.getArch() == Triple::mips64 ||
234 T.getArch() == Triple::mips64el)
235 FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
237 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
239 if (T.getArch() == Triple::x86) {
240 PersonalityEncoding = (RelocM == Reloc::PIC_)
241 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
242 : dwarf::DW_EH_PE_absptr;
243 LSDAEncoding = (RelocM == Reloc::PIC_)
244 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
245 : dwarf::DW_EH_PE_absptr;
246 FDEEncoding = (RelocM == Reloc::PIC_)
247 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
248 : dwarf::DW_EH_PE_absptr;
249 TTypeEncoding = (RelocM == Reloc::PIC_)
250 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
251 : dwarf::DW_EH_PE_absptr;
252 } else if (T.getArch() == Triple::x86_64) {
253 if (RelocM == Reloc::PIC_) {
254 PersonalityEncoding = 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);
257 LSDAEncoding = dwarf::DW_EH_PE_pcrel |
258 (CMModel == CodeModel::Small
259 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
260 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
261 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
262 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
263 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
265 PersonalityEncoding =
266 (CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
267 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
268 LSDAEncoding = (CMModel == CodeModel::Small)
269 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
270 FDEEncoding = dwarf::DW_EH_PE_udata4;
271 TTypeEncoding = (CMModel == CodeModel::Small)
272 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
274 } else if (T.getArch() == Triple::aarch64) {
275 // The small model guarantees static code/data size < 4GB, but not where it
276 // will be in memory. Most of these could end up >2GB away so even a signed
277 // pc-relative 32-bit address is insufficient, theoretically.
278 if (RelocM == Reloc::PIC_) {
279 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
280 dwarf::DW_EH_PE_sdata8;
281 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8;
282 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
283 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
284 dwarf::DW_EH_PE_sdata8;
286 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
287 LSDAEncoding = dwarf::DW_EH_PE_absptr;
288 FDEEncoding = dwarf::DW_EH_PE_udata4;
289 TTypeEncoding = dwarf::DW_EH_PE_absptr;
291 } else if (T.getArch() == Triple::ppc64) {
292 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
293 dwarf::DW_EH_PE_udata8;
294 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
295 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
296 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
297 dwarf::DW_EH_PE_udata8;
300 // Solaris requires different flags for .eh_frame to seemingly every other
302 EHSectionType = ELF::SHT_PROGBITS;
303 EHSectionFlags = ELF::SHF_ALLOC;
304 if (T.getOS() == Triple::Solaris) {
305 if (T.getArch() == Triple::x86_64)
306 EHSectionType = ELF::SHT_X86_64_UNWIND;
308 EHSectionFlags |= ELF::SHF_WRITE;
314 Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
315 ELF::SHF_WRITE | ELF::SHF_ALLOC,
316 SectionKind::getBSS());
319 Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
322 SectionKind::getText());
325 Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
326 ELF::SHF_WRITE |ELF::SHF_ALLOC,
327 SectionKind::getDataRel());
330 Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS,
332 SectionKind::getReadOnly());
335 Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
336 ELF::SHF_ALLOC | ELF::SHF_TLS |
338 SectionKind::getThreadData());
341 Ctx->getELFSection(".tbss", ELF::SHT_NOBITS,
342 ELF::SHF_ALLOC | ELF::SHF_TLS |
344 SectionKind::getThreadBSS());
347 Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS,
348 ELF::SHF_ALLOC |ELF::SHF_WRITE,
349 SectionKind::getDataRel());
351 DataRelLocalSection =
352 Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS,
353 ELF::SHF_ALLOC |ELF::SHF_WRITE,
354 SectionKind::getDataRelLocal());
357 Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
358 ELF::SHF_ALLOC |ELF::SHF_WRITE,
359 SectionKind::getReadOnlyWithRel());
361 DataRelROLocalSection =
362 Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS,
363 ELF::SHF_ALLOC |ELF::SHF_WRITE,
364 SectionKind::getReadOnlyWithRelLocal());
366 MergeableConst4Section =
367 Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
368 ELF::SHF_ALLOC |ELF::SHF_MERGE,
369 SectionKind::getMergeableConst4());
371 MergeableConst8Section =
372 Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
373 ELF::SHF_ALLOC |ELF::SHF_MERGE,
374 SectionKind::getMergeableConst8());
376 MergeableConst16Section =
377 Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
378 ELF::SHF_ALLOC |ELF::SHF_MERGE,
379 SectionKind::getMergeableConst16());
382 Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS,
383 ELF::SHF_ALLOC |ELF::SHF_WRITE,
384 SectionKind::getDataRel());
387 Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS,
388 ELF::SHF_ALLOC |ELF::SHF_WRITE,
389 SectionKind::getDataRel());
391 // Exception Handling Sections.
393 // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
394 // it contains relocatable pointers. In PIC mode, this is probably a big
395 // runtime hit for C++ apps. Either the contents of the LSDA need to be
396 // adjusted or this should be a data section.
398 Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
400 SectionKind::getReadOnly());
402 // Debug Info Sections.
404 Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0,
405 SectionKind::getMetadata());
407 Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0,
408 SectionKind::getMetadata());
410 Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0,
411 SectionKind::getMetadata());
413 Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0,
414 SectionKind::getMetadata());
415 DwarfPubNamesSection =
416 Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0,
417 SectionKind::getMetadata());
418 DwarfPubTypesSection =
419 Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0,
420 SectionKind::getMetadata());
422 Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS,
423 ELF::SHF_MERGE | ELF::SHF_STRINGS,
424 SectionKind::getMergeable1ByteCString());
426 Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0,
427 SectionKind::getMetadata());
428 DwarfARangesSection =
429 Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0,
430 SectionKind::getMetadata());
432 Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0,
433 SectionKind::getMetadata());
434 DwarfMacroInfoSection =
435 Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0,
436 SectionKind::getMetadata());
438 // DWARF5 Experimental Debug Info
440 // Accelerator Tables
441 DwarfAccelNamesSection =
442 Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0,
443 SectionKind::getMetadata());
444 DwarfAccelObjCSection =
445 Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0,
446 SectionKind::getMetadata());
447 DwarfAccelNamespaceSection =
448 Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0,
449 SectionKind::getMetadata());
450 DwarfAccelTypesSection =
451 Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0,
452 SectionKind::getMetadata());
455 DwarfInfoDWOSection =
456 Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0,
457 SectionKind::getMetadata());
458 DwarfAbbrevDWOSection =
459 Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0,
460 SectionKind::getMetadata());
462 Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS,
463 ELF::SHF_MERGE | ELF::SHF_STRINGS,
464 SectionKind::getMergeable1ByteCString());
465 DwarfLineDWOSection =
466 Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0,
467 SectionKind::getMetadata());
469 Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0,
470 SectionKind::getMetadata());
471 DwarfStrOffDWOSection =
472 Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0,
473 SectionKind::getMetadata());
475 Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0,
476 SectionKind::getMetadata());
480 void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
483 Ctx->getCOFFSection(".text",
484 COFF::IMAGE_SCN_CNT_CODE |
485 COFF::IMAGE_SCN_MEM_EXECUTE |
486 COFF::IMAGE_SCN_MEM_READ,
487 SectionKind::getText());
489 Ctx->getCOFFSection(".data",
490 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
491 COFF::IMAGE_SCN_MEM_READ |
492 COFF::IMAGE_SCN_MEM_WRITE,
493 SectionKind::getDataRel());
495 Ctx->getCOFFSection(".rdata",
496 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
497 COFF::IMAGE_SCN_MEM_READ,
498 SectionKind::getReadOnly());
499 if (T.getOS() == Triple::Win32) {
501 Ctx->getCOFFSection(".CRT$XCU",
502 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
503 COFF::IMAGE_SCN_MEM_READ,
504 SectionKind::getReadOnly());
507 Ctx->getCOFFSection(".ctors",
508 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
509 COFF::IMAGE_SCN_MEM_READ |
510 COFF::IMAGE_SCN_MEM_WRITE,
511 SectionKind::getDataRel());
515 if (T.getOS() == Triple::Win32) {
517 Ctx->getCOFFSection(".CRT$XTX",
518 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
519 COFF::IMAGE_SCN_MEM_READ,
520 SectionKind::getReadOnly());
523 Ctx->getCOFFSection(".dtors",
524 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
525 COFF::IMAGE_SCN_MEM_READ |
526 COFF::IMAGE_SCN_MEM_WRITE,
527 SectionKind::getDataRel());
530 // FIXME: We're emitting LSDA info into a readonly section on COFF, even
531 // though it contains relocatable pointers. In PIC mode, this is probably a
532 // big runtime hit for C++ apps. Either the contents of the LSDA need to be
533 // adjusted or this should be a data section.
535 Ctx->getCOFFSection(".gcc_except_table",
536 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
537 COFF::IMAGE_SCN_MEM_READ,
538 SectionKind::getReadOnly());
542 Ctx->getCOFFSection(".debug_abbrev",
543 COFF::IMAGE_SCN_MEM_DISCARDABLE |
544 COFF::IMAGE_SCN_MEM_READ,
545 SectionKind::getMetadata());
547 Ctx->getCOFFSection(".debug_info",
548 COFF::IMAGE_SCN_MEM_DISCARDABLE |
549 COFF::IMAGE_SCN_MEM_READ,
550 SectionKind::getMetadata());
552 Ctx->getCOFFSection(".debug_line",
553 COFF::IMAGE_SCN_MEM_DISCARDABLE |
554 COFF::IMAGE_SCN_MEM_READ,
555 SectionKind::getMetadata());
557 Ctx->getCOFFSection(".debug_frame",
558 COFF::IMAGE_SCN_MEM_DISCARDABLE |
559 COFF::IMAGE_SCN_MEM_READ,
560 SectionKind::getMetadata());
561 DwarfPubNamesSection =
562 Ctx->getCOFFSection(".debug_pubnames",
563 COFF::IMAGE_SCN_MEM_DISCARDABLE |
564 COFF::IMAGE_SCN_MEM_READ,
565 SectionKind::getMetadata());
566 DwarfPubTypesSection =
567 Ctx->getCOFFSection(".debug_pubtypes",
568 COFF::IMAGE_SCN_MEM_DISCARDABLE |
569 COFF::IMAGE_SCN_MEM_READ,
570 SectionKind::getMetadata());
572 Ctx->getCOFFSection(".debug_str",
573 COFF::IMAGE_SCN_MEM_DISCARDABLE |
574 COFF::IMAGE_SCN_MEM_READ,
575 SectionKind::getMetadata());
577 Ctx->getCOFFSection(".debug_loc",
578 COFF::IMAGE_SCN_MEM_DISCARDABLE |
579 COFF::IMAGE_SCN_MEM_READ,
580 SectionKind::getMetadata());
581 DwarfARangesSection =
582 Ctx->getCOFFSection(".debug_aranges",
583 COFF::IMAGE_SCN_MEM_DISCARDABLE |
584 COFF::IMAGE_SCN_MEM_READ,
585 SectionKind::getMetadata());
587 Ctx->getCOFFSection(".debug_ranges",
588 COFF::IMAGE_SCN_MEM_DISCARDABLE |
589 COFF::IMAGE_SCN_MEM_READ,
590 SectionKind::getMetadata());
591 DwarfMacroInfoSection =
592 Ctx->getCOFFSection(".debug_macinfo",
593 COFF::IMAGE_SCN_MEM_DISCARDABLE |
594 COFF::IMAGE_SCN_MEM_READ,
595 SectionKind::getMetadata());
598 Ctx->getCOFFSection(".drectve",
599 COFF::IMAGE_SCN_LNK_INFO,
600 SectionKind::getMetadata());
603 Ctx->getCOFFSection(".pdata",
604 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
605 COFF::IMAGE_SCN_MEM_READ,
606 SectionKind::getDataRel());
609 Ctx->getCOFFSection(".xdata",
610 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
611 COFF::IMAGE_SCN_MEM_READ,
612 SectionKind::getDataRel());
614 Ctx->getCOFFSection(".tls$",
615 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
616 COFF::IMAGE_SCN_MEM_READ |
617 COFF::IMAGE_SCN_MEM_WRITE,
618 SectionKind::getDataRel());
621 void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
629 CommDirectiveSupportsAlignment = true;
630 SupportsWeakOmittedEHFrame = true;
631 IsFunctionEHFrameSymbolPrivate = true;
633 PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding =
634 TTypeEncoding = dwarf::DW_EH_PE_absptr;
636 CompactUnwindDwarfEHFrameOnly = 0;
638 EHFrameSection = 0; // Created on demand.
639 CompactUnwindSection = 0; // Used only by selected targets.
640 DwarfAccelNamesSection = 0; // Used only by selected targets.
641 DwarfAccelObjCSection = 0; // Used only by selected targets.
642 DwarfAccelNamespaceSection = 0; // Used only by selected targets.
643 DwarfAccelTypesSection = 0; // Used only by selected targets.
646 Triple::ArchType Arch = T.getArch();
647 // FIXME: Checking for Arch here to filter out bogus triples such as
648 // cellspu-apple-darwin. Perhaps we should fix in Triple?
649 if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
650 Arch == Triple::arm || Arch == Triple::thumb ||
651 Arch == Triple::ppc || Arch == Triple::ppc64 ||
652 Arch == Triple::UnknownArch) &&
653 (T.isOSDarwin() || T.getEnvironment() == Triple::MachO)) {
655 InitMachOMCObjectFileInfo(T);
656 } else if ((Arch == Triple::x86 || Arch == Triple::x86_64) &&
657 (T.getEnvironment() != Triple::ELF) &&
658 (T.getOS() == Triple::MinGW32 || T.getOS() == Triple::Cygwin ||
659 T.getOS() == Triple::Win32)) {
661 InitCOFFMCObjectFileInfo(T);
664 InitELFMCObjectFileInfo(T);
668 void MCObjectFileInfo::InitEHFrameSection() {
671 Ctx->getMachOSection("__TEXT", "__eh_frame",
672 MCSectionMachO::S_COALESCED |
673 MCSectionMachO::S_ATTR_NO_TOC |
674 MCSectionMachO::S_ATTR_STRIP_STATIC_SYMS |
675 MCSectionMachO::S_ATTR_LIVE_SUPPORT,
676 SectionKind::getReadOnly());
677 else if (Env == IsELF)
679 Ctx->getELFSection(".eh_frame", EHSectionType,
681 SectionKind::getDataRel());
684 Ctx->getCOFFSection(".eh_frame",
685 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
686 COFF::IMAGE_SCN_MEM_READ |
687 COFF::IMAGE_SCN_MEM_WRITE,
688 SectionKind::getDataRel());