LLVM 17.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
16#include "llvm/ADT/Triple.h"
18#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.
230
231 // XCOFF specific sections
235
236 // Swift5 Reflection Data Sections
237 std::array<MCSection *, binaryformat::Swift5ReflectionSectionKind::last>
239
240public:
241 void initMCObjectFileInfo(MCContext &MCCtx, bool PIC,
242 bool LargeCodeModel = false);
244 MCContext &getContext() const { return *Ctx; }
245
248 }
251 }
254 }
255
256 unsigned getFDEEncoding() const { return FDECFIEncoding; }
257
260 }
261
262 virtual unsigned getTextSectionAlignment() const { return 4; }
265 MCSection *getBSSSection() const { return BSSSection; }
272 return getDwarfComdatSection(".debug_info", Hash);
273 }
281 }
284 }
287 }
296
299 }
302 }
306 }
309 }
312 return getDwarfComdatSection(".debug_types", Hash);
313 }
324 }
327 }
331 }
335
338 }
341 }
344 }
345
347 const MCSection *getTLSDataSection() const { return TLSDataSection; }
349
353
354 MCSection *getStackSizesSection(const MCSection &TextSec) const;
355
356 MCSection *getBBAddrMapSection(const MCSection &TextSec) const;
357
358 MCSection *getKCFITrapSection(const MCSection &TextSec) const;
359
360 MCSection *getPseudoProbeSection(const MCSection &TextSec) const;
361
363
365
366 MCSection *getPCSection(StringRef Name, const MCSection *TextSec) const;
367
368 // ELF specific sections.
372 }
375 }
378 }
381 }
382
383 // MachO specific sections.
384 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
387 }
388 const MCSection *getCStringSection() const { return CStringSection; }
389 const MCSection *getUStringSection() const { return UStringSection; }
393 }
398 }
403 }
406 }
409 }
412 }
415 }
418 }
420
421 // COFF specific sections.
430
431 // GOFF specific sections.
433
434 // XCOFF specific sections
436
438
439 bool isPositionIndependent() const { return PositionIndependent; }
440
441 // Swift5 Reflection Data Sections
444 return ReflSectionKind !=
446 ? Swift5ReflectionSections[ReflSectionKind]
447 : nullptr;
448 }
449
450private:
451 bool PositionIndependent = false;
452 MCContext *Ctx = nullptr;
453 VersionTuple SDKVersion;
454 std::optional<Triple> DarwinTargetVariantTriple;
455 VersionTuple DarwinTargetVariantSDKVersion;
456
457 void initMachOMCObjectFileInfo(const Triple &T);
458 void initELFMCObjectFileInfo(const Triple &T, bool Large);
459 void initGOFFMCObjectFileInfo(const Triple &T);
460 void initCOFFMCObjectFileInfo(const Triple &T);
461 void initSPIRVMCObjectFileInfo(const Triple &T);
462 void initWasmMCObjectFileInfo(const Triple &T);
463 void initXCOFFMCObjectFileInfo(const Triple &T);
464 void initDXContainerObjectFileInfo(const Triple &T);
465 MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
466
467public:
468 void setSDKVersion(const VersionTuple &TheSDKVersion) {
469 SDKVersion = TheSDKVersion;
470 }
471
472 const VersionTuple &getSDKVersion() const { return SDKVersion; }
473
475 DarwinTargetVariantTriple = T;
476 }
477
479 return DarwinTargetVariantTriple ? &*DarwinTargetVariantTriple : nullptr;
480 }
481
483 DarwinTargetVariantSDKVersion = TheSDKVersion;
484 }
485
487 return DarwinTargetVariantSDKVersion;
488 }
489};
490
491} // end namespace llvm
492
493#endif
This header is deprecated in favour of llvm/TargetParser/Triple.h.
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 * 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 * 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 * 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:31
Swift5ReflectionSectionKind
Definition: Swift.h:14
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18