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/StringExtras.h"
12 #include "llvm/ADT/Triple.h"
13 #include "llvm/MC/MCContext.h"
14 #include "llvm/MC/MCSection.h"
15 #include "llvm/MC/MCSectionCOFF.h"
16 #include "llvm/MC/MCSectionELF.h"
17 #include "llvm/MC/MCSectionMachO.h"
20 void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
22 IsFunctionEHFrameSymbolPrivate = false;
23 SupportsWeakOmittedEHFrame = false;
25 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel
26 | dwarf::DW_EH_PE_sdata4;
27 LSDAEncoding = FDEEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
28 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
29 dwarf::DW_EH_PE_sdata4;
31 // .comm doesn't support alignment before Leopard.
32 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 5))
33 CommDirectiveSupportsAlignment = false;
36 = Ctx->getMachOSection("__TEXT", "__text",
37 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
38 SectionKind::getText());
40 = Ctx->getMachOSection("__DATA", "__data", 0,
41 SectionKind::getDataRel());
43 // BSSSection might not be expected initialized on msvc.
46 TLSDataSection // .tdata
47 = Ctx->getMachOSection("__DATA", "__thread_data",
48 MCSectionMachO::S_THREAD_LOCAL_REGULAR,
49 SectionKind::getDataRel());
50 TLSBSSSection // .tbss
51 = Ctx->getMachOSection("__DATA", "__thread_bss",
52 MCSectionMachO::S_THREAD_LOCAL_ZEROFILL,
53 SectionKind::getThreadBSS());
55 // TODO: Verify datarel below.
57 = Ctx->getMachOSection("__DATA", "__thread_vars",
58 MCSectionMachO::S_THREAD_LOCAL_VARIABLES,
59 SectionKind::getDataRel());
62 = Ctx->getMachOSection("__DATA", "__thread_init",
63 MCSectionMachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
64 SectionKind::getDataRel());
66 CStringSection // .cstring
67 = Ctx->getMachOSection("__TEXT", "__cstring",
68 MCSectionMachO::S_CSTRING_LITERALS,
69 SectionKind::getMergeable1ByteCString());
71 = Ctx->getMachOSection("__TEXT","__ustring", 0,
72 SectionKind::getMergeable2ByteCString());
73 FourByteConstantSection // .literal4
74 = Ctx->getMachOSection("__TEXT", "__literal4",
75 MCSectionMachO::S_4BYTE_LITERALS,
76 SectionKind::getMergeableConst4());
77 EightByteConstantSection // .literal8
78 = Ctx->getMachOSection("__TEXT", "__literal8",
79 MCSectionMachO::S_8BYTE_LITERALS,
80 SectionKind::getMergeableConst8());
82 // ld_classic doesn't support .literal16 in 32-bit mode, and ld64 falls back
83 // to using it in -static mode.
84 SixteenByteConstantSection = 0;
85 if (RelocM != Reloc::Static &&
86 T.getArch() != Triple::x86_64 && T.getArch() != Triple::ppc64 &&
87 T.getArch() != Triple::ppc64le)
88 SixteenByteConstantSection = // .literal16
89 Ctx->getMachOSection("__TEXT", "__literal16",
90 MCSectionMachO::S_16BYTE_LITERALS,
91 SectionKind::getMergeableConst16());
93 ReadOnlySection // .const
94 = Ctx->getMachOSection("__TEXT", "__const", 0,
95 SectionKind::getReadOnly());
98 = Ctx->getMachOSection("__TEXT", "__textcoal_nt",
99 MCSectionMachO::S_COALESCED |
100 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS,
101 SectionKind::getText());
103 = Ctx->getMachOSection("__TEXT", "__const_coal",
104 MCSectionMachO::S_COALESCED,
105 SectionKind::getReadOnly());
106 ConstDataSection // .const_data
107 = Ctx->getMachOSection("__DATA", "__const", 0,
108 SectionKind::getReadOnlyWithRel());
110 = Ctx->getMachOSection("__DATA","__datacoal_nt",
111 MCSectionMachO::S_COALESCED,
112 SectionKind::getDataRel());
114 = Ctx->getMachOSection("__DATA","__common",
115 MCSectionMachO::S_ZEROFILL,
116 SectionKind::getBSS());
118 = Ctx->getMachOSection("__DATA","__bss", MCSectionMachO::S_ZEROFILL,
119 SectionKind::getBSS());
122 LazySymbolPointerSection
123 = Ctx->getMachOSection("__DATA", "__la_symbol_ptr",
124 MCSectionMachO::S_LAZY_SYMBOL_POINTERS,
125 SectionKind::getMetadata());
126 NonLazySymbolPointerSection
127 = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr",
128 MCSectionMachO::S_NON_LAZY_SYMBOL_POINTERS,
129 SectionKind::getMetadata());
131 if (RelocM == Reloc::Static) {
133 = Ctx->getMachOSection("__TEXT", "__constructor", 0,
134 SectionKind::getDataRel());
136 = Ctx->getMachOSection("__TEXT", "__destructor", 0,
137 SectionKind::getDataRel());
140 = Ctx->getMachOSection("__DATA", "__mod_init_func",
141 MCSectionMachO::S_MOD_INIT_FUNC_POINTERS,
142 SectionKind::getDataRel());
144 = Ctx->getMachOSection("__DATA", "__mod_term_func",
145 MCSectionMachO::S_MOD_TERM_FUNC_POINTERS,
146 SectionKind::getDataRel());
149 // Exception Handling.
150 LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0,
151 SectionKind::getReadOnlyWithRel());
153 if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6)) {
154 CompactUnwindSection =
155 Ctx->getMachOSection("__LD", "__compact_unwind",
156 MCSectionMachO::S_ATTR_DEBUG,
157 SectionKind::getReadOnly());
159 if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)
160 CompactUnwindDwarfEHFrameOnly = 0x04000000;
163 // Debug Information.
164 DwarfAccelNamesSection =
165 Ctx->getMachOSection("__DWARF", "__apple_names",
166 MCSectionMachO::S_ATTR_DEBUG,
167 SectionKind::getMetadata());
168 DwarfAccelObjCSection =
169 Ctx->getMachOSection("__DWARF", "__apple_objc",
170 MCSectionMachO::S_ATTR_DEBUG,
171 SectionKind::getMetadata());
172 // 16 character section limit...
173 DwarfAccelNamespaceSection =
174 Ctx->getMachOSection("__DWARF", "__apple_namespac",
175 MCSectionMachO::S_ATTR_DEBUG,
176 SectionKind::getMetadata());
177 DwarfAccelTypesSection =
178 Ctx->getMachOSection("__DWARF", "__apple_types",
179 MCSectionMachO::S_ATTR_DEBUG,
180 SectionKind::getMetadata());
183 Ctx->getMachOSection("__DWARF", "__debug_abbrev",
184 MCSectionMachO::S_ATTR_DEBUG,
185 SectionKind::getMetadata());
187 Ctx->getMachOSection("__DWARF", "__debug_info",
188 MCSectionMachO::S_ATTR_DEBUG,
189 SectionKind::getMetadata());
191 Ctx->getMachOSection("__DWARF", "__debug_line",
192 MCSectionMachO::S_ATTR_DEBUG,
193 SectionKind::getMetadata());
195 Ctx->getMachOSection("__DWARF", "__debug_frame",
196 MCSectionMachO::S_ATTR_DEBUG,
197 SectionKind::getMetadata());
198 DwarfPubNamesSection =
199 Ctx->getMachOSection("__DWARF", "__debug_pubnames",
200 MCSectionMachO::S_ATTR_DEBUG,
201 SectionKind::getMetadata());
202 DwarfPubTypesSection =
203 Ctx->getMachOSection("__DWARF", "__debug_pubtypes",
204 MCSectionMachO::S_ATTR_DEBUG,
205 SectionKind::getMetadata());
206 DwarfGnuPubNamesSection =
207 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn",
208 MCSectionMachO::S_ATTR_DEBUG,
209 SectionKind::getMetadata());
210 DwarfGnuPubTypesSection =
211 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt",
212 MCSectionMachO::S_ATTR_DEBUG,
213 SectionKind::getMetadata());
215 Ctx->getMachOSection("__DWARF", "__debug_str",
216 MCSectionMachO::S_ATTR_DEBUG,
217 SectionKind::getMetadata());
219 Ctx->getMachOSection("__DWARF", "__debug_loc",
220 MCSectionMachO::S_ATTR_DEBUG,
221 SectionKind::getMetadata());
222 DwarfARangesSection =
223 Ctx->getMachOSection("__DWARF", "__debug_aranges",
224 MCSectionMachO::S_ATTR_DEBUG,
225 SectionKind::getMetadata());
227 Ctx->getMachOSection("__DWARF", "__debug_ranges",
228 MCSectionMachO::S_ATTR_DEBUG,
229 SectionKind::getMetadata());
230 DwarfMacroInfoSection =
231 Ctx->getMachOSection("__DWARF", "__debug_macinfo",
232 MCSectionMachO::S_ATTR_DEBUG,
233 SectionKind::getMetadata());
234 DwarfDebugInlineSection =
235 Ctx->getMachOSection("__DWARF", "__debug_inlined",
236 MCSectionMachO::S_ATTR_DEBUG,
237 SectionKind::getMetadata());
239 Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps", 0,
240 SectionKind::getMetadata());
242 TLSExtraDataSection = TLSTLVSection;
245 void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
246 if (T.getArch() == Triple::mips ||
247 T.getArch() == Triple::mipsel)
248 FDECFIEncoding = dwarf::DW_EH_PE_sdata4;
249 else if (T.getArch() == Triple::mips64 ||
250 T.getArch() == Triple::mips64el)
251 FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
253 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
255 if (T.getArch() == Triple::x86) {
256 PersonalityEncoding = (RelocM == Reloc::PIC_)
257 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
258 : dwarf::DW_EH_PE_absptr;
259 LSDAEncoding = (RelocM == Reloc::PIC_)
260 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
261 : dwarf::DW_EH_PE_absptr;
262 FDEEncoding = (RelocM == Reloc::PIC_)
263 ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
264 : dwarf::DW_EH_PE_absptr;
265 TTypeEncoding = (RelocM == Reloc::PIC_)
266 ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
267 : dwarf::DW_EH_PE_absptr;
268 } else if (T.getArch() == Triple::x86_64) {
269 if (RelocM == Reloc::PIC_) {
270 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
271 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
272 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
273 LSDAEncoding = dwarf::DW_EH_PE_pcrel |
274 (CMModel == CodeModel::Small
275 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
276 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
277 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
278 ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
279 ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
281 PersonalityEncoding =
282 (CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
283 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
284 LSDAEncoding = (CMModel == CodeModel::Small)
285 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
286 FDEEncoding = dwarf::DW_EH_PE_udata4;
287 TTypeEncoding = (CMModel == CodeModel::Small)
288 ? dwarf::DW_EH_PE_udata4 : dwarf::DW_EH_PE_absptr;
290 } else if (T.getArch() == Triple::aarch64) {
291 // The small model guarantees static code/data size < 4GB, but not where it
292 // will be in memory. Most of these could end up >2GB away so even a signed
293 // pc-relative 32-bit address is insufficient, theoretically.
294 if (RelocM == Reloc::PIC_) {
295 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
296 dwarf::DW_EH_PE_sdata8;
297 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8;
298 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
299 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
300 dwarf::DW_EH_PE_sdata8;
302 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
303 LSDAEncoding = dwarf::DW_EH_PE_absptr;
304 FDEEncoding = dwarf::DW_EH_PE_udata4;
305 TTypeEncoding = dwarf::DW_EH_PE_absptr;
307 } else if (T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le) {
308 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
309 dwarf::DW_EH_PE_udata8;
310 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
311 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_udata8;
312 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
313 dwarf::DW_EH_PE_udata8;
314 } else if (T.getArch() == Triple::sparc) {
315 if (RelocM == Reloc::PIC_) {
316 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
317 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
318 dwarf::DW_EH_PE_sdata4;
319 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
320 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
321 dwarf::DW_EH_PE_sdata4;
323 LSDAEncoding = dwarf::DW_EH_PE_absptr;
324 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
325 FDEEncoding = dwarf::DW_EH_PE_udata4;
326 TTypeEncoding = dwarf::DW_EH_PE_absptr;
328 } else if (T.getArch() == Triple::sparcv9) {
329 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
330 if (RelocM == Reloc::PIC_) {
331 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
332 dwarf::DW_EH_PE_sdata4;
333 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
334 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
335 dwarf::DW_EH_PE_sdata4;
337 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
338 FDEEncoding = dwarf::DW_EH_PE_udata4;
339 TTypeEncoding = dwarf::DW_EH_PE_absptr;
341 } else if (T.getArch() == Triple::systemz) {
342 // All currently-defined code models guarantee that 4-byte PC-relative
343 // values will be in range.
344 if (RelocM == Reloc::PIC_) {
345 PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
346 dwarf::DW_EH_PE_sdata4;
347 LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
348 FDEEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
349 TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
350 dwarf::DW_EH_PE_sdata4;
352 PersonalityEncoding = dwarf::DW_EH_PE_absptr;
353 LSDAEncoding = dwarf::DW_EH_PE_absptr;
354 FDEEncoding = dwarf::DW_EH_PE_absptr;
355 TTypeEncoding = dwarf::DW_EH_PE_absptr;
359 // Solaris requires different flags for .eh_frame to seemingly every other
361 EHSectionType = ELF::SHT_PROGBITS;
362 EHSectionFlags = ELF::SHF_ALLOC;
363 if (T.getOS() == Triple::Solaris) {
364 if (T.getArch() == Triple::x86_64)
365 EHSectionType = ELF::SHT_X86_64_UNWIND;
367 EHSectionFlags |= ELF::SHF_WRITE;
373 Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
374 ELF::SHF_WRITE | ELF::SHF_ALLOC,
375 SectionKind::getBSS());
378 Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
381 SectionKind::getText());
384 Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
385 ELF::SHF_WRITE |ELF::SHF_ALLOC,
386 SectionKind::getDataRel());
389 Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS,
391 SectionKind::getReadOnly());
394 Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
395 ELF::SHF_ALLOC | ELF::SHF_TLS |
397 SectionKind::getThreadData());
400 Ctx->getELFSection(".tbss", ELF::SHT_NOBITS,
401 ELF::SHF_ALLOC | ELF::SHF_TLS |
403 SectionKind::getThreadBSS());
406 Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS,
407 ELF::SHF_ALLOC |ELF::SHF_WRITE,
408 SectionKind::getDataRel());
410 DataRelLocalSection =
411 Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS,
412 ELF::SHF_ALLOC |ELF::SHF_WRITE,
413 SectionKind::getDataRelLocal());
416 Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
417 ELF::SHF_ALLOC |ELF::SHF_WRITE,
418 SectionKind::getReadOnlyWithRel());
420 DataRelROLocalSection =
421 Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS,
422 ELF::SHF_ALLOC |ELF::SHF_WRITE,
423 SectionKind::getReadOnlyWithRelLocal());
425 MergeableConst4Section =
426 Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
427 ELF::SHF_ALLOC |ELF::SHF_MERGE,
428 SectionKind::getMergeableConst4());
430 MergeableConst8Section =
431 Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
432 ELF::SHF_ALLOC |ELF::SHF_MERGE,
433 SectionKind::getMergeableConst8());
435 MergeableConst16Section =
436 Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
437 ELF::SHF_ALLOC |ELF::SHF_MERGE,
438 SectionKind::getMergeableConst16());
441 Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS,
442 ELF::SHF_ALLOC |ELF::SHF_WRITE,
443 SectionKind::getDataRel());
446 Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS,
447 ELF::SHF_ALLOC |ELF::SHF_WRITE,
448 SectionKind::getDataRel());
450 // Exception Handling Sections.
452 // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
453 // it contains relocatable pointers. In PIC mode, this is probably a big
454 // runtime hit for C++ apps. Either the contents of the LSDA need to be
455 // adjusted or this should be a data section.
457 Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
459 SectionKind::getReadOnly());
461 // Debug Info Sections.
463 Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0,
464 SectionKind::getMetadata());
466 Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0,
467 SectionKind::getMetadata());
469 Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0,
470 SectionKind::getMetadata());
472 Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0,
473 SectionKind::getMetadata());
474 DwarfPubNamesSection =
475 Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0,
476 SectionKind::getMetadata());
477 DwarfPubTypesSection =
478 Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0,
479 SectionKind::getMetadata());
480 DwarfGnuPubNamesSection =
481 Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0,
482 SectionKind::getMetadata());
483 DwarfGnuPubTypesSection =
484 Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0,
485 SectionKind::getMetadata());
487 Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS,
488 ELF::SHF_MERGE | ELF::SHF_STRINGS,
489 SectionKind::getMergeable1ByteCString());
491 Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0,
492 SectionKind::getMetadata());
493 DwarfARangesSection =
494 Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0,
495 SectionKind::getMetadata());
497 Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0,
498 SectionKind::getMetadata());
499 DwarfMacroInfoSection =
500 Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0,
501 SectionKind::getMetadata());
503 // DWARF5 Experimental Debug Info
505 // Accelerator Tables
506 DwarfAccelNamesSection =
507 Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0,
508 SectionKind::getMetadata());
509 DwarfAccelObjCSection =
510 Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0,
511 SectionKind::getMetadata());
512 DwarfAccelNamespaceSection =
513 Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0,
514 SectionKind::getMetadata());
515 DwarfAccelTypesSection =
516 Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0,
517 SectionKind::getMetadata());
520 DwarfInfoDWOSection =
521 Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0,
522 SectionKind::getMetadata());
523 DwarfAbbrevDWOSection =
524 Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0,
525 SectionKind::getMetadata());
527 Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS,
528 ELF::SHF_MERGE | ELF::SHF_STRINGS,
529 SectionKind::getMergeable1ByteCString());
530 DwarfLineDWOSection =
531 Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0,
532 SectionKind::getMetadata());
534 Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0,
535 SectionKind::getMetadata());
536 DwarfStrOffDWOSection =
537 Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0,
538 SectionKind::getMetadata());
540 Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0,
541 SectionKind::getMetadata());
545 void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
548 Ctx->getCOFFSection(".bss",
549 COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
550 COFF::IMAGE_SCN_MEM_READ |
551 COFF::IMAGE_SCN_MEM_WRITE,
552 SectionKind::getBSS());
554 Ctx->getCOFFSection(".text",
555 COFF::IMAGE_SCN_CNT_CODE |
556 COFF::IMAGE_SCN_MEM_EXECUTE |
557 COFF::IMAGE_SCN_MEM_READ,
558 SectionKind::getText());
560 Ctx->getCOFFSection(".data",
561 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
562 COFF::IMAGE_SCN_MEM_READ |
563 COFF::IMAGE_SCN_MEM_WRITE,
564 SectionKind::getDataRel());
566 Ctx->getCOFFSection(".rdata",
567 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
568 COFF::IMAGE_SCN_MEM_READ,
569 SectionKind::getReadOnly());
570 if (T.getOS() == Triple::Win32) {
572 Ctx->getCOFFSection(".CRT$XCU",
573 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
574 COFF::IMAGE_SCN_MEM_READ,
575 SectionKind::getReadOnly());
578 Ctx->getCOFFSection(".ctors",
579 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
580 COFF::IMAGE_SCN_MEM_READ |
581 COFF::IMAGE_SCN_MEM_WRITE,
582 SectionKind::getDataRel());
586 if (T.getOS() == Triple::Win32) {
588 Ctx->getCOFFSection(".CRT$XTX",
589 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
590 COFF::IMAGE_SCN_MEM_READ,
591 SectionKind::getReadOnly());
594 Ctx->getCOFFSection(".dtors",
595 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
596 COFF::IMAGE_SCN_MEM_READ |
597 COFF::IMAGE_SCN_MEM_WRITE,
598 SectionKind::getDataRel());
601 // FIXME: We're emitting LSDA info into a readonly section on COFF, even
602 // though it contains relocatable pointers. In PIC mode, this is probably a
603 // big runtime hit for C++ apps. Either the contents of the LSDA need to be
604 // adjusted or this should be a data section.
606 Ctx->getCOFFSection(".gcc_except_table",
607 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
608 COFF::IMAGE_SCN_MEM_READ,
609 SectionKind::getReadOnly());
613 Ctx->getCOFFSection(".debug_abbrev",
614 COFF::IMAGE_SCN_MEM_DISCARDABLE |
615 COFF::IMAGE_SCN_MEM_READ,
616 SectionKind::getMetadata());
618 Ctx->getCOFFSection(".debug_info",
619 COFF::IMAGE_SCN_MEM_DISCARDABLE |
620 COFF::IMAGE_SCN_MEM_READ,
621 SectionKind::getMetadata());
623 Ctx->getCOFFSection(".debug_line",
624 COFF::IMAGE_SCN_MEM_DISCARDABLE |
625 COFF::IMAGE_SCN_MEM_READ,
626 SectionKind::getMetadata());
628 Ctx->getCOFFSection(".debug_frame",
629 COFF::IMAGE_SCN_MEM_DISCARDABLE |
630 COFF::IMAGE_SCN_MEM_READ,
631 SectionKind::getMetadata());
632 DwarfPubNamesSection =
633 Ctx->getCOFFSection(".debug_pubnames",
634 COFF::IMAGE_SCN_MEM_DISCARDABLE |
635 COFF::IMAGE_SCN_MEM_READ,
636 SectionKind::getMetadata());
637 DwarfPubTypesSection =
638 Ctx->getCOFFSection(".debug_pubtypes",
639 COFF::IMAGE_SCN_MEM_DISCARDABLE |
640 COFF::IMAGE_SCN_MEM_READ,
641 SectionKind::getMetadata());
642 DwarfGnuPubNamesSection =
643 Ctx->getCOFFSection(".debug_gnu_pubnames",
644 COFF::IMAGE_SCN_MEM_DISCARDABLE |
645 COFF::IMAGE_SCN_MEM_READ,
646 SectionKind::getMetadata());
647 DwarfGnuPubTypesSection =
648 Ctx->getCOFFSection(".debug_gnu_pubtypes",
649 COFF::IMAGE_SCN_MEM_DISCARDABLE |
650 COFF::IMAGE_SCN_MEM_READ,
651 SectionKind::getMetadata());
653 Ctx->getCOFFSection(".debug_str",
654 COFF::IMAGE_SCN_MEM_DISCARDABLE |
655 COFF::IMAGE_SCN_MEM_READ,
656 SectionKind::getMetadata());
658 Ctx->getCOFFSection(".debug_loc",
659 COFF::IMAGE_SCN_MEM_DISCARDABLE |
660 COFF::IMAGE_SCN_MEM_READ,
661 SectionKind::getMetadata());
662 DwarfARangesSection =
663 Ctx->getCOFFSection(".debug_aranges",
664 COFF::IMAGE_SCN_MEM_DISCARDABLE |
665 COFF::IMAGE_SCN_MEM_READ,
666 SectionKind::getMetadata());
668 Ctx->getCOFFSection(".debug_ranges",
669 COFF::IMAGE_SCN_MEM_DISCARDABLE |
670 COFF::IMAGE_SCN_MEM_READ,
671 SectionKind::getMetadata());
672 DwarfMacroInfoSection =
673 Ctx->getCOFFSection(".debug_macinfo",
674 COFF::IMAGE_SCN_MEM_DISCARDABLE |
675 COFF::IMAGE_SCN_MEM_READ,
676 SectionKind::getMetadata());
679 Ctx->getCOFFSection(".drectve",
680 COFF::IMAGE_SCN_LNK_INFO,
681 SectionKind::getMetadata());
684 Ctx->getCOFFSection(".pdata",
685 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
686 COFF::IMAGE_SCN_MEM_READ,
687 SectionKind::getDataRel());
690 Ctx->getCOFFSection(".xdata",
691 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
692 COFF::IMAGE_SCN_MEM_READ,
693 SectionKind::getDataRel());
695 Ctx->getCOFFSection(".tls$",
696 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
697 COFF::IMAGE_SCN_MEM_READ |
698 COFF::IMAGE_SCN_MEM_WRITE,
699 SectionKind::getDataRel());
702 void MCObjectFileInfo::InitMCObjectFileInfo(StringRef TT, Reloc::Model relocm,
710 CommDirectiveSupportsAlignment = true;
711 SupportsWeakOmittedEHFrame = true;
712 IsFunctionEHFrameSymbolPrivate = true;
714 PersonalityEncoding = LSDAEncoding = FDEEncoding = FDECFIEncoding =
715 TTypeEncoding = dwarf::DW_EH_PE_absptr;
717 CompactUnwindDwarfEHFrameOnly = 0;
719 EHFrameSection = 0; // Created on demand.
720 CompactUnwindSection = 0; // Used only by selected targets.
721 DwarfAccelNamesSection = 0; // Used only by selected targets.
722 DwarfAccelObjCSection = 0; // Used only by selected targets.
723 DwarfAccelNamespaceSection = 0; // Used only by selected targets.
724 DwarfAccelTypesSection = 0; // Used only by selected targets.
727 Triple::ArchType Arch = T.getArch();
728 // FIXME: Checking for Arch here to filter out bogus triples such as
729 // cellspu-apple-darwin. Perhaps we should fix in Triple?
730 if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
731 Arch == Triple::arm || Arch == Triple::thumb ||
732 Arch == Triple::ppc || Arch == Triple::ppc64 ||
733 Arch == Triple::UnknownArch) &&
734 (T.isOSDarwin() || T.getEnvironment() == Triple::MachO)) {
736 InitMachOMCObjectFileInfo(T);
737 } else if ((Arch == Triple::x86 || Arch == Triple::x86_64) &&
738 (T.getEnvironment() != Triple::ELF) &&
739 (T.getOS() == Triple::MinGW32 || T.getOS() == Triple::Cygwin ||
740 T.getOS() == Triple::Win32)) {
742 InitCOFFMCObjectFileInfo(T);
745 InitELFMCObjectFileInfo(T);
749 const MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
750 return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
751 SectionKind::getMetadata(), 0, utostr(Hash));
755 MCObjectFileInfo::getDwarfTypesDWOSection(uint64_t Hash) const {
756 return Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS,
757 ELF::SHF_GROUP, SectionKind::getMetadata(), 0,
761 void MCObjectFileInfo::InitEHFrameSection() {
764 Ctx->getMachOSection("__TEXT", "__eh_frame",
765 MCSectionMachO::S_COALESCED |
766 MCSectionMachO::S_ATTR_NO_TOC |
767 MCSectionMachO::S_ATTR_STRIP_STATIC_SYMS |
768 MCSectionMachO::S_ATTR_LIVE_SUPPORT,
769 SectionKind::getReadOnly());
770 else if (Env == IsELF)
772 Ctx->getELFSection(".eh_frame", EHSectionType,
774 SectionKind::getDataRel());
777 Ctx->getCOFFSection(".eh_frame",
778 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
779 COFF::IMAGE_SCN_MEM_READ |
780 COFF::IMAGE_SCN_MEM_WRITE,
781 SectionKind::getDataRel());