LLVM: lib/MC/MCObjectFileInfo.cpp Source File

LLVM 22.0.0git
MCObjectFileInfo.cpp
Go to the documentation of this file.
1//===-- MCObjectFileInfo.cpp - Object File Information --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "llvm/MC/MCObjectFileInfo.h"
10#include "llvm/ADT/StringExtras.h"
11#include "llvm/BinaryFormat/COFF.h"
12#include "llvm/BinaryFormat/ELF.h"
13#include "llvm/BinaryFormat/SFrame.h"
14#include "llvm/BinaryFormat/Wasm.h"
15#include "llvm/MC/MCAsmInfo.h"
16#include "llvm/MC/MCContext.h"
17#include "llvm/MC/MCGOFFAttributes.h"
18#include "llvm/MC/MCSection.h"
19#include "llvm/MC/MCSectionCOFF.h"
20#include "llvm/MC/MCSectionDXContainer.h"
21#include "llvm/MC/MCSectionELF.h"
22#include "llvm/MC/MCSectionGOFF.h"
23#include "llvm/MC/MCSectionMachO.h"
24#include "llvm/MC/MCSectionSPIRV.h"
25#include "llvm/MC/MCSectionWasm.h"
26#include "llvm/MC/MCSectionXCOFF.h"
27#include "llvm/TargetParser/Triple.h"
28
29using namespace llvm;
30
31 static bool useCompactUnwind(const Triple &T) {
32 // Only on darwin.
33 if (!T.isOSDarwin())
34 return false;
35
36 // aarch64 always has it.
37 if (T.getArch() == Triple::aarch64 || T.getArch() == Triple::aarch64_32)
38 return true;
39
40 // armv7k always has it.
41 if (T.isWatchABI())
42 return true;
43
44 // Use it on newer version of OS X.
45 if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6))
46 return true;
47
48 // And the iOS simulator.
49 if (T.isiOS() && T.isX86())
50 return true;
51
52 // The rest of the simulators always have it.
53 if (T.isSimulatorEnvironment())
54 return true;
55
56 // XROS always has it.
57 if (T.isXROS())
58 return true;
59
60 return false;
61}
62
63void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
64 // MachO
65 SupportsWeakOmittedEHFrame = false;
66
67 EHFrameSection = Ctx->getMachOSection(
68 "__TEXT", "__eh_frame",
69 MachO::S_COALESCED | MachO::S_ATTR_NO_TOC |
70 MachO::S_ATTR_STRIP_STATIC_SYMS | MachO::S_ATTR_LIVE_SUPPORT,
71 SectionKind::getReadOnly());
72
73 if (T.isOSDarwin() &&
74 (T.getArch() == Triple::aarch64 || T.getArch() == Triple::aarch64_32 ||
75 T.isSimulatorEnvironment()))
76 SupportsCompactUnwindWithoutEHFrame = true;
77
78 switch (Ctx->emitDwarfUnwindInfo()) {
79 case EmitDwarfUnwindType::Always:
80 OmitDwarfIfHaveCompactUnwind = false;
81 break;
82 case EmitDwarfUnwindType::NoCompactUnwind:
83 OmitDwarfIfHaveCompactUnwind = true;
84 break;
85 case EmitDwarfUnwindType::Default:
86 OmitDwarfIfHaveCompactUnwind =
87 T.isWatchABI() || SupportsCompactUnwindWithoutEHFrame;
88 break;
89 }
90
91 FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
92
93 TextSection // .text
94 = Ctx->getMachOSection("__TEXT", "__text",
95 MachO::S_ATTR_PURE_INSTRUCTIONS,
96 SectionKind::getText());
97 DataSection // .data
98 = Ctx->getMachOSection("__DATA", "__data", 0, SectionKind::getData());
99
100 // BSSSection might not be expected initialized on msvc.
101 BSSSection = nullptr;
102
103 TLSDataSection // .tdata
104 = Ctx->getMachOSection("__DATA", "__thread_data",
105 MachO::S_THREAD_LOCAL_REGULAR,
106 SectionKind::getData());
107 TLSBSSSection // .tbss
108 = Ctx->getMachOSection("__DATA", "__thread_bss",
109 MachO::S_THREAD_LOCAL_ZEROFILL,
110 SectionKind::getThreadBSS());
111
112 // TODO: Verify datarel below.
113 TLSTLVSection // .tlv
114 = Ctx->getMachOSection("__DATA", "__thread_vars",
115 MachO::S_THREAD_LOCAL_VARIABLES,
116 SectionKind::getData());
117
118 TLSThreadInitSection = Ctx->getMachOSection(
119 "__DATA", "__thread_init", MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
120 SectionKind::getData());
121
122 CStringSection // .cstring
123 = Ctx->getMachOSection("__TEXT", "__cstring",
124 MachO::S_CSTRING_LITERALS,
125 SectionKind::getMergeable1ByteCString());
126 UStringSection
127 = Ctx->getMachOSection("__TEXT","__ustring", 0,
128 SectionKind::getMergeable2ByteCString());
129 FourByteConstantSection // .literal4
130 = Ctx->getMachOSection("__TEXT", "__literal4",
131 MachO::S_4BYTE_LITERALS,
132 SectionKind::getMergeableConst4());
133 EightByteConstantSection // .literal8
134 = Ctx->getMachOSection("__TEXT", "__literal8",
135 MachO::S_8BYTE_LITERALS,
136 SectionKind::getMergeableConst8());
137
138 SixteenByteConstantSection // .literal16
139 = Ctx->getMachOSection("__TEXT", "__literal16",
140 MachO::S_16BYTE_LITERALS,
141 SectionKind::getMergeableConst16());
142
143 ReadOnlySection // .const
144 = Ctx->getMachOSection("__TEXT", "__const", 0,
145 SectionKind::getReadOnly());
146
147 // If the target is not powerpc, map the coal sections to the non-coal
148 // sections.
149 //
150 // "__TEXT/__textcoal_nt" => section "__TEXT/__text"
151 // "__TEXT/__const_coal" => section "__TEXT/__const"
152 // "__DATA/__datacoal_nt" => section "__DATA/__data"
153 Triple::ArchType ArchTy = T.getArch();
154
155 ConstDataSection // .const_data
156 = Ctx->getMachOSection("__DATA", "__const", 0,
157 SectionKind::getReadOnlyWithRel());
158
159 if (ArchTy == Triple::ppc || ArchTy == Triple::ppc64) {
160 TextCoalSection
161 = Ctx->getMachOSection("__TEXT", "__textcoal_nt",
162 MachO::S_COALESCED |
163 MachO::S_ATTR_PURE_INSTRUCTIONS,
164 SectionKind::getText());
165 ConstTextCoalSection
166 = Ctx->getMachOSection("__TEXT", "__const_coal",
167 MachO::S_COALESCED,
168 SectionKind::getReadOnly());
169 DataCoalSection = Ctx->getMachOSection(
170 "__DATA", "__datacoal_nt", MachO::S_COALESCED, SectionKind::getData());
171 ConstDataCoalSection = DataCoalSection;
172 } else {
173 TextCoalSection = TextSection;
174 ConstTextCoalSection = ReadOnlySection;
175 DataCoalSection = DataSection;
176 ConstDataCoalSection = ConstDataSection;
177 }
178
179 DataCommonSection
180 = Ctx->getMachOSection("__DATA","__common",
181 MachO::S_ZEROFILL,
182 SectionKind::getBSS());
183 DataBSSSection
184 = Ctx->getMachOSection("__DATA","__bss", MachO::S_ZEROFILL,
185 SectionKind::getBSS());
186
187
188 LazySymbolPointerSection
189 = Ctx->getMachOSection("__DATA", "__la_symbol_ptr",
190 MachO::S_LAZY_SYMBOL_POINTERS,
191 SectionKind::getMetadata());
192 NonLazySymbolPointerSection
193 = Ctx->getMachOSection("__DATA", "__nl_symbol_ptr",
194 MachO::S_NON_LAZY_SYMBOL_POINTERS,
195 SectionKind::getMetadata());
196
197 ThreadLocalPointerSection
198 = Ctx->getMachOSection("__DATA", "__thread_ptr",
199 MachO::S_THREAD_LOCAL_VARIABLE_POINTERS,
200 SectionKind::getMetadata());
201
202 AddrSigSection = Ctx->getMachOSection("__DATA", "__llvm_addrsig", 0,
203 SectionKind::getData());
204
205 // Exception Handling.
206 LSDASection = Ctx->getMachOSection("__TEXT", "__gcc_except_tab", 0,
207 SectionKind::getReadOnlyWithRel());
208
209 COFFDebugSymbolsSection = nullptr;
210 COFFDebugTypesSection = nullptr;
211 COFFGlobalTypeHashesSection = nullptr;
212
213 if (useCompactUnwind(T)) {
214 CompactUnwindSection =
215 Ctx->getMachOSection("__LD", "__compact_unwind", MachO::S_ATTR_DEBUG,
216 SectionKind::getReadOnly());
217
218 if (T.isX86())
219 CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_X86_64_MODE_DWARF
220 else if (T.getArch() == Triple::aarch64 || T.getArch() == Triple::aarch64_32)
221 CompactUnwindDwarfEHFrameOnly = 0x03000000; // UNWIND_ARM64_MODE_DWARF
222 else if (T.getArch() == Triple::arm || T.getArch() == Triple::thumb)
223 CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_ARM_MODE_DWARF
224 }
225
226 // Debug Information.
227 DwarfDebugNamesSection =
228 Ctx->getMachOSection("__DWARF", "__debug_names", MachO::S_ATTR_DEBUG,
229 SectionKind::getMetadata(), "debug_names_begin");
230 DwarfAccelNamesSection =
231 Ctx->getMachOSection("__DWARF", "__apple_names", MachO::S_ATTR_DEBUG,
232 SectionKind::getMetadata(), "names_begin");
233 DwarfAccelObjCSection =
234 Ctx->getMachOSection("__DWARF", "__apple_objc", MachO::S_ATTR_DEBUG,
235 SectionKind::getMetadata(), "objc_begin");
236 // 16 character section limit...
237 DwarfAccelNamespaceSection =
238 Ctx->getMachOSection("__DWARF", "__apple_namespac", MachO::S_ATTR_DEBUG,
239 SectionKind::getMetadata(), "namespac_begin");
240 DwarfAccelTypesSection =
241 Ctx->getMachOSection("__DWARF", "__apple_types", MachO::S_ATTR_DEBUG,
242 SectionKind::getMetadata(), "types_begin");
243
244 DwarfSwiftASTSection =
245 Ctx->getMachOSection("__DWARF", "__swift_ast", MachO::S_ATTR_DEBUG,
246 SectionKind::getMetadata());
247
248 DwarfAbbrevSection =
249 Ctx->getMachOSection("__DWARF", "__debug_abbrev", MachO::S_ATTR_DEBUG,
250 SectionKind::getMetadata(), "section_abbrev");
251 DwarfInfoSection =
252 Ctx->getMachOSection("__DWARF", "__debug_info", MachO::S_ATTR_DEBUG,
253 SectionKind::getMetadata(), "section_info");
254 DwarfLineSection =
255 Ctx->getMachOSection("__DWARF", "__debug_line", MachO::S_ATTR_DEBUG,
256 SectionKind::getMetadata(), "section_line");
257 DwarfLineStrSection =
258 Ctx->getMachOSection("__DWARF", "__debug_line_str", MachO::S_ATTR_DEBUG,
259 SectionKind::getMetadata(), "section_line_str");
260 DwarfFrameSection =
261 Ctx->getMachOSection("__DWARF", "__debug_frame", MachO::S_ATTR_DEBUG,
262 SectionKind::getMetadata(), "section_frame");
263 DwarfPubNamesSection =
264 Ctx->getMachOSection("__DWARF", "__debug_pubnames", MachO::S_ATTR_DEBUG,
265 SectionKind::getMetadata());
266 DwarfPubTypesSection =
267 Ctx->getMachOSection("__DWARF", "__debug_pubtypes", MachO::S_ATTR_DEBUG,
268 SectionKind::getMetadata());
269 DwarfGnuPubNamesSection =
270 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubn", MachO::S_ATTR_DEBUG,
271 SectionKind::getMetadata());
272 DwarfGnuPubTypesSection =
273 Ctx->getMachOSection("__DWARF", "__debug_gnu_pubt", MachO::S_ATTR_DEBUG,
274 SectionKind::getMetadata());
275 DwarfStrSection =
276 Ctx->getMachOSection("__DWARF", "__debug_str", MachO::S_ATTR_DEBUG,
277 SectionKind::getMetadata(), "info_string");
278 DwarfStrOffSection =
279 Ctx->getMachOSection("__DWARF", "__debug_str_offs", MachO::S_ATTR_DEBUG,
280 SectionKind::getMetadata(), "section_str_off");
281 DwarfAddrSection =
282 Ctx->getMachOSection("__DWARF", "__debug_addr", MachO::S_ATTR_DEBUG,
283 SectionKind::getMetadata(), "section_info");
284 DwarfLocSection =
285 Ctx->getMachOSection("__DWARF", "__debug_loc", MachO::S_ATTR_DEBUG,
286 SectionKind::getMetadata(), "section_debug_loc");
287 DwarfLoclistsSection =
288 Ctx->getMachOSection("__DWARF", "__debug_loclists", MachO::S_ATTR_DEBUG,
289 SectionKind::getMetadata(), "section_debug_loc");
290
291 DwarfARangesSection =
292 Ctx->getMachOSection("__DWARF", "__debug_aranges", MachO::S_ATTR_DEBUG,
293 SectionKind::getMetadata());
294 DwarfRangesSection =
295 Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG,
296 SectionKind::getMetadata(), "debug_range");
297 DwarfRnglistsSection =
298 Ctx->getMachOSection("__DWARF", "__debug_rnglists", MachO::S_ATTR_DEBUG,
299 SectionKind::getMetadata(), "debug_range");
300 DwarfMacinfoSection =
301 Ctx->getMachOSection("__DWARF", "__debug_macinfo", MachO::S_ATTR_DEBUG,
302 SectionKind::getMetadata(), "debug_macinfo");
303 DwarfMacroSection =
304 Ctx->getMachOSection("__DWARF", "__debug_macro", MachO::S_ATTR_DEBUG,
305 SectionKind::getMetadata(), "debug_macro");
306 DwarfDebugInlineSection =
307 Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG,
308 SectionKind::getMetadata());
309 DwarfCUIndexSection =
310 Ctx->getMachOSection("__DWARF", "__debug_cu_index", MachO::S_ATTR_DEBUG,
311 SectionKind::getMetadata());
312 DwarfTUIndexSection =
313 Ctx->getMachOSection("__DWARF", "__debug_tu_index", MachO::S_ATTR_DEBUG,
314 SectionKind::getMetadata());
315 StackMapSection = Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps",
316 0, SectionKind::getMetadata());
317
318 FaultMapSection = Ctx->getMachOSection("__LLVM_FAULTMAPS", "__llvm_faultmaps",
319 0, SectionKind::getMetadata());
320
321 RemarksSection = Ctx->getMachOSection(
322 "__LLVM", "__remarks", MachO::S_ATTR_DEBUG, SectionKind::getMetadata());
323
324 // The architecture of dsymutil makes it very difficult to copy the Swift
325 // reflection metadata sections into the __TEXT segment, so dsymutil creates
326 // these sections in the __DWARF segment instead.
327 if (!Ctx->getSwift5ReflectionSegmentName().empty()) {
328#define HANDLE_SWIFT_SECTION(KIND, MACHO, ELF, COFF) \
329 Swift5ReflectionSections \
330 [llvm::binaryformat::Swift5ReflectionSectionKind::KIND] = \
331 Ctx->getMachOSection(Ctx->getSwift5ReflectionSegmentName().data(), \
332 MACHO, 0, SectionKind::getMetadata());
333#include "llvm/BinaryFormat/Swift.def"
334 }
335
336 TLSExtraDataSection = TLSTLVSection;
337}
338
339void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
340 switch (T.getArch()) {
341 case Triple::mips:
342 case Triple::mipsel:
343 case Triple::mips64:
344 case Triple::mips64el:
345 // We cannot use DW_EH_PE_sdata8 for the large PositionIndependent case
346 // since there is no R_MIPS_PC64 relocation (only a 32-bit version).
347 // In fact DW_EH_PE_sdata4 is enough for us now, and GNU ld doesn't
348 // support pcrel|sdata8 well. Let's use sdata4 for now.
349 if (PositionIndependent)
350 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
351 else
352 FDECFIEncoding = Ctx->getAsmInfo()->getCodePointerSize() == 4
353 ? dwarf::DW_EH_PE_sdata4
354 : dwarf::DW_EH_PE_sdata8;
355 break;
356 case Triple::ppc64:
357 case Triple::ppc64le:
358 case Triple::aarch64:
359 case Triple::aarch64_be:
360 case Triple::x86_64:
361 FDECFIEncoding = dwarf::DW_EH_PE_pcrel |
362 (Large ? dwarf::DW_EH_PE_sdata8 : dwarf::DW_EH_PE_sdata4);
363 break;
364 case Triple::bpfel:
365 case Triple::bpfeb:
366 FDECFIEncoding = dwarf::DW_EH_PE_sdata8;
367 break;
368 case Triple::hexagon:
369 FDECFIEncoding =
370 PositionIndependent ? dwarf::DW_EH_PE_pcrel : dwarf::DW_EH_PE_absptr;
371 break;
372 case Triple::xtensa:
373 FDECFIEncoding = dwarf::DW_EH_PE_sdata4;
374 break;
375 default:
376 FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
377 break;
378 }
379
380 unsigned EHSectionType = T.getArch() == Triple::x86_64
381 ? ELF::SHT_X86_64_UNWIND
382 : ELF::SHT_PROGBITS;
383 switch (T.getArch()) {
384 case Triple::x86_64:
385 SFrameABIArch = sframe::ABI::AMD64EndianLittle;
386 break;
387 case Triple::aarch64:
388 SFrameABIArch = sframe::ABI::AArch64EndianLittle;
389 break;
390 case Triple::aarch64_be:
391 SFrameABIArch = sframe::ABI::AArch64EndianBig;
392 break;
393 default:
394 break;
395 }
396
397 // Solaris requires different flags for .eh_frame to seemingly every other
398 // platform.
399 unsigned EHSectionFlags = ELF::SHF_ALLOC;
400 if (T.isOSSolaris() && T.getArch() != Triple::x86_64)
401 EHSectionFlags |= ELF::SHF_WRITE;
402
403 // ELF
404 BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
405 ELF::SHF_WRITE | ELF::SHF_ALLOC);
406
407 TextSection = Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
408 ELF::SHF_EXECINSTR | ELF::SHF_ALLOC);
409
410 DataSection = Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
411 ELF::SHF_WRITE | ELF::SHF_ALLOC);
412
413 ReadOnlySection =
414 Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
415
416 TLSDataSection =
417 Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
418 ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
419
420 TLSBSSSection = Ctx->getELFSection(
421 ".tbss", ELF::SHT_NOBITS, ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
422
423 DataRelROSection = Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
424 ELF::SHF_ALLOC | ELF::SHF_WRITE);
425
426 MergeableConst4Section =
427 Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
428 ELF::SHF_ALLOC | ELF::SHF_MERGE, 4);
429
430 MergeableConst8Section =
431 Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
432 ELF::SHF_ALLOC | ELF::SHF_MERGE, 8);
433
434 MergeableConst16Section =
435 Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
436 ELF::SHF_ALLOC | ELF::SHF_MERGE, 16);
437
438 MergeableConst32Section =
439 Ctx->getELFSection(".rodata.cst32", ELF::SHT_PROGBITS,
440 ELF::SHF_ALLOC | ELF::SHF_MERGE, 32);
441
442 // Exception Handling Sections.
443
444 // FIXME: We're emitting LSDA info into a readonly section on ELF, even though
445 // it contains relocatable pointers. In PIC mode, this is probably a big
446 // runtime hit for C++ apps. Either the contents of the LSDA need to be
447 // adjusted or this should be a data section.
448 LSDASection = Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
449 ELF::SHF_ALLOC);
450
451 COFFDebugSymbolsSection = nullptr;
452 COFFDebugTypesSection = nullptr;
453
454 unsigned DebugSecType = ELF::SHT_PROGBITS;
455
456 // MIPS .debug_* sections should have SHT_MIPS_DWARF section type
457 // to distinguish among sections contain DWARF and ECOFF debug formats.
458 // Sections with ECOFF debug format are obsoleted and marked by SHT_PROGBITS.
459 if (T.isMIPS())
460 DebugSecType = ELF::SHT_MIPS_DWARF;
461
462 // Debug Info Sections.
463 DwarfAbbrevSection =
464 Ctx->getELFSection(".debug_abbrev", DebugSecType, 0);
465 DwarfInfoSection = Ctx->getELFSection(".debug_info", DebugSecType, 0);
466 DwarfLineSection = Ctx->getELFSection(".debug_line", DebugSecType, 0);
467 DwarfLineStrSection =
468 Ctx->getELFSection(".debug_line_str", DebugSecType,
469 ELF::SHF_MERGE | ELF::SHF_STRINGS, 1);
470 DwarfFrameSection = Ctx->getELFSection(".debug_frame", DebugSecType, 0);
471 DwarfPubNamesSection =
472 Ctx->getELFSection(".debug_pubnames", DebugSecType, 0);
473 DwarfPubTypesSection =
474 Ctx->getELFSection(".debug_pubtypes", DebugSecType, 0);
475 DwarfGnuPubNamesSection =
476 Ctx->getELFSection(".debug_gnu_pubnames", DebugSecType, 0);
477 DwarfGnuPubTypesSection =
478 Ctx->getELFSection(".debug_gnu_pubtypes", DebugSecType, 0);
479 DwarfStrSection =
480 Ctx->getELFSection(".debug_str", DebugSecType,
481 ELF::SHF_MERGE | ELF::SHF_STRINGS, 1);
482 DwarfLocSection = Ctx->getELFSection(".debug_loc", DebugSecType, 0);
483 DwarfARangesSection =
484 Ctx->getELFSection(".debug_aranges", DebugSecType, 0);
485 DwarfRangesSection =
486 Ctx->getELFSection(".debug_ranges", DebugSecType, 0);
487 DwarfMacinfoSection =
488 Ctx->getELFSection(".debug_macinfo", DebugSecType, 0);
489 DwarfMacroSection = Ctx->getELFSection(".debug_macro", DebugSecType, 0);
490
491 // DWARF5 Experimental Debug Info
492
493 // Accelerator Tables
494 DwarfDebugNamesSection =
495 Ctx->getELFSection(".debug_names", ELF::SHT_PROGBITS, 0);
496 DwarfAccelNamesSection =
497 Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0);
498 DwarfAccelObjCSection =
499 Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0);
500 DwarfAccelNamespaceSection =
501 Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0);
502 DwarfAccelTypesSection =
503 Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0);
504
505 // String Offset and Address Sections
506 DwarfStrOffSection =
507 Ctx->getELFSection(".debug_str_offsets", DebugSecType, 0);
508 DwarfAddrSection = Ctx->getELFSection(".debug_addr", DebugSecType, 0);
509 DwarfRnglistsSection = Ctx->getELFSection(".debug_rnglists", DebugSecType, 0);
510 DwarfLoclistsSection = Ctx->getELFSection(".debug_loclists", DebugSecType, 0);
511
512 // Fission Sections
513 DwarfInfoDWOSection =
514 Ctx->getELFSection(".debug_info.dwo", DebugSecType, ELF::SHF_EXCLUDE);
515 DwarfTypesDWOSection =
516 Ctx->getELFSection(".debug_types.dwo", DebugSecType, ELF::SHF_EXCLUDE);
517 DwarfAbbrevDWOSection =
518 Ctx->getELFSection(".debug_abbrev.dwo", DebugSecType, ELF::SHF_EXCLUDE);
519 DwarfStrDWOSection = Ctx->getELFSection(
520 ".debug_str.dwo", DebugSecType,
521 ELF::SHF_MERGE | ELF::SHF_STRINGS | ELF::SHF_EXCLUDE, 1);
522 DwarfLineDWOSection =
523 Ctx->getELFSection(".debug_line.dwo", DebugSecType, ELF::SHF_EXCLUDE);
524 DwarfLocDWOSection =
525 Ctx->getELFSection(".debug_loc.dwo", DebugSecType, ELF::SHF_EXCLUDE);
526 DwarfStrOffDWOSection = Ctx->getELFSection(".debug_str_offsets.dwo",
527 DebugSecType, ELF::SHF_EXCLUDE);
528 DwarfRnglistsDWOSection =
529 Ctx->getELFSection(".debug_rnglists.dwo", DebugSecType, ELF::SHF_EXCLUDE);
530 DwarfMacinfoDWOSection =
531 Ctx->getELFSection(".debug_macinfo.dwo", DebugSecType, ELF::SHF_EXCLUDE);
532 DwarfMacroDWOSection =
533 Ctx->getELFSection(".debug_macro.dwo", DebugSecType, ELF::SHF_EXCLUDE);
534
535 DwarfLoclistsDWOSection =
536 Ctx->getELFSection(".debug_loclists.dwo", DebugSecType, ELF::SHF_EXCLUDE);
537
538 // DWP Sections
539 DwarfCUIndexSection =
540 Ctx->getELFSection(".debug_cu_index", DebugSecType, 0);
541 DwarfTUIndexSection =
542 Ctx->getELFSection(".debug_tu_index", DebugSecType, 0);
543
544 StackMapSection =
545 Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
546
547 FaultMapSection =
548 Ctx->getELFSection(".llvm_faultmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
549
550 EHFrameSection =
551 Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
552
553 SFrameSection =
554 Ctx->getELFSection(".sframe", ELF::SHT_GNU_SFRAME, ELF::SHF_ALLOC);
555
556 CallGraphSection =
557 Ctx->getELFSection(".llvm.callgraph", ELF::SHT_LLVM_CALL_GRAPH, 0);
558
559 StackSizesSection = Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, 0);
560
561 PseudoProbeSection = Ctx->getELFSection(".pseudo_probe", DebugSecType, 0);
562 PseudoProbeDescSection =
563 Ctx->getELFSection(".pseudo_probe_desc", DebugSecType, 0);
564
565 LLVMStatsSection = Ctx->getELFSection(".llvm_stats", ELF::SHT_PROGBITS, 0);
566}
567
568void MCObjectFileInfo::initGOFFMCObjectFileInfo(const Triple &T) {
569 MCSectionGOFF *RootSDSection = Ctx->getGOFFSection(
570 SectionKind::getMetadata(), "#C",
571 GOFF::SDAttr{GOFF::ESD_TA_Rent, GOFF::ESD_BSC_Section});
572
573 MCSectionGOFF *ADAEDSection = Ctx->getGOFFSection(
574 SectionKind::getMetadata(), GOFF::CLASS_WSA,
575 GOFF::EDAttr{false, GOFF::ESD_RMODE_64, GOFF::ESD_NS_Parts,
576 GOFF::ESD_TS_ByteOriented, GOFF::ESD_BA_Merge,
577 GOFF::ESD_LB_Deferred, GOFF::ESD_RQ_1,
578 GOFF::ESD_ALIGN_Quadword, 0},
579 RootSDSection);
580 ADASection = Ctx->getGOFFSection(SectionKind::getData(), "#S",
581 GOFF::PRAttr{false, GOFF::ESD_EXE_DATA,
582 GOFF::ESD_LT_XPLink,
583 GOFF::ESD_BSC_Section, 0},
584 ADAEDSection);
585
586 TextSection = Ctx->getGOFFSection(
587 SectionKind::getText(), GOFF::CLASS_CODE,
588 GOFF::EDAttr{true, GOFF::ESD_RMODE_64, GOFF::ESD_NS_NormalName,
589 GOFF::ESD_TS_ByteOriented, GOFF::ESD_BA_Concatenate,
590 GOFF::ESD_LB_Initial, GOFF::ESD_RQ_0,
591 GOFF::ESD_ALIGN_Doubleword, 0},
592 RootSDSection);
593
594 MCSectionGOFF *PPA2ListEDSection = Ctx->getGOFFSection(
595 SectionKind::getMetadata(), GOFF::CLASS_PPA2,
596 GOFF::EDAttr{true, GOFF::ESD_RMODE_64, GOFF::ESD_NS_Parts,
597 GOFF::ESD_TS_ByteOriented, GOFF::ESD_BA_Merge,
598 GOFF::ESD_LB_Initial, GOFF::ESD_RQ_0,
599 GOFF::ESD_ALIGN_Doubleword, 0},
600 RootSDSection);
601 PPA2ListSection = Ctx->getGOFFSection(SectionKind::getData(), ".&ppa2",
602 GOFF::PRAttr{true, GOFF::ESD_EXE_DATA,
603 GOFF::ESD_LT_OS,
604 GOFF::ESD_BSC_Section, 0},
605 PPA2ListEDSection);
606
607 IDRLSection = Ctx->getGOFFSection(
608 SectionKind::getData(), "B_IDRL",
609 GOFF::EDAttr{true, GOFF::ESD_RMODE_64, GOFF::ESD_NS_NormalName,
610 GOFF::ESD_TS_Structured, GOFF::ESD_BA_Concatenate,
611 GOFF::ESD_LB_NoLoad, GOFF::ESD_RQ_0,
612 GOFF::ESD_ALIGN_Doubleword, 0},
613 RootSDSection);
614}
615
616void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
617 EHFrameSection =
618 Ctx->getCOFFSection(".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
619 COFF::IMAGE_SCN_MEM_READ);
620
621 // Set the `IMAGE_SCN_MEM_16BIT` flag when compiling for thumb mode. This is
622 // used to indicate to the linker that the text segment contains thumb instructions
623 // and to set the ISA selection bit for calls accordingly.
624 const bool IsThumb = T.getArch() == Triple::thumb;
625
626 // COFF
627 BSSSection = Ctx->getCOFFSection(
628 ".bss", COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
629 COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE);
630 TextSection = Ctx->getCOFFSection(
631 ".text",
632 (IsThumb ? COFF::IMAGE_SCN_MEM_16BIT : (COFF::SectionCharacteristics)0) |
633 COFF::IMAGE_SCN_CNT_CODE | COFF::IMAGE_SCN_MEM_EXECUTE |
634 COFF::IMAGE_SCN_MEM_READ);
635 DataSection = Ctx->getCOFFSection(
636 ".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
637 COFF::IMAGE_SCN_MEM_WRITE);
638 ReadOnlySection =
639 Ctx->getCOFFSection(".rdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
640 COFF::IMAGE_SCN_MEM_READ);
641
642 if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::aarch64 ||
643 T.getArch() == Triple::arm || T.getArch() == Triple::thumb) {
644 // On Windows with SEH, the LSDA is emitted into the .xdata section
645 LSDASection = nullptr;
646 } else {
647 LSDASection = Ctx->getCOFFSection(".gcc_except_table",
648 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
649 COFF::IMAGE_SCN_MEM_READ);
650 }
651
652 if (T.getArch() == Triple::aarch64) {
653 ImportCallSection =
654 Ctx->getCOFFSection(".impcall", COFF::IMAGE_SCN_LNK_INFO);
655 } else if (T.getArch() == Triple::x86_64) {
656 // Import Call Optimization on x64 leverages the same metadata as the
657 // retpoline mitigation, hence the unusual section name.
658 ImportCallSection =
659 Ctx->getCOFFSection(".retplne", COFF::IMAGE_SCN_LNK_INFO);
660 }
661
662 // Debug info.
663 COFFDebugSymbolsSection =
664 Ctx->getCOFFSection(".debug$S", (COFF::IMAGE_SCN_MEM_DISCARDABLE |
665 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
666 COFF::IMAGE_SCN_MEM_READ));
667 COFFDebugTypesSection =
668 Ctx->getCOFFSection(".debug$T", (COFF::IMAGE_SCN_MEM_DISCARDABLE |
669 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
670 COFF::IMAGE_SCN_MEM_READ));
671 COFFGlobalTypeHashesSection =
672 Ctx->getCOFFSection(".debug$H", (COFF::IMAGE_SCN_MEM_DISCARDABLE |
673 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
674 COFF::IMAGE_SCN_MEM_READ));
675
676 DwarfAbbrevSection = Ctx->getCOFFSection(
677 ".debug_abbrev", COFF::IMAGE_SCN_MEM_DISCARDABLE |
678 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
679 COFF::IMAGE_SCN_MEM_READ);
680 DwarfInfoSection = Ctx->getCOFFSection(
681 ".debug_info", COFF::IMAGE_SCN_MEM_DISCARDABLE |
682 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
683 COFF::IMAGE_SCN_MEM_READ);
684 DwarfLineSection = Ctx->getCOFFSection(
685 ".debug_line", COFF::IMAGE_SCN_MEM_DISCARDABLE |
686 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
687 COFF::IMAGE_SCN_MEM_READ);
688 DwarfLineStrSection = Ctx->getCOFFSection(
689 ".debug_line_str", COFF::IMAGE_SCN_MEM_DISCARDABLE |
690 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
691 COFF::IMAGE_SCN_MEM_READ);
692 DwarfFrameSection = Ctx->getCOFFSection(
693 ".debug_frame", COFF::IMAGE_SCN_MEM_DISCARDABLE |
694 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
695 COFF::IMAGE_SCN_MEM_READ);
696 DwarfPubNamesSection = Ctx->getCOFFSection(
697 ".debug_pubnames", COFF::IMAGE_SCN_MEM_DISCARDABLE |
698 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
699 COFF::IMAGE_SCN_MEM_READ);
700 DwarfPubTypesSection = Ctx->getCOFFSection(
701 ".debug_pubtypes", COFF::IMAGE_SCN_MEM_DISCARDABLE |
702 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
703 COFF::IMAGE_SCN_MEM_READ);
704 DwarfGnuPubNamesSection = Ctx->getCOFFSection(
705 ".debug_gnu_pubnames", COFF::IMAGE_SCN_MEM_DISCARDABLE |
706 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
707 COFF::IMAGE_SCN_MEM_READ);
708 DwarfGnuPubTypesSection = Ctx->getCOFFSection(
709 ".debug_gnu_pubtypes", COFF::IMAGE_SCN_MEM_DISCARDABLE |
710 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
711 COFF::IMAGE_SCN_MEM_READ);
712 DwarfStrSection = Ctx->getCOFFSection(
713 ".debug_str", COFF::IMAGE_SCN_MEM_DISCARDABLE |
714 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
715 COFF::IMAGE_SCN_MEM_READ);
716 DwarfStrOffSection = Ctx->getCOFFSection(
717 ".debug_str_offsets", COFF::IMAGE_SCN_MEM_DISCARDABLE |
718 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
719 COFF::IMAGE_SCN_MEM_READ);
720 DwarfLocSection = Ctx->getCOFFSection(
721 ".debug_loc", COFF::IMAGE_SCN_MEM_DISCARDABLE |
722 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
723 COFF::IMAGE_SCN_MEM_READ);
724 DwarfLoclistsSection = Ctx->getCOFFSection(
725 ".debug_loclists", COFF::IMAGE_SCN_MEM_DISCARDABLE |
726 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
727 COFF::IMAGE_SCN_MEM_READ);
728 DwarfARangesSection = Ctx->getCOFFSection(
729 ".debug_aranges", COFF::IMAGE_SCN_MEM_DISCARDABLE |
730 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
731 COFF::IMAGE_SCN_MEM_READ);
732 DwarfRangesSection = Ctx->getCOFFSection(
733 ".debug_ranges", COFF::IMAGE_SCN_MEM_DISCARDABLE |
734 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
735 COFF::IMAGE_SCN_MEM_READ);
736 DwarfRnglistsSection = Ctx->getCOFFSection(
737 ".debug_rnglists", COFF::IMAGE_SCN_MEM_DISCARDABLE |
738 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
739 COFF::IMAGE_SCN_MEM_READ);
740 DwarfMacinfoSection = Ctx->getCOFFSection(
741 ".debug_macinfo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
742 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
743 COFF::IMAGE_SCN_MEM_READ);
744 DwarfMacroSection = Ctx->getCOFFSection(
745 ".debug_macro", COFF::IMAGE_SCN_MEM_DISCARDABLE |
746 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
747 COFF::IMAGE_SCN_MEM_READ);
748 DwarfMacinfoDWOSection = Ctx->getCOFFSection(
749 ".debug_macinfo.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
750 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
751 COFF::IMAGE_SCN_MEM_READ);
752 DwarfMacroDWOSection = Ctx->getCOFFSection(
753 ".debug_macro.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
754 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
755 COFF::IMAGE_SCN_MEM_READ);
756 DwarfInfoDWOSection = Ctx->getCOFFSection(
757 ".debug_info.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
758 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
759 COFF::IMAGE_SCN_MEM_READ);
760 DwarfTypesDWOSection = Ctx->getCOFFSection(
761 ".debug_types.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
762 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
763 COFF::IMAGE_SCN_MEM_READ);
764 DwarfAbbrevDWOSection = Ctx->getCOFFSection(
765 ".debug_abbrev.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
766 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
767 COFF::IMAGE_SCN_MEM_READ);
768 DwarfStrDWOSection = Ctx->getCOFFSection(
769 ".debug_str.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
770 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
771 COFF::IMAGE_SCN_MEM_READ);
772 DwarfLineDWOSection = Ctx->getCOFFSection(
773 ".debug_line.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
774 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
775 COFF::IMAGE_SCN_MEM_READ);
776 DwarfLocDWOSection = Ctx->getCOFFSection(
777 ".debug_loc.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
778 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
779 COFF::IMAGE_SCN_MEM_READ);
780 DwarfLoclistsDWOSection = Ctx->getCOFFSection(
781 ".debug_loclists.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
782 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
783 COFF::IMAGE_SCN_MEM_READ);
784 DwarfStrOffDWOSection = Ctx->getCOFFSection(
785 ".debug_str_offsets.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
786 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
787 COFF::IMAGE_SCN_MEM_READ);
788 DwarfRnglistsDWOSection = Ctx->getCOFFSection(
789 ".debug_rnglists.dwo", COFF::IMAGE_SCN_MEM_DISCARDABLE |
790 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
791 COFF::IMAGE_SCN_MEM_READ);
792 DwarfAddrSection = Ctx->getCOFFSection(
793 ".debug_addr", COFF::IMAGE_SCN_MEM_DISCARDABLE |
794 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
795 COFF::IMAGE_SCN_MEM_READ);
796 DwarfCUIndexSection = Ctx->getCOFFSection(
797 ".debug_cu_index", COFF::IMAGE_SCN_MEM_DISCARDABLE |
798 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
799 COFF::IMAGE_SCN_MEM_READ);
800 DwarfTUIndexSection = Ctx->getCOFFSection(
801 ".debug_tu_index", COFF::IMAGE_SCN_MEM_DISCARDABLE |
802 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
803 COFF::IMAGE_SCN_MEM_READ);
804 DwarfDebugNamesSection = Ctx->getCOFFSection(
805 ".debug_names", COFF::IMAGE_SCN_MEM_DISCARDABLE |
806 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
807 COFF::IMAGE_SCN_MEM_READ);
808 DwarfAccelNamesSection = Ctx->getCOFFSection(
809 ".apple_names", COFF::IMAGE_SCN_MEM_DISCARDABLE |
810 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
811 COFF::IMAGE_SCN_MEM_READ);
812 DwarfAccelNamespaceSection = Ctx->getCOFFSection(
813 ".apple_namespaces", COFF::IMAGE_SCN_MEM_DISCARDABLE |
814 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
815 COFF::IMAGE_SCN_MEM_READ);
816 DwarfAccelTypesSection = Ctx->getCOFFSection(
817 ".apple_types", COFF::IMAGE_SCN_MEM_DISCARDABLE |
818 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
819 COFF::IMAGE_SCN_MEM_READ);
820 DwarfAccelObjCSection = Ctx->getCOFFSection(
821 ".apple_objc", COFF::IMAGE_SCN_MEM_DISCARDABLE |
822 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
823 COFF::IMAGE_SCN_MEM_READ);
824
825 DrectveSection = Ctx->getCOFFSection(
826 ".drectve", COFF::IMAGE_SCN_LNK_INFO | COFF::IMAGE_SCN_LNK_REMOVE);
827
828 PDataSection =
829 Ctx->getCOFFSection(".pdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
830 COFF::IMAGE_SCN_MEM_READ);
831
832 XDataSection =
833 Ctx->getCOFFSection(".xdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
834 COFF::IMAGE_SCN_MEM_READ);
835
836 SXDataSection = Ctx->getCOFFSection(".sxdata", COFF::IMAGE_SCN_LNK_INFO);
837
838 GEHContSection =
839 Ctx->getCOFFSection(".gehcont$y", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
840 COFF::IMAGE_SCN_MEM_READ);
841
842 GFIDsSection =
843 Ctx->getCOFFSection(".gfids$y", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
844 COFF::IMAGE_SCN_MEM_READ);
845
846 GIATsSection =
847 Ctx->getCOFFSection(".giats$y", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
848 COFF::IMAGE_SCN_MEM_READ);
849
850 GLJMPSection =
851 Ctx->getCOFFSection(".gljmp$y", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
852 COFF::IMAGE_SCN_MEM_READ);
853
854 TLSDataSection = Ctx->getCOFFSection(
855 ".tls$", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
856 COFF::IMAGE_SCN_MEM_WRITE);
857
858 StackMapSection = Ctx->getCOFFSection(".llvm_stackmaps",
859 COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
860 COFF::IMAGE_SCN_MEM_READ);
861
862 // Set IMAGE_SCN_MEM_DISCARDABLE so that lld will not truncate section name.
863 PseudoProbeSection = Ctx->getCOFFSection(
864 ".pseudo_probe", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
865 COFF::IMAGE_SCN_MEM_DISCARDABLE |
866 COFF::IMAGE_SCN_MEM_READ);
867 PseudoProbeDescSection = Ctx->getCOFFSection(
868 ".pseudo_probe_desc", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
869 COFF::IMAGE_SCN_MEM_DISCARDABLE |
870 COFF::IMAGE_SCN_MEM_READ);
871}
872
873void MCObjectFileInfo::initSPIRVMCObjectFileInfo(const Triple &T) {
874 // Put everything in a single binary section.
875 TextSection = Ctx->getSPIRVSection();
876}
877
878void MCObjectFileInfo::initWasmMCObjectFileInfo(const Triple &T) {
879 TextSection = Ctx->getWasmSection(".text", SectionKind::getText());
880 DataSection = Ctx->getWasmSection(".data", SectionKind::getData());
881
882 DwarfLineSection =
883 Ctx->getWasmSection(".debug_line", SectionKind::getMetadata());
884 DwarfLineStrSection =
885 Ctx->getWasmSection(".debug_line_str", SectionKind::getMetadata(),
886 wasm::WASM_SEG_FLAG_STRINGS);
887 DwarfStrSection = Ctx->getWasmSection(
888 ".debug_str", SectionKind::getMetadata(), wasm::WASM_SEG_FLAG_STRINGS);
889 DwarfLocSection =
890 Ctx->getWasmSection(".debug_loc", SectionKind::getMetadata());
891 DwarfAbbrevSection =
892 Ctx->getWasmSection(".debug_abbrev", SectionKind::getMetadata());
893 DwarfARangesSection = Ctx->getWasmSection(".debug_aranges", SectionKind::getMetadata());
894 DwarfRangesSection =
895 Ctx->getWasmSection(".debug_ranges", SectionKind::getMetadata());
896 DwarfMacinfoSection =
897 Ctx->getWasmSection(".debug_macinfo", SectionKind::getMetadata());
898 DwarfMacroSection =
899 Ctx->getWasmSection(".debug_macro", SectionKind::getMetadata());
900 DwarfCUIndexSection = Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata());
901 DwarfTUIndexSection = Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata());
902 DwarfInfoSection =
903 Ctx->getWasmSection(".debug_info", SectionKind::getMetadata());
904 DwarfFrameSection = Ctx->getWasmSection(".debug_frame", SectionKind::getMetadata());
905 DwarfPubNamesSection = Ctx->getWasmSection(".debug_pubnames", SectionKind::getMetadata());
906 DwarfPubTypesSection = Ctx->getWasmSection(".debug_pubtypes", SectionKind::getMetadata());
907 DwarfGnuPubNamesSection =
908 Ctx->getWasmSection(".debug_gnu_pubnames", SectionKind::getMetadata());
909 DwarfGnuPubTypesSection =
910 Ctx->getWasmSection(".debug_gnu_pubtypes", SectionKind::getMetadata());
911
912 DwarfDebugNamesSection =
913 Ctx->getWasmSection(".debug_names", SectionKind::getMetadata());
914 DwarfStrOffSection =
915 Ctx->getWasmSection(".debug_str_offsets", SectionKind::getMetadata());
916 DwarfAddrSection =
917 Ctx->getWasmSection(".debug_addr", SectionKind::getMetadata());
918 DwarfRnglistsSection =
919 Ctx->getWasmSection(".debug_rnglists", SectionKind::getMetadata());
920 DwarfLoclistsSection =
921 Ctx->getWasmSection(".debug_loclists", SectionKind::getMetadata());
922
923 // Fission Sections
924 DwarfInfoDWOSection =
925 Ctx->getWasmSection(".debug_info.dwo", SectionKind::getMetadata());
926 DwarfTypesDWOSection =
927 Ctx->getWasmSection(".debug_types.dwo", SectionKind::getMetadata());
928 DwarfAbbrevDWOSection =
929 Ctx->getWasmSection(".debug_abbrev.dwo", SectionKind::getMetadata());
930 DwarfStrDWOSection =
931 Ctx->getWasmSection(".debug_str.dwo", SectionKind::getMetadata(),
932 wasm::WASM_SEG_FLAG_STRINGS);
933 DwarfLineDWOSection =
934 Ctx->getWasmSection(".debug_line.dwo", SectionKind::getMetadata());
935 DwarfLocDWOSection =
936 Ctx->getWasmSection(".debug_loc.dwo", SectionKind::getMetadata());
937 DwarfStrOffDWOSection =
938 Ctx->getWasmSection(".debug_str_offsets.dwo", SectionKind::getMetadata());
939 DwarfRnglistsDWOSection =
940 Ctx->getWasmSection(".debug_rnglists.dwo", SectionKind::getMetadata());
941 DwarfMacinfoDWOSection =
942 Ctx->getWasmSection(".debug_macinfo.dwo", SectionKind::getMetadata());
943 DwarfMacroDWOSection =
944 Ctx->getWasmSection(".debug_macro.dwo", SectionKind::getMetadata());
945
946 DwarfLoclistsDWOSection =
947 Ctx->getWasmSection(".debug_loclists.dwo", SectionKind::getMetadata());
948
949 // DWP Sections
950 DwarfCUIndexSection =
951 Ctx->getWasmSection(".debug_cu_index", SectionKind::getMetadata());
952 DwarfTUIndexSection =
953 Ctx->getWasmSection(".debug_tu_index", SectionKind::getMetadata());
954
955 // Wasm use data section for LSDA.
956 // TODO Consider putting each function's exception table in a separate
957 // section, as in -function-sections, to facilitate lld's --gc-section.
958 LSDASection = Ctx->getWasmSection(".rodata.gcc_except_table",
959 SectionKind::getReadOnlyWithRel());
960
961 // TODO: Define more sections.
962}
963
964void MCObjectFileInfo::initXCOFFMCObjectFileInfo(const Triple &T) {
965 // The default csect for program code. Functions without a specified section
966 // get placed into this csect. The choice of csect name is not a property of
967 // the ABI or object file format, but various tools rely on the section
968 // name being empty (considering named symbols to be "user symbol names").
969 TextSection = Ctx->getXCOFFSection(
970 "..text..", // Use a non-null name to work around an AIX assembler bug...
971 SectionKind::getText(),
972 XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_PR, XCOFF::XTY_SD),
973 /* MultiSymbolsAllowed*/ true);
974
975 // ... but use a null name when generating the symbol table.
976 MCSectionXCOFF *TS = static_cast<MCSectionXCOFF *>(TextSection);
977 TS->getQualNameSymbol()->setSymbolTableName("");
978 TS->setSymbolTableName("");
979
980 DataSection = Ctx->getXCOFFSection(
981 ".data", SectionKind::getData(),
982 XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RW, XCOFF::XTY_SD),
983 /* MultiSymbolsAllowed*/ true);
984
985 ReadOnlySection = Ctx->getXCOFFSection(
986 ".rodata", SectionKind::getReadOnly(),
987 XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RO, XCOFF::XTY_SD),
988 /* MultiSymbolsAllowed*/ true);
989 ReadOnlySection->setAlignment(Align(4));
990
991 ReadOnly8Section = Ctx->getXCOFFSection(
992 ".rodata.8", SectionKind::getReadOnly(),
993 XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RO, XCOFF::XTY_SD),
994 /* MultiSymbolsAllowed*/ true);
995 ReadOnly8Section->setAlignment(Align(8));
996
997 ReadOnly16Section = Ctx->getXCOFFSection(
998 ".rodata.16", SectionKind::getReadOnly(),
999 XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RO, XCOFF::XTY_SD),
1000 /* MultiSymbolsAllowed*/ true);
1001 ReadOnly16Section->setAlignment(Align(16));
1002
1003 TLSDataSection = Ctx->getXCOFFSection(
1004 ".tdata", SectionKind::getThreadData(),
1005 XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_TL, XCOFF::XTY_SD),
1006 /* MultiSymbolsAllowed*/ true);
1007
1008 TOCBaseSection = Ctx->getXCOFFSection(
1009 "TOC", SectionKind::getData(),
1010 XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_TC0,
1011 XCOFF::XTY_SD));
1012
1013 // The TOC-base always has 0 size, but 4 byte alignment.
1014 TOCBaseSection->setAlignment(Align(4));
1015
1016 LSDASection = Ctx->getXCOFFSection(
1017 ".gcc_except_table", SectionKind::getReadOnly(),
1018 XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RO,
1019 XCOFF::XTY_SD));
1020
1021 CompactUnwindSection = Ctx->getXCOFFSection(
1022 ".eh_info_table", SectionKind::getData(),
1023 XCOFF::CsectProperties(XCOFF::StorageMappingClass::XMC_RW,
1024 XCOFF::XTY_SD));
1025
1026 // DWARF sections for XCOFF are not csects. They are special STYP_DWARF
1027 // sections, and the individual DWARF sections are distinguished by their
1028 // section subtype.
1029 DwarfAbbrevSection = Ctx->getXCOFFSection(
1030 ".dwabrev", SectionKind::getMetadata(),
1031 /* CsectProperties */ std::nullopt,
1032 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWABREV);
1033
1034 DwarfInfoSection = Ctx->getXCOFFSection(
1035 ".dwinfo", SectionKind::getMetadata(), /* CsectProperties */ std::nullopt,
1036 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWINFO);
1037
1038 DwarfLineSection = Ctx->getXCOFFSection(
1039 ".dwline", SectionKind::getMetadata(), /* CsectProperties */ std::nullopt,
1040 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWLINE);
1041
1042 DwarfFrameSection = Ctx->getXCOFFSection(
1043 ".dwframe", SectionKind::getMetadata(),
1044 /* CsectProperties */ std::nullopt,
1045 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWFRAME);
1046
1047 DwarfPubNamesSection = Ctx->getXCOFFSection(
1048 ".dwpbnms", SectionKind::getMetadata(),
1049 /* CsectProperties */ std::nullopt,
1050 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWPBNMS);
1051
1052 DwarfPubTypesSection = Ctx->getXCOFFSection(
1053 ".dwpbtyp", SectionKind::getMetadata(),
1054 /* CsectProperties */ std::nullopt,
1055 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWPBTYP);
1056
1057 DwarfStrSection = Ctx->getXCOFFSection(
1058 ".dwstr", SectionKind::getMetadata(), /* CsectProperties */ std::nullopt,
1059 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWSTR);
1060
1061 DwarfLocSection = Ctx->getXCOFFSection(
1062 ".dwloc", SectionKind::getMetadata(), /* CsectProperties */ std::nullopt,
1063 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWLOC);
1064
1065 DwarfARangesSection = Ctx->getXCOFFSection(
1066 ".dwarnge", SectionKind::getMetadata(),
1067 /* CsectProperties */ std::nullopt,
1068 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWARNGE);
1069
1070 DwarfRangesSection = Ctx->getXCOFFSection(
1071 ".dwrnges", SectionKind::getMetadata(),
1072 /* CsectProperties */ std::nullopt,
1073 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWRNGES);
1074
1075 DwarfMacinfoSection = Ctx->getXCOFFSection(
1076 ".dwmac", SectionKind::getMetadata(), /* CsectProperties */ std::nullopt,
1077 /* MultiSymbolsAllowed */ true, XCOFF::SSUBTYP_DWMAC);
1078}
1079
1080void MCObjectFileInfo::initDXContainerObjectFileInfo(const Triple &T) {
1081 // At the moment the DXBC section should end up empty.
1082 TextSection = Ctx->getDXContainerSection("DXBC", SectionKind::getText());
1083}
1084
1085MCObjectFileInfo::~MCObjectFileInfo() = default;
1086
1088 bool LargeCodeModel) {
1089 PositionIndependent = PIC;
1090 Ctx = &MCCtx;
1091
1092 // Common.
1096
1098
1100
1101 EHFrameSection = nullptr; // Created on demand.
1102 SFrameSection = nullptr; // Created on demand.
1103 CompactUnwindSection = nullptr; // Used only by selected targets.
1104 DwarfAccelNamesSection = nullptr; // Used only by selected targets.
1105 DwarfAccelObjCSection = nullptr; // Used only by selected targets.
1106 DwarfAccelNamespaceSection = nullptr; // Used only by selected targets.
1107 DwarfAccelTypesSection = nullptr; // Used only by selected targets.
1108
1109 const Triple &TheTriple = Ctx->getTargetTriple();
1110 switch (Ctx->getObjectFileType()) {
1111 case MCContext::IsMachO:
1112 initMachOMCObjectFileInfo(TheTriple);
1113 break;
1114 case MCContext::IsCOFF:
1115 initCOFFMCObjectFileInfo(TheTriple);
1116 break;
1117 case MCContext::IsELF:
1118 initELFMCObjectFileInfo(TheTriple, LargeCodeModel);
1119 break;
1120 case MCContext::IsGOFF:
1121 initGOFFMCObjectFileInfo(TheTriple);
1122 break;
1123 case MCContext::IsSPIRV:
1124 initSPIRVMCObjectFileInfo(TheTriple);
1125 break;
1126 case MCContext::IsWasm:
1127 initWasmMCObjectFileInfo(TheTriple);
1128 break;
1129 case MCContext::IsXCOFF:
1130 initXCOFFMCObjectFileInfo(TheTriple);
1131 break;
1133 initDXContainerObjectFileInfo(TheTriple);
1134 break;
1135 }
1136}
1137
1138MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name,
1139 uint64_t Hash) const {
1140 switch (Ctx->getTargetTriple().getObjectFormat()) {
1141 case Triple::ELF:
1142 return Ctx->getELFSection(Name, ELF::SHT_PROGBITS, ELF::SHF_GROUP, 0,
1143 utostr(Hash), /*IsComdat=*/true);
1144 case Triple::Wasm:
1145 return Ctx->getWasmSection(Name, SectionKind::getMetadata(), 0,
1146 utostr(Hash), MCSection::NonUniqueID);
1147 case Triple::MachO:
1148 case Triple::COFF:
1149 case Triple::GOFF:
1150 case Triple::SPIRV:
1151 case Triple::XCOFF:
1152 case Triple::DXContainer:
1153 case Triple::UnknownObjectFormat:
1154 report_fatal_error("Cannot get DWARF comdat section for this object file "
1155 "format: not implemented.");
1156 break;
1157 }
1158 llvm_unreachable("Unknown ObjectFormatType");
1159}
1160
1161MCSection *
1163 if (Ctx->getObjectFileType() != MCContext::IsELF)
1164 return CallGraphSection;
1165
1166 const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec);
1167 unsigned Flags = ELF::SHF_LINK_ORDER;
1168 StringRef GroupName;
1169 if (const MCSymbol *Group = ElfSec.getGroup()) {
1170 GroupName = Group->getName();
1171 Flags |= ELF::SHF_GROUP;
1172 }
1173
1174 return Ctx->getELFSection(
1175 ".llvm.callgraph", ELF::SHT_LLVM_CALL_GRAPH, Flags, 0, GroupName,
1176 /*IsComdat=*/true, ElfSec.getUniqueID(),
1177 static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol()));
1178}
1179
1180MCSection *
1182 if ((Ctx->getObjectFileType() != MCContext::IsELF) ||
1183 Ctx->getTargetTriple().isPS4())
1184 return StackSizesSection;
1185
1186 const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec);
1187 unsigned Flags = ELF::SHF_LINK_ORDER;
1188 StringRef GroupName;
1189 if (const MCSymbol *Group = ElfSec.getGroup()) {
1190 GroupName = Group->getName();
1191 Flags |= ELF::SHF_GROUP;
1192 }
1193
1194 return Ctx->getELFSection(
1195 ".stack_sizes", ELF::SHT_PROGBITS, Flags, 0, GroupName, true,
1196 ElfSec.getUniqueID(),
1197 static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol()));
1198}
1199
1200MCSection *
1202 if (Ctx->getObjectFileType() != MCContext::IsELF)
1203 return nullptr;
1204
1205 const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec);
1206 unsigned Flags = ELF::SHF_LINK_ORDER;
1207 StringRef GroupName;
1208 if (const MCSymbol *Group = ElfSec.getGroup()) {
1209 GroupName = Group->getName();
1210 Flags |= ELF::SHF_GROUP;
1211 }
1212
1213 // Use the text section's begin symbol and unique ID to create a separate
1214 // .llvm_bb_addr_map section associated with every unique text section.
1215 return Ctx->getELFSection(
1216 ".llvm_bb_addr_map", ELF::SHT_LLVM_BB_ADDR_MAP, Flags, 0, GroupName, true,
1217 ElfSec.getUniqueID(),
1218 static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol()));
1219}
1220
1221MCSection *
1223 if (Ctx->getObjectFileType() != MCContext::IsELF)
1224 return nullptr;
1225
1226 const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec);
1227 unsigned Flags = ELF::SHF_LINK_ORDER | ELF::SHF_ALLOC;
1228 StringRef GroupName;
1229 if (const MCSymbol *Group = ElfSec.getGroup()) {
1230 GroupName = Group->getName();
1231 Flags |= ELF::SHF_GROUP;
1232 }
1233
1234 return Ctx->getELFSection(
1235 ".kcfi_traps", ELF::SHT_PROGBITS, Flags, 0, GroupName,
1236 /*IsComdat=*/true, ElfSec.getUniqueID(),
1237 static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol()));
1238}
1239
1240MCSection *
1242 auto ObjFileType = Ctx->getObjectFileType();
1243 if (ObjFileType == MCContext::IsELF) {
1244 const auto &ElfSec = static_cast<const MCSectionELF &>(TextSec);
1245 unsigned Flags = ELF::SHF_LINK_ORDER;
1246 StringRef GroupName;
1247 if (const MCSymbol *Group = ElfSec.getGroup()) {
1248 GroupName = Group->getName();
1249 Flags |= ELF::SHF_GROUP;
1250 }
1251 return Ctx->getELFSection(
1252 PseudoProbeSection->getName(), ELF::SHT_PROGBITS, Flags, 0, GroupName,
1253 true, ElfSec.getUniqueID(),
1254 static_cast<const MCSymbolELF *>(TextSec.getBeginSymbol()));
1255 } else if (ObjFileType == MCContext::IsCOFF) {
1256 StringRef COMDATSymName = "";
1257 int Selection = 0;
1258 unsigned Characteristics =
1259 static_cast<MCSectionCOFF *>(PseudoProbeSection)->getCharacteristics();
1260 const auto &COFFSec = static_cast<const MCSectionCOFF &>(TextSec);
1261 if (const MCSymbol *COMDATSym = COFFSec.getCOMDATSymbol()) {
1262 // Associate .pseudo_probe to its function section.
1263 COMDATSymName = COMDATSym->getName();
1264 Characteristics |= COFF::IMAGE_SCN_LNK_COMDAT;
1266 }
1267 return Ctx->getCOFFSection(PseudoProbeSection->getName(), Characteristics,
1268 COMDATSymName, Selection, COFFSec.getUniqueID());
1269 }
1270
1271 return PseudoProbeSection;
1272}
1273
1274MCSection *
1276 if (!Ctx->getTargetTriple().supportsCOMDAT() || FuncName.empty())
1278
1279 // Create a separate comdat group for each function's descriptor in order
1280 // for the linker to deduplicate. The duplication, must be from different
1281 // tranlation unit, can come from:
1282 // 1. Inline functions defined in header files;
1283 // 2. ThinLTO imported funcions;
1284 // 3. Weak-linkage definitions.
1285 // Use a concatenation of the section name and the function name as the
1286 // group name so that descriptor-only groups won't be folded with groups of
1287 // code.
1288 auto ObjFileType = Ctx->getObjectFileType();
1289 if (ObjFileType == MCContext::IsELF) {
1290 auto *S = static_cast<MCSectionELF *>(PseudoProbeDescSection);
1291 auto Flags = S->getFlags() | ELF::SHF_GROUP;
1292 return Ctx->getELFSection(S->getName(), S->getType(), Flags,
1293 S->getEntrySize(), S->getName() + "_" + FuncName,
1294 /*IsComdat=*/true);
1295 } else if (ObjFileType == MCContext::IsCOFF) {
1296 auto *S = static_cast<MCSectionCOFF *>(PseudoProbeDescSection);
1297 unsigned Characteristics =
1298 S->getCharacteristics() | COFF::IMAGE_SCN_LNK_COMDAT;
1299 std::string COMDATSymName = (S->getName() + "_" + FuncName).str();
1300 return Ctx->getCOFFSection(S->getName(), Characteristics, COMDATSymName,
1302 }
1303
1305}
1306
1310
1312 const MCSection *TextSec) const {
1313 if (Ctx->getObjectFileType() != MCContext::IsELF)
1314 return nullptr;
1315
1316 // SHF_WRITE for relocations, and let user post-process data in-place.
1318
1319 if (!TextSec)
1320 TextSec = getTextSection();
1321
1322 StringRef GroupName;
1323 const auto &ElfSec = static_cast<const MCSectionELF &>(*TextSec);
1324 if (const MCSymbol *Group = ElfSec.getGroup()) {
1325 GroupName = Group->getName();
1326 Flags |= ELF::SHF_GROUP;
1327 }
1328 return Ctx->getELFSection(
1329 Name, ELF::SHT_PROGBITS, Flags, 0, GroupName, true, ElfSec.getUniqueID(),
1330 static_cast<const MCSymbolELF *>(TextSec->getBeginSymbol()));
1331}
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
static bool useCompactUnwind(const Triple &T)
This file declares the MCSectionGOFF class, which contains all of the necessary machine code sections...
T
#define T
PassInstrumentationCallbacks PIC
This file contains data-structure definitions and constants to support unwinding based on ....
This file contains some functions that are useful when dealing with strings.
Context object for machine code objects.
Definition MCContext.h:83
MCSection * NonLazySymbolPointerSection
MCSection * TLSBSSSection
Section directive for Thread Local uninitialized data.
MCSection * CallGraphSection
Section containing call graph metadata.
MCSection * DwarfDebugNamesSection
Accelerator table sections.
const MCSection * TLSThreadInitSection
Section for thread local data initialization functions.
MCSection * DwarfStrOffSection
The DWARF v5 string offset and address table sections.
MCSection * DwarfARangesSection
MCSection * DwarfStrSection
MCSection * MergeableConst16Section
MCSection * COFFGlobalTypeHashesSection
MCSection * SFrameSection
SFrame section.
MCSection * DwarfLocDWOSection
MCSection * MergeableConst4Section
MCSection * DwarfMacinfoSection
MCSection * DwarfPubNamesSection
MCSection * DwarfGnuPubTypesSection
Section for newer gnu pubtypes.
MCSection * getLLVMStatsSection() const
MCSection * DwarfCUIndexSection
MCSection * TextSection
Section directive for standard text.
MCSection * ConstDataCoalSection
MCSection * ConstTextCoalSection
MCSection * TLSDataSection
Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
MCSection * MergeableConst8Section
MCSection * DwarfInfoSection
MCSection * ThreadLocalPointerSection
MCSection * LSDASection
If exception handling is supported by the target, this is the section the Language Specific Data Area...
MCSection * CompactUnwindSection
If exception handling is supported by the target and the target can support a compact representation ...
MCSection * COFFDebugSymbolsSection
MCSection * DwarfStrDWOSection
MCSection * getPseudoProbeDescSection(StringRef FuncName) const
MCSection * DwarfLoclistsSection
The DWARF v5 locations list section.
MCSection * ReadOnly16Section
MCSection * DwarfLocSection
MCSection * PseudoProbeSection
Section for pseudo probe information used by AutoFDO.
MCSection * FourByteConstantSection
MCSection * DwarfAccelNamesSection
MCSection * getStackSizesSection(const MCSection &TextSec) const
MCSection * DwarfRnglistsSection
The DWARF v5 range list section.
const MCSection * DwarfDebugInlineSection
MCSection * DwarfAbbrevDWOSection
MCSection * getBBAddrMapSection(const MCSection &TextSec) const
MCSection * COFFDebugTypesSection
MCSection * LazySymbolPointerSection
MCSection * RemarksSection
Remarks section.
MCSection * getPseudoProbeSection(const MCSection &TextSec) const
MCSection * PseudoProbeDescSection
MCSection * DwarfPubTypesSection
MCSection * DwarfRangesSection
MCSection * DwarfStrOffDWOSection
MCSection * TLSExtraDataSection
Extra TLS Variable Data section.
MCSection * EHFrameSection
EH frame section.
bool OmitDwarfIfHaveCompactUnwind
OmitDwarfIfHaveCompactUnwind - True if the target object file supports having some functions with com...
MCSection * DrectveSection
COFF specific sections.
MCSection * FaultMapSection
FaultMap section.
MCSection * getKCFITrapSection(const MCSection &TextSec) const
MCSection * DwarfAccelObjCSection
MCSection * TLSTLVSection
Section for thread local structure information.
MCSection * DwarfSwiftASTSection
MCSection * DwarfMacroSection
void initMCObjectFileInfo(MCContext &MCCtx, bool PIC, bool LargeCodeModel=false)
MCSection * DwarfFrameSection
MCSection * DwarfRnglistsDWOSection
The DWARF v5 range and location list sections for fission.
MCSection * ImportCallSection
If import call optimization is supported by the target, this is the section to emit import call data ...
MCSection * MergeableConst32Section
MCSection * SixteenByteConstantSection
virtual ~MCObjectFileInfo()
MCSection * DataCommonSection
MCSection * getPCSection(StringRef Name, const MCSection *TextSec) const
std::optional< sframe::ABI > SFrameABIArch
SFrame ABI architecture byte.
MCSection * DwarfLineStrSection
bool SupportsCompactUnwindWithoutEHFrame
True if the target object file supports emitting a compact unwind section without an associated EH fr...
MCSection * ReadOnlySection
Section that is readonly and can contain arbitrary initialized data.
MCSection * DwarfLineDWOSection
MCSection * DwarfAbbrevSection
MCSection * DwarfLineSection
unsigned FDECFIEncoding
FDE CFI encoding.
MCSection * DwarfTUIndexSection
bool SupportsWeakOmittedEHFrame
True if target object file supports a weak_definition of constant 0 for an omitted EH frame.
MCSection * DwarfLoclistsDWOSection
MCSection * getCallGraphSection(const MCSection &TextSec) const
MCSection * DwarfInfoDWOSection
MCSection * BSSSection
Section that is default initialized to zero.
MCSection * EightByteConstantSection
MCSection * StackSizesSection
Section containing metadata on function stack sizes.
unsigned CompactUnwindDwarfEHFrameOnly
Compact unwind encoding indicating that we should emit only an EH frame.
MCSection * getTextSection() const
MCSection * DwarfTypesDWOSection
MCSection * DwarfGnuPubNamesSection
Section for newer gnu pubnames.
MCSection * StackMapSection
StackMap section.
MCSection * DwarfMacroDWOSection
MCSection * DwarfMacinfoDWOSection
MCSection * DwarfAccelNamespaceSection
MCSection * DwarfAccelTypesSection
MCSection * DataSection
Section directive for standard data.
This represents a section on Windows.
Definition MCSectionCOFF.h:27
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition MCSectionELF.h:27
unsigned getFlags() const
Definition MCSectionELF.h:74
unsigned getUniqueID() const
Definition MCSectionELF.h:81
const MCSymbolELF * getGroup() const
Definition MCSectionELF.h:77
void setSymbolTableName(StringRef STN)
MCSymbolXCOFF * getQualNameSymbol() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:521
static constexpr unsigned NonUniqueID
Definition MCSection.h:526
MCSymbol * getBeginSymbol()
Definition MCSection.h:593
void setSymbolTableName(StringRef STN)
Definition MCSymbolXCOFF.h:63
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
static SectionKind getThreadData()
Definition SectionKind.h:207
static SectionKind getMetadata()
Definition SectionKind.h:188
static SectionKind getMergeable2ByteCString()
Definition SectionKind.h:196
static SectionKind getMergeableConst4()
Definition SectionKind.h:202
static SectionKind getText()
Definition SectionKind.h:190
static SectionKind getReadOnlyWithRel()
Definition SectionKind.h:214
static SectionKind getData()
Definition SectionKind.h:213
static SectionKind getMergeableConst8()
Definition SectionKind.h:203
static SectionKind getBSS()
Definition SectionKind.h:209
static SectionKind getThreadBSS()
Definition SectionKind.h:206
static SectionKind getMergeableConst16()
Definition SectionKind.h:204
static SectionKind getMergeable1ByteCString()
Definition SectionKind.h:193
static SectionKind getReadOnly()
Definition SectionKind.h:192
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:143
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
@ x86_64
Definition Triple.h:91
@ ppc64le
Definition Triple.h:75
@ hexagon
Definition Triple.h:63
@ mipsel
Definition Triple.h:68
@ aarch64_be
Definition Triple.h:55
@ bpfel
Definition Triple.h:59
@ mips64
Definition Triple.h:69
@ ppc64
Definition Triple.h:74
@ thumb
Definition Triple.h:88
@ xtensa
Definition Triple.h:93
@ bpfeb
Definition Triple.h:60
@ mips64el
Definition Triple.h:70
@ aarch64
Definition Triple.h:54
@ aarch64_32
Definition Triple.h:56
@ DXContainer
Definition Triple.h:323
@ UnknownObjectFormat
Definition Triple.h:320
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
SectionCharacteristics
Definition COFF.h:298
@ IMAGE_SCN_LNK_REMOVE
Definition COFF.h:308
@ IMAGE_SCN_CNT_CODE
Definition COFF.h:303
@ IMAGE_SCN_MEM_READ
Definition COFF.h:336
@ IMAGE_SCN_MEM_EXECUTE
Definition COFF.h:335
@ IMAGE_SCN_CNT_UNINITIALIZED_DATA
Definition COFF.h:305
@ IMAGE_SCN_MEM_DISCARDABLE
Definition COFF.h:331
@ IMAGE_SCN_LNK_INFO
Definition COFF.h:307
@ IMAGE_SCN_MEM_16BIT
Definition COFF.h:312
@ IMAGE_SCN_CNT_INITIALIZED_DATA
Definition COFF.h:304
@ IMAGE_SCN_LNK_COMDAT
Definition COFF.h:309
@ IMAGE_SCN_MEM_WRITE
Definition COFF.h:337
@ IMAGE_COMDAT_SELECT_ASSOCIATIVE
Definition COFF.h:459
@ IMAGE_COMDAT_SELECT_EXACT_MATCH
Definition COFF.h:458
@ SHF_MERGE
Definition ELF.h:1254
@ SHF_STRINGS
Definition ELF.h:1257
@ SHF_EXCLUDE
Definition ELF.h:1282
@ SHF_ALLOC
Definition ELF.h:1248
@ SHF_LINK_ORDER
Definition ELF.h:1263
@ SHF_GROUP
Definition ELF.h:1270
@ SHF_WRITE
Definition ELF.h:1245
@ SHF_TLS
Definition ELF.h:1273
@ SHF_EXECINSTR
Definition ELF.h:1251
@ SHT_PROGBITS
Definition ELF.h:1147
@ SHT_NOBITS
Definition ELF.h:1154
@ SHT_LLVM_CALL_GRAPH
Definition ELF.h:1190
@ SHT_MIPS_DWARF
Definition ELF.h:1226
@ SHT_LLVM_BB_ADDR_MAP
Definition ELF.h:1185
@ SHT_GNU_SFRAME
Definition ELF.h:1194
@ SHT_X86_64_UNWIND
Definition ELF.h:1222
@ ESD_LB_Deferred
Definition GOFF.h:129
@ ESD_LB_NoLoad
Definition GOFF.h:130
@ ESD_LB_Initial
Definition GOFF.h:128
constexpr StringLiteral CLASS_WSA
@ ESD_BA_Concatenate
Definition GOFF.h:98
@ ESD_BA_Merge
Definition GOFF.h:99
@ ESD_TS_Structured
Definition GOFF.h:93
@ ESD_TS_ByteOriented
Definition GOFF.h:92
@ ESD_EXE_DATA
Definition GOFF.h:111
@ ESD_RQ_1
Definition GOFF.h:70
@ ESD_RQ_0
Definition GOFF.h:69
@ ESD_ALIGN_Doubleword
Definition GOFF.h:148
@ ESD_ALIGN_Quadword
Definition GOFF.h:149
constexpr StringLiteral CLASS_PPA2
@ ESD_BSC_Section
Definition GOFF.h:136
@ ESD_LT_OS
Definition GOFF.h:142
@ ESD_LT_XPLink
Definition GOFF.h:142
@ ESD_NS_Parts
Definition GOFF.h:65
@ ESD_NS_NormalName
Definition GOFF.h:63
@ ESD_TA_Rent
Definition GOFF.h:106
constexpr StringLiteral CLASS_CODE
@ ESD_RMODE_64
Definition GOFF.h:88
@ S_THREAD_LOCAL_VARIABLE_POINTERS
S_THREAD_LOCAL_VARIABLE_POINTERS - Section with pointers to thread local structures.
Definition MachO.h:175
@ S_16BYTE_LITERALS
S_16BYTE_LITERALS - Section with only 16 byte literals.
Definition MachO.h:160
@ S_THREAD_LOCAL_INIT_FUNCTION_POINTERS
S_THREAD_LOCAL_INIT_FUNCTION_POINTERS - Section with thread local variable initialization pointers to...
Definition MachO.h:178
@ S_COALESCED
S_COALESCED - Section contains symbols that are to be coalesced.
Definition MachO.h:152
@ S_THREAD_LOCAL_ZEROFILL
S_THREAD_LOCAL_ZEROFILL - Thread local zerofill section.
Definition MachO.h:169
@ S_LAZY_SYMBOL_POINTERS
S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers.
Definition MachO.h:141
@ S_CSTRING_LITERALS
S_CSTRING_LITERALS - Section with literal C strings.
Definition MachO.h:131
@ S_THREAD_LOCAL_REGULAR
S_THREAD_LOCAL_REGULAR - Thread local data section.
Definition MachO.h:167
@ S_ZEROFILL
S_ZEROFILL - Zero fill on demand section.
Definition MachO.h:129
@ S_NON_LAZY_SYMBOL_POINTERS
S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
Definition MachO.h:139
@ S_4BYTE_LITERALS
S_4BYTE_LITERALS - Section with 4 byte literals.
Definition MachO.h:133
@ S_8BYTE_LITERALS
S_8BYTE_LITERALS - Section with 8 byte literals.
Definition MachO.h:135
@ S_THREAD_LOCAL_VARIABLES
S_THREAD_LOCAL_VARIABLES - Section with thread local variable structure data.
Definition MachO.h:172
@ S_ATTR_DEBUG
S_ATTR_DEBUG - A debug section.
Definition MachO.h:207
@ S_ATTR_NO_TOC
S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be in a ranlib table of contents.
Definition MachO.h:195
@ S_ATTR_LIVE_SUPPORT
S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks.
Definition MachO.h:202
@ S_ATTR_PURE_INSTRUCTIONS
S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine instructions.
Definition MachO.h:192
@ S_ATTR_STRIP_STATIC_SYMS
S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section in files with the MY_DYLDLINK f...
Definition MachO.h:198
@ SSUBTYP_DWARNGE
DWARF aranges section.
Definition XCOFF.h:160
@ SSUBTYP_DWFRAME
DWARF frame section.
Definition XCOFF.h:165
@ SSUBTYP_DWABREV
DWARF abbrev section.
Definition XCOFF.h:161
@ SSUBTYP_DWINFO
DWARF info section.
Definition XCOFF.h:156
@ SSUBTYP_DWRNGES
DWARF ranges section.
Definition XCOFF.h:163
@ SSUBTYP_DWLOC
DWARF loc section.
Definition XCOFF.h:164
@ SSUBTYP_DWMAC
DWARF macinfo section.
Definition XCOFF.h:166
@ SSUBTYP_DWPBNMS
DWARF pubnames section.
Definition XCOFF.h:158
@ SSUBTYP_DWPBTYP
DWARF pubtypes section.
Definition XCOFF.h:159
@ SSUBTYP_DWLINE
DWARF line section.
Definition XCOFF.h:157
@ SSUBTYP_DWSTR
DWARF str section.
Definition XCOFF.h:162
@ XMC_TC0
TOC Anchor for TOC Addressability.
Definition XCOFF.h:119
@ XMC_RW
Read Write Data.
Definition XCOFF.h:118
@ XMC_TL
Initialized thread-local variable.
Definition XCOFF.h:127
@ XMC_RO
Read Only Constant.
Definition XCOFF.h:107
@ XMC_PR
Program Code.
Definition XCOFF.h:106
@ XTY_SD
Csect definition for initialized storage.
Definition XCOFF.h:243
@ DW_EH_PE_pcrel
Definition Dwarf.h:879
@ DW_EH_PE_sdata4
Definition Dwarf.h:876
@ DW_EH_PE_sdata8
Definition Dwarf.h:877
@ DW_EH_PE_absptr
Definition Dwarf.h:868
@ WASM_SEG_FLAG_STRINGS
Definition Wasm.h:229
This is an optimization pass for GlobalISel generic memory operations.
Definition AddressRanges.h:18
std::string utostr(uint64_t X, bool isNeg=false)
Definition StringExtras.h:322
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:167

Generated on for LLVM by doxygen 1.14.0

AltStyle によって変換されたページ (->オリジナル) /