LLVM 18.0.0git
MCObjectFileInfo.h
Go to the documentation of this file.
1//===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===//
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// This file describes common object file formats.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_MC_MCOBJECTFILEINFO_H
14#define LLVM_MC_MCOBJECTFILEINFO_H
15
17#include "llvm/MC/MCSection.h"
20
21#include <array>
22#include <optional>
23
24namespace llvm {
25class MCContext;
26class MCSection;
27
29protected:
30 /// True if target object file supports a weak_definition of constant 0 for an
31 /// omitted EH frame.
33
34 /// True if the target object file supports emitting a compact unwind section
35 /// without an associated EH frame section.
37
38 /// OmitDwarfIfHaveCompactUnwind - True if the target object file
39 /// supports having some functions with compact unwind and other with
40 /// dwarf unwind.
42
43 /// FDE CFI encoding. Controls the encoding of the begin label in the
44 /// .eh_frame section. Unlike the LSDA encoding, personality encoding, and
45 /// type encodings, this is something that the assembler just "knows" about
46 /// its target
47 unsigned FDECFIEncoding = 0;
48
49 /// Compact unwind encoding indicating that we should emit only an EH frame.
51
52 /// Section directive for standard text.
54
55 /// Section directive for standard data.
57
58 /// Section that is default initialized to zero.
60
61 /// Section that is readonly and can contain arbitrary initialized data.
62 /// Targets are not required to have a readonly section. If they don't,
63 /// various bits of code will fall back to using the data section for
64 /// constants.
66
67 /// If exception handling is supported by the target, this is the section the
68 /// Language Specific Data Area information is emitted to.
70
71 /// If exception handling is supported by the target and the target can
72 /// support a compact representation of the CIE and FDE, this is the section
73 /// to emit them into.
75
76 // Dwarf sections for debug info. If a target supports debug info, these must
77 // be set.
91 // The pubnames section is no longer generated by default. The generation
92 // can be enabled by a compiler flag.
94
95 /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
96 /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
97 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
98 /// extensions.
104
105 // These are used for the Fission separate debug information files.
115
116 /// The DWARF v5 string offset and address table sections.
119 /// The DWARF v5 range list section.
121 /// The DWARF v5 locations list section.
123
124 /// The DWARF v5 range and location list sections for fission.
127
128 // These are for Fission DWP files.
131
132 /// Section for newer gnu pubnames.
134 /// Section for newer gnu pubtypes.
136
137 // Section for Swift AST
139
143
144 /// Extra TLS Variable Data section.
145 ///
146 /// If the target needs to put additional information for a TLS variable,
147 /// it'll go here.
149
150 /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
151 MCSection *TLSDataSection = nullptr; // Defaults to ".tdata".
152
153 /// Section directive for Thread Local uninitialized data.
154 ///
155 /// Null if this target doesn't support a BSS section. ELF and MachO only.
156 MCSection *TLSBSSSection = nullptr; // Defaults to ".tbss".
157
158 /// StackMap section.
160
161 /// FaultMap section.
163
164 /// Remarks section.
166
167 /// EH frame section.
168 ///
169 /// It is initialized on demand so it can be overwritten (with uniquing).
171
172 /// Section containing metadata on function stack sizes.
174
175 /// Section for pseudo probe information used by AutoFDO
178
179 // Section for metadata of llvm statistics.
181
182 // ELF specific sections.
188
189 // MachO specific sections.
190
191 /// Section for thread local structure information.
192 ///
193 /// Contains the source code name of the variable, visibility and a pointer to
194 /// the initial value (.tdata or .tbss).
195 MCSection *TLSTLVSection = nullptr; // Defaults to ".tlv".
196
197 /// Section for thread local data initialization functions.
198 // Defaults to ".thread_init_func".
200
217
218 /// COFF specific sections.
227
228 // GOFF specific sections.
233
234 // XCOFF specific sections
238
239 // Swift5 Reflection Data Sections
240 std::array<MCSection *, binaryformat::Swift5ReflectionSectionKind::last>
242
243public:
244 void initMCObjectFileInfo(MCContext &MCCtx, bool PIC,
245 bool LargeCodeModel = false);
247 MCContext &getContext() const { return *Ctx; }
248
251 }
254 }
257 }
258
259 unsigned getFDEEncoding() const { return FDECFIEncoding; }
260
263 }
264
265 virtual unsigned getTextSectionAlignment() const { return 4; }
268 MCSection *getBSSSection() const { return BSSSection; }
275 return getDwarfComdatSection(".debug_info", Hash);
276 }
284 }
287 }
290 }
299
302 }
305 }
309 }
312 }
315 return getDwarfComdatSection(".debug_types", Hash);
316 }
327 }
330 }
334 }
338
341 }
344 }
347 }
348
350 const MCSection *getTLSDataSection() const { return TLSDataSection; }
352
356
357 MCSection *getStackSizesSection(const MCSection &TextSec) const;
358
359 MCSection *getBBAddrMapSection(const MCSection &TextSec) const;
360
361 MCSection *getKCFITrapSection(const MCSection &TextSec) const;
362
363 MCSection *getPseudoProbeSection(const MCSection &TextSec) const;
364
366
368
369 MCSection *getPCSection(StringRef Name, const MCSection *TextSec) const;
370
371 // ELF specific sections.
375 }
378 }
381 }
384 }
385
386 // MachO specific sections.
387 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
390 }
391 const MCSection *getCStringSection() const { return CStringSection; }
392 const MCSection *getUStringSection() const { return UStringSection; }
396 }
401 }
406 }
409 }
412 }
415 }
418 }
421 }
423
424 // COFF specific sections.
433
434 // GOFF specific sections.
437 MCSection *getADASection() const { return ADASection; }
439
440 // XCOFF specific sections
442
444
445 bool isPositionIndependent() const { return PositionIndependent; }
446
447 // Swift5 Reflection Data Sections
450 return ReflSectionKind !=
452 ? Swift5ReflectionSections[ReflSectionKind]
453 : nullptr;
454 }
455
456private:
457 bool PositionIndependent = false;
458 MCContext *Ctx = nullptr;
459 VersionTuple SDKVersion;
460 std::optional<Triple> DarwinTargetVariantTriple;
461 VersionTuple DarwinTargetVariantSDKVersion;
462
463 void initMachOMCObjectFileInfo(const Triple &T);
464 void initELFMCObjectFileInfo(const Triple &T, bool Large);
465 void initGOFFMCObjectFileInfo(const Triple &T);
466 void initCOFFMCObjectFileInfo(const Triple &T);
467 void initSPIRVMCObjectFileInfo(const Triple &T);
468 void initWasmMCObjectFileInfo(const Triple &T);
469 void initXCOFFMCObjectFileInfo(const Triple &T);
470 void initDXContainerObjectFileInfo(const Triple &T);
471 MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
472
473public:
474 void setSDKVersion(const VersionTuple &TheSDKVersion) {
475 SDKVersion = TheSDKVersion;
476 }
477
478 const VersionTuple &getSDKVersion() const { return SDKVersion; }
479
481 DarwinTargetVariantTriple = T;
482 }
483
485 return DarwinTargetVariantTriple ? &*DarwinTargetVariantTriple : nullptr;
486 }
487
489 DarwinTargetVariantSDKVersion = TheSDKVersion;
490 }
491
493 return DarwinTargetVariantSDKVersion;
494 }
495};
496
497} // end namespace llvm
498
499#endif
std::string Name
#define T
PassInstrumentationCallbacks PIC
Defines the llvm::VersionTuple class, which represents a version in the form major[....
Context object for machine code objects.
Definition: MCContext.h:76
MCSection * getTLSBSSSection() const
MCSection * getDataRelROSection() const
MCSection * NonLazySymbolPointerSection
const VersionTuple & getDarwinTargetVariantSDKVersion() const
MCSection * TLSBSSSection
Section directive for Thread Local uninitialized data.
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 * getDwarfLoclistsSection() const
MCSection * DwarfARangesSection
MCSection * getDwarfAccelTypesSection() const
MCSection * MergeableConst16Section
const MCSection * getMergeableConst4Section() const
MCSection * COFFGlobalTypeHashesSection
const MCSection * getMergeableConst16Section() const
const MCSection * getMergeableConst32Section() const
MCSection * MergeableConst4Section
MCSection * DwarfMacinfoSection
MCSection * DwarfPubNamesSection
MCSection * DwarfGnuPubTypesSection
Section for newer gnu pubtypes.
MCSection * getLLVMStatsSection() const
MCSection * TextSection
Section directive for standard text.
MCSection * getDwarfGnuPubNamesSection() const
MCSection * ConstDataCoalSection
MCSection * getDwarfStrOffDWOSection() const
MCSection * ConstTextCoalSection
MCSection * getAddrSigSection() const
MCSection * TLSDataSection
Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
const MCSection * getTLSTLVSection() const
MCSection * MergeableConst8Section
MCSection * getEHFrameSection() const
MCSection * getDwarfRangesSection() const
MCSection * getADASection() const
MCSection * getPDataSection() const
MCSection * ThreadLocalPointerSection
MCSection * getDwarfInfoSection(uint64_t Hash) const
MCSection * getDwarfAccelNamespaceSection() const
MCSection * LSDASection
If exception handling is supported by the target, this is the section the Language Specific Data Area...
MCSection * getFaultMapSection() const
MCSection * CompactUnwindSection
If exception handling is supported by the target and the target can support a compact representation ...
MCSection * getDwarfLineDWOSection() const
bool getSupportsWeakOmittedEHFrame() const
MCSection * COFFDebugSymbolsSection
MCSection * getDwarfStrOffSection() const
MCSection * getDwarfInfoDWOSection() const
const MCSection * getConstTextCoalSection() const
MCSection * getGEHContSection() const
MCSection * getPseudoProbeDescSection(StringRef FuncName) const
std::array< MCSection *, binaryformat::Swift5ReflectionSectionKind::last > Swift5ReflectionSections
MCSection * getDwarfTypesDWOSection() const
MCSection * DwarfLoclistsSection
The DWARF v5 locations list section.
MCSection * getDwarfPubNamesSection() const
bool getSupportsCompactUnwindWithoutEHFrame() const
MCSection * getDwarfMacroSection() const
MCSection * getSXDataSection() const
MCSection * getTextCoalSection() const
MCSection * PseudoProbeSection
Section for pseudo probe information used by AutoFDO.
MCSection * getDwarfStrSection() const
void setDarwinTargetVariantSDKVersion(const VersionTuple &TheSDKVersion)
MCSection * getDwarfLineStrSection() const
unsigned getCompactUnwindDwarfEHFrameOnly() const
MCSection * FourByteConstantSection
MCSection * DwarfAccelNamesSection
MCSection * getGFIDsSection() const
MCSection * getStackSizesSection(const MCSection &TextSec) const
MCSection * getDwarfLoclistsDWOSection() const
const MCSection * getConstDataSection() const
const MCSection * getDataCoalSection() const
MCSection * DwarfRnglistsSection
The DWARF v5 range list section.
const MCSection * DwarfDebugInlineSection
MCSection * getBSSSection() const
MCSection * DwarfAbbrevDWOSection
MCSection * getBBAddrMapSection(const MCSection &TextSec) const
MCSection * COFFDebugTypesSection
MCSection * getDwarfTUIndexSection() const
MCSection * getDwarfDebugNamesSection() const
MCSection * getRemarksSection() const
const MCSection * getConstDataCoalSection() const
MCSection * getDwarfMacinfoDWOSection() const
MCSection * LazySymbolPointerSection
MCSection * getDrectveSection() const
MCSection * getSwift5ReflectionSection(llvm::binaryformat::Swift5ReflectionSectionKind ReflSectionKind)
MCSection * RemarksSection
Remarks section.
MCSection * getLazySymbolPointerSection() const
MCSection * getDwarfRnglistsSection() const
MCSection * getPseudoProbeSection(const MCSection &TextSec) const
MCSection * getDwarfAddrSection() const
MCSection * PseudoProbeDescSection
MCSection * DwarfPubTypesSection
MCSection * DwarfRangesSection
MCSection * DwarfStrOffDWOSection
MCSection * TLSExtraDataSection
Extra TLS Variable Data section.
MCSection * getDwarfLineSection() const
MCSection * getDwarfInfoSection() const
MCSection * getDwarfFrameSection() const
MCSection * getTLSExtraDataSection() const
const MCSection * getEightByteConstantSection() const
MCSection * EHFrameSection
EH frame section.
bool OmitDwarfIfHaveCompactUnwind
OmitDwarfIfHaveCompactUnwind - True if the target object file supports having some functions with com...
const MCSection * getTLSThreadInitSection() const
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 * getLSDASection() const
const Triple * getDarwinTargetVariantTriple() const
void setDarwinTargetVariantTriple(const Triple &T)
MCSection * DwarfSwiftASTSection
MCSection * getDwarfPubTypesSection() const
bool isPositionIndependent() const
unsigned getFDEEncoding() const
const MCSection * getDwarfDebugInlineSection() const
void initMCObjectFileInfo(MCContext &MCCtx, bool PIC, bool LargeCodeModel=false)
MCSection * getDwarfTypesSection(uint64_t Hash) const
MCSection * getDwarfGnuPubTypesSection() const
MCSection * getPPA1Section() const
void setSDKVersion(const VersionTuple &TheSDKVersion)
const MCSection * getMergeableConst8Section() const
MCSection * DwarfRnglistsDWOSection
The DWARF v5 range and location list sections for fission.
MCSection * getDwarfStrDWOSection() const
MCSection * MergeableConst32Section
MCSection * SixteenByteConstantSection
MCSection * getStackMapSection() const
MCSection * getDwarfAccelNamesSection() const
const VersionTuple & getSDKVersion() const
MCSection * getReadOnlySection() const
MCSection * getThreadLocalPointerSection() const
MCSection * getPCSection(StringRef Name, const MCSection *TextSec) const
MCSection * getDwarfAbbrevDWOSection() const
MCSection * getDwarfRnglistsDWOSection() const
const MCSection * getFourByteConstantSection() const
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 * getDwarfAbbrevSection() const
MCSection * getDwarfSwiftASTSection() const
MCSection * getIDRLSection() const
MCSection * getCOFFDebugSymbolsSection() const
MCSection * DwarfAbbrevSection
MCSection * getXDataSection() const
bool getOmitDwarfIfHaveCompactUnwind() const
MCSection * getGLJMPSection() const
MCSection * getTOCBaseSection() const
const MCSection * getCStringSection() const
const MCSection * getTLSDataSection() const
unsigned FDECFIEncoding
FDE CFI encoding.
MCSection * getCOFFDebugTypesSection() const
MCSection * getGIATsSection() const
MCSection * getDwarfCUIndexSection() const
bool SupportsWeakOmittedEHFrame
True if target object file supports a weak_definition of constant 0 for an omitted EH frame.
MCSection * getDwarfMacinfoSection() const
MCSection * getDwarfLocDWOSection() const
MCSection * DwarfLoclistsDWOSection
MCSection * getDwarfARangesSection() const
MCSection * getDwarfAccelObjCSection() const
MCSection * BSSSection
Section that is default initialized to zero.
MCSection * getNonLazySymbolPointerSection() const
const MCSection * getSixteenByteConstantSection() const
MCSection * getDwarfLocSection() const
virtual unsigned getTextSectionAlignment() const
MCSection * getDataBSSSection() const
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.
const MCSection * getDataCommonSection() const
MCSection * getTextSection() const
MCSection * DwarfTypesDWOSection
MCSection * getCOFFGlobalTypeHashesSection() const
MCSection * DwarfGnuPubNamesSection
Section for newer gnu pubnames.
MCSection * StackMapSection
StackMap section.
const MCSection * getUStringSection() const
MCSection * DwarfMacroDWOSection
MCSection * getDwarfMacroDWOSection() const
MCSection * DwarfMacinfoDWOSection
MCContext & getContext() const
MCSection * getPPA2Section() const
MCSection * DwarfAccelNamespaceSection
MCSection * getDataSection() const
MCSection * DwarfAccelTypesSection
MCSection * getCompactUnwindSection() const
MCSection * DataSection
Section directive for standard data.
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
Swift5ReflectionSectionKind
Definition: Swift.h:14
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18