LLVM 22.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
18#include "llvm/MC/MCSection.h"
22
23#include <array>
24#include <optional>
25
26namespace llvm {
27class MCContext;
28class MCSection;
29
31protected:
32 /// True if target object file supports a weak_definition of constant 0 for an
33 /// omitted EH frame.
35
36 /// True if the target object file supports emitting a compact unwind section
37 /// without an associated EH frame section.
39
40 /// OmitDwarfIfHaveCompactUnwind - True if the target object file
41 /// supports having some functions with compact unwind and other with
42 /// dwarf unwind.
44
45 /// FDE CFI encoding. Controls the encoding of the begin label in the
46 /// .eh_frame section. Unlike the LSDA encoding, personality encoding, and
47 /// type encodings, this is something that the assembler just "knows" about
48 /// its target
49 unsigned FDECFIEncoding = 0;
50
51 /// Compact unwind encoding indicating that we should emit only an EH frame.
53
54 /// SFrame ABI architecture byte.
55 std::optional<sframe::ABI> SFrameABIArch = {};
56
57 /// Section directive for standard text.
59
60 /// Section directive for standard data.
62
63 /// Section that is default initialized to zero.
65
66 /// Section that is readonly and can contain arbitrary initialized data.
67 /// Targets are not required to have a readonly section. If they don't,
68 /// various bits of code will fall back to using the data section for
69 /// constants.
71
72 /// If exception handling is supported by the target, this is the section the
73 /// Language Specific Data Area information is emitted to.
75
76 /// Section containing call graph metadata.
78
79 /// If exception handling is supported by the target and the target can
80 /// support a compact representation of the CIE and FDE, this is the section
81 /// to emit them into.
83
84 /// If import call optimization is supported by the target, this is the
85 /// section to emit import call data to.
87
88 // Dwarf sections for debug info. If a target supports debug info, these must
89 // be set.
103 // The pubnames section is no longer generated by default. The generation
104 // can be enabled by a compiler flag.
106
107 /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
108 /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
109 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
110 /// extensions.
116
117 // These are used for the Fission separate debug information files.
127
128 /// The DWARF v5 string offset and address table sections.
131 /// The DWARF v5 range list section.
133 /// The DWARF v5 locations list section.
135
136 /// The DWARF v5 range and location list sections for fission.
139
140 // These are for Fission DWP files.
143
144 /// Section for newer gnu pubnames.
146 /// Section for newer gnu pubtypes.
148
149 // Section for Swift AST
151
155
156 /// Extra TLS Variable Data section.
157 ///
158 /// If the target needs to put additional information for a TLS variable,
159 /// it'll go here.
161
162 /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
163 MCSection *TLSDataSection = nullptr; // Defaults to ".tdata".
164
165 /// Section directive for Thread Local uninitialized data.
166 ///
167 /// Null if this target doesn't support a BSS section. ELF and MachO only.
168 MCSection *TLSBSSSection = nullptr; // Defaults to ".tbss".
169
170 /// StackMap section.
172
173 /// FaultMap section.
175
176 /// Remarks section.
178
179 /// EH frame section.
180 ///
181 /// It is initialized on demand so it can be overwritten (with uniquing).
183
184 /// SFrame section.
186
187 /// Section containing metadata on function stack sizes.
189
190 /// Section for pseudo probe information used by AutoFDO
193
194 // Section for metadata of llvm statistics.
196
197 // ELF specific sections.
203
204 // MachO specific sections.
205
206 /// Section for thread local structure information.
207 ///
208 /// Contains the source code name of the variable, visibility and a pointer to
209 /// the initial value (.tdata or .tbss).
210 MCSection *TLSTLVSection = nullptr; // Defaults to ".tlv".
211
212 /// Section for thread local data initialization functions.
213 // Defaults to ".thread_init_func".
215
232
233 /// COFF specific sections.
242
243 // GOFF specific sections.
247
248 // XCOFF specific sections
252
253 // Swift5 Reflection Data Sections
254 std::array<MCSection *, binaryformat::Swift5ReflectionSectionKind::last>
256
257public:
258 void initMCObjectFileInfo(MCContext &MCCtx, bool PIC,
259 bool LargeCodeModel = false);
261 MCContext &getContext() const { return *Ctx; }
262
272
273 unsigned getFDEEncoding() const { return FDECFIEncoding; }
274
278
279 std::optional<sframe::ABI> getSFrameABIArch() const { return SFrameABIArch; }
280 virtual unsigned getTextSectionAlignment() const { return 4; }
283 MCSection *getBSSSection() const { return BSSSection; }
291 return getDwarfComdatSection(".debug_info", Hash);
292 }
315
331 return getDwarfComdatSection(".debug_types", Hash);
332 }
354
364
366 const MCSection *getTLSDataSection() const { return TLSDataSection; }
368
372
373 MCSection *getCallGraphSection(const MCSection &TextSec) const;
374
375 MCSection *getStackSizesSection(const MCSection &TextSec) const;
376
377 MCSection *getBBAddrMapSection(const MCSection &TextSec) const;
378
379 MCSection *getKCFITrapSection(const MCSection &TextSec) const;
380
381 MCSection *getPseudoProbeSection(const MCSection &TextSec) const;
382
383 MCSection *getPseudoProbeDescSection(StringRef FuncName) const;
384
385 MCSection *getLLVMStatsSection() const;
386
387 MCSection *getPCSection(StringRef Name, const MCSection *TextSec) const;
388
389 // ELF specific sections.
403
404 // MachO specific sections.
405 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
408 }
409 const MCSection *getCStringSection() const { return CStringSection; }
410 const MCSection *getUStringSection() const { return UStringSection; }
414 }
419 }
441
442 // COFF specific sections.
451
452 // GOFF specific sections.
454 MCSection *getADASection() const { return ADASection; }
456
457 // XCOFF specific sections
459
462
463 bool isPositionIndependent() const { return PositionIndependent; }
464
465 // Swift5 Reflection Data Sections
473
474private:
475 bool PositionIndependent = false;
476 MCContext *Ctx = nullptr;
477
478 void initMachOMCObjectFileInfo(const Triple &T);
479 void initELFMCObjectFileInfo(const Triple &T, bool Large);
480 void initGOFFMCObjectFileInfo(const Triple &T);
481 void initCOFFMCObjectFileInfo(const Triple &T);
482 void initSPIRVMCObjectFileInfo(const Triple &T);
483 void initWasmMCObjectFileInfo(const Triple &T);
484 void initXCOFFMCObjectFileInfo(const Triple &T);
485 void initDXContainerObjectFileInfo(const Triple &T);
486 MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
487};
488
489} // end namespace llvm
490
491#endif
#define LLVM_ABI
Definition Compiler.h:213
#define T
PassInstrumentationCallbacks PIC
This file contains data-structure definitions and constants to support unwinding based on ....
Defines the llvm::VersionTuple class, which represents a version in the form major[....
Context object for machine code objects.
Definition MCContext.h:83
MCSection * getTLSBSSSection() const
MCSection * getDataRelROSection() const
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 * getDwarfLoclistsSection() const
MCSection * getDwarfAccelTypesSection() const
MCSection * MergeableConst16Section
const MCSection * getMergeableConst4Section() const
MCSection * COFFGlobalTypeHashesSection
const MCSection * getMergeableConst16Section() const
MCSection * SFrameSection
SFrame section.
const MCSection * getMergeableConst32Section() const
MCSection * DwarfGnuPubTypesSection
Section for newer gnu pubtypes.
MCSection * TextSection
Section directive for standard text.
MCSection * getDwarfGnuPubNamesSection() const
MCSection * getDwarfStrOffDWOSection() const
MCSection * getAddrSigSection() const
MCSection * TLSDataSection
Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
const MCSection * getTLSTLVSection() const
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
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
MCSection * getDwarfLineStrSection() const
unsigned getCompactUnwindDwarfEHFrameOnly() const
MCSection * FourByteConstantSection
MCSection * getGFIDsSection() 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 * 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 * getDwarfAddrSection() const
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 * TLSTLVSection
Section for thread local structure information.
MCSection * getLSDASection() const
MCSection * getDwarfPubTypesSection() const
bool isPositionIndependent() const
unsigned getFDEEncoding() const
const MCSection * getDwarfDebugInlineSection() const
MCSection * getDwarfTypesSection(uint64_t Hash) const
MCSection * getDwarfGnuPubTypesSection() const
const MCSection * getMergeableConst8Section() const
MCSection * DwarfRnglistsDWOSection
The DWARF v5 range and location list sections for fission.
MCSection * getDwarfStrDWOSection() const
MCSection * ImportCallSection
If import call optimization is supported by the target, this is the section to emit import call data ...
MCSection * MergeableConst32Section
MCSection * SixteenByteConstantSection
MCSection * getStackMapSection() const
MCSection * getDwarfAccelNamesSection() const
MCSection * getReadOnlySection() const
MCSection * getThreadLocalPointerSection() const
MCSection * getDwarfAbbrevDWOSection() const
MCSection * getDwarfRnglistsDWOSection() const
const MCSection * getFourByteConstantSection() const
std::optional< sframe::ABI > SFrameABIArch
SFrame ABI architecture byte.
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 * 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
std::optional< sframe::ABI > getSFrameABIArch() const
MCSection * getGIATsSection() const
MCSection * getSFrameSection() const
MCSection * getDwarfCUIndexSection() const
MCSection * getImportCallSection() 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 * getCOFFGlobalTypeHashesSection() const
MCSection * DwarfGnuPubNamesSection
Section for newer gnu pubnames.
MCSection * StackMapSection
StackMap section.
const MCSection * getUStringSection() const
MCSection * getDwarfMacroDWOSection() const
MCContext & getContext() const
MCSection * DwarfAccelNamespaceSection
MCSection * getDataSection() const
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:496
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
Swift5ReflectionSectionKind
Definition Swift.h:14
This is an optimization pass for GlobalISel generic memory operations.