LLVM 19.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.
234
235 // XCOFF specific sections
239
240 // Swift5 Reflection Data Sections
241 std::array<MCSection *, binaryformat::Swift5ReflectionSectionKind::last>
243
244public:
245 void initMCObjectFileInfo(MCContext &MCCtx, bool PIC,
246 bool LargeCodeModel = false);
248 MCContext &getContext() const { return *Ctx; }
249
252 }
255 }
258 }
259
260 unsigned getFDEEncoding() const { return FDECFIEncoding; }
261
264 }
265
266 virtual unsigned getTextSectionAlignment() const { return 4; }
269 MCSection *getBSSSection() const { return BSSSection; }
276 return getDwarfComdatSection(".debug_info", Hash);
277 }
285 }
288 }
291 }
300
303 }
306 }
310 }
313 }
316 return getDwarfComdatSection(".debug_types", Hash);
317 }
328 }
331 }
335 }
339
342 }
345 }
348 }
349
351 const MCSection *getTLSDataSection() const { return TLSDataSection; }
353
357
358 MCSection *getStackSizesSection(const MCSection &TextSec) const;
359
360 MCSection *getBBAddrMapSection(const MCSection &TextSec) const;
361
362 MCSection *getKCFITrapSection(const MCSection &TextSec) const;
363
364 MCSection *getPseudoProbeSection(const MCSection &TextSec) const;
365
367
369
370 MCSection *getPCSection(StringRef Name, const MCSection *TextSec) const;
371
372 // ELF specific sections.
376 }
379 }
382 }
385 }
386
387 // MachO specific sections.
388 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
391 }
392 const MCSection *getCStringSection() const { return CStringSection; }
393 const MCSection *getUStringSection() const { return UStringSection; }
397 }
402 }
407 }
410 }
413 }
416 }
419 }
422 }
424
425 // COFF specific sections.
434
435 // GOFF specific sections.
439 MCSection *getADASection() const { return ADASection; }
441
442 // XCOFF specific sections
444
446
447 bool isPositionIndependent() const { return PositionIndependent; }
448
449 // Swift5 Reflection Data Sections
452 return ReflSectionKind !=
454 ? Swift5ReflectionSections[ReflSectionKind]
455 : nullptr;
456 }
457
458private:
459 bool PositionIndependent = false;
460 MCContext *Ctx = nullptr;
461 VersionTuple SDKVersion;
462 std::optional<Triple> DarwinTargetVariantTriple;
463 VersionTuple DarwinTargetVariantSDKVersion;
464
465 void initMachOMCObjectFileInfo(const Triple &T);
466 void initELFMCObjectFileInfo(const Triple &T, bool Large);
467 void initGOFFMCObjectFileInfo(const Triple &T);
468 void initCOFFMCObjectFileInfo(const Triple &T);
469 void initSPIRVMCObjectFileInfo(const Triple &T);
470 void initWasmMCObjectFileInfo(const Triple &T);
471 void initXCOFFMCObjectFileInfo(const Triple &T);
472 void initDXContainerObjectFileInfo(const Triple &T);
473 MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
474
475public:
476 void setSDKVersion(const VersionTuple &TheSDKVersion) {
477 SDKVersion = TheSDKVersion;
478 }
479
480 const VersionTuple &getSDKVersion() const { return SDKVersion; }
481
483 DarwinTargetVariantTriple = T;
484 }
485
487 return DarwinTargetVariantTriple ? &*DarwinTargetVariantTriple : nullptr;
488 }
489
491 DarwinTargetVariantSDKVersion = TheSDKVersion;
492 }
493
495 return DarwinTargetVariantSDKVersion;
496 }
497};
498
499} // end namespace llvm
500
501#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 * getPPA2ListSection() const
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