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