LLVM 20.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 /// If import call optimization is supported by the target, this is the
77 /// section to emit import call data to.
79
80 // Dwarf sections for debug info. If a target supports debug info, these must
81 // be set.
95 // The pubnames section is no longer generated by default. The generation
96 // can be enabled by a compiler flag.
98
99 /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
100 /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
101 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
102 /// extensions.
108
109 // These are used for the Fission separate debug information files.
119
120 /// The DWARF v5 string offset and address table sections.
123 /// The DWARF v5 range list section.
125 /// The DWARF v5 locations list section.
127
128 /// The DWARF v5 range and location list sections for fission.
131
132 // These are for Fission DWP files.
135
136 /// Section for newer gnu pubnames.
138 /// Section for newer gnu pubtypes.
140
141 // Section for Swift AST
143
147
148 /// Extra TLS Variable Data section.
149 ///
150 /// If the target needs to put additional information for a TLS variable,
151 /// it'll go here.
153
154 /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
155 MCSection *TLSDataSection = nullptr; // Defaults to ".tdata".
156
157 /// Section directive for Thread Local uninitialized data.
158 ///
159 /// Null if this target doesn't support a BSS section. ELF and MachO only.
160 MCSection *TLSBSSSection = nullptr; // Defaults to ".tbss".
161
162 /// StackMap section.
164
165 /// FaultMap section.
167
168 /// Remarks section.
170
171 /// EH frame section.
172 ///
173 /// It is initialized on demand so it can be overwritten (with uniquing).
175
176 /// Section containing metadata on function stack sizes.
178
179 /// Section for pseudo probe information used by AutoFDO
182
183 // Section for metadata of llvm statistics.
185
186 // ELF specific sections.
192
193 // MachO specific sections.
194
195 /// Section for thread local structure information.
196 ///
197 /// Contains the source code name of the variable, visibility and a pointer to
198 /// the initial value (.tdata or .tbss).
199 MCSection *TLSTLVSection = nullptr; // Defaults to ".tlv".
200
201 /// Section for thread local data initialization functions.
202 // Defaults to ".thread_init_func".
204
221
222 /// COFF specific sections.
231
232 // GOFF specific sections.
238
239 // XCOFF specific sections
243
244 // Swift5 Reflection Data Sections
245 std::array<MCSection *, binaryformat::Swift5ReflectionSectionKind::last>
247
248public:
249 void initMCObjectFileInfo(MCContext &MCCtx, bool PIC,
250 bool LargeCodeModel = false);
252 MCContext &getContext() const { return *Ctx; }
253
256 }
259 }
262 }
263
264 unsigned getFDEEncoding() const { return FDECFIEncoding; }
265
268 }
269
270 virtual unsigned getTextSectionAlignment() const { return 4; }
273 MCSection *getBSSSection() const { return BSSSection; }
281 return getDwarfComdatSection(".debug_info", Hash);
282 }
290 }
293 }
296 }
305
308 }
311 }
315 }
318 }
321 return getDwarfComdatSection(".debug_types", Hash);
322 }
333 }
336 }
340 }
344
347 }
350 }
353 }
354
356 const MCSection *getTLSDataSection() const { return TLSDataSection; }
358
362
363 MCSection *getStackSizesSection(const MCSection &TextSec) const;
364
365 MCSection *getBBAddrMapSection(const MCSection &TextSec) const;
366
367 MCSection *getKCFITrapSection(const MCSection &TextSec) const;
368
369 MCSection *getPseudoProbeSection(const MCSection &TextSec) const;
370
372
374
375 MCSection *getPCSection(StringRef Name, const MCSection *TextSec) const;
376
377 // ELF specific sections.
381 }
384 }
387 }
390 }
391
392 // MachO specific sections.
393 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
396 }
397 const MCSection *getCStringSection() const { return CStringSection; }
398 const MCSection *getUStringSection() const { return UStringSection; }
402 }
407 }
412 }
415 }
418 }
421 }
424 }
427 }
429
430 // COFF specific sections.
439
440 // GOFF specific sections.
444 MCSection *getADASection() const { return ADASection; }
446
447 // XCOFF specific sections
449
451
452 bool isPositionIndependent() const { return PositionIndependent; }
453
454 // Swift5 Reflection Data Sections
457 return ReflSectionKind !=
459 ? Swift5ReflectionSections[ReflSectionKind]
460 : nullptr;
461 }
462
463private:
464 bool PositionIndependent = false;
465 MCContext *Ctx = nullptr;
466
467 void initMachOMCObjectFileInfo(const Triple &T);
468 void initELFMCObjectFileInfo(const Triple &T, bool Large);
469 void initGOFFMCObjectFileInfo(const Triple &T);
470 void initCOFFMCObjectFileInfo(const Triple &T);
471 void initSPIRVMCObjectFileInfo(const Triple &T);
472 void initWasmMCObjectFileInfo(const Triple &T);
473 void initXCOFFMCObjectFileInfo(const Triple &T);
474 void initDXContainerObjectFileInfo(const Triple &T);
475 MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
476};
477
478} // end namespace llvm
479
480#endif
std::string Name
PassInstrumentationCallbacks PIC
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 * 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
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
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
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 * 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
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 * 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:36
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Swift5ReflectionSectionKind
Definition: Swift.h:14
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18