blob: 2e6a84b6861f812fc69efdce0509bc158bde0cc4 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
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
Andrew Scullcdfcccc2018-10-05 20:58:37 +010016#include "llvm/ADT/DenseMap.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010017#include "llvm/ADT/Triple.h"
Andrew Scullcdfcccc2018-10-05 20:58:37 +010018#include "llvm/MC/MCSymbol.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010019#include "llvm/Support/CodeGen.h"
Andrew Walbran16937d02019-10-22 13:54:20 +010020#include "llvm/Support/VersionTuple.h"
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010021
22namespace llvm {
23class MCContext;
24class MCSection;
25
26class MCObjectFileInfo {
27protected:
28 /// True if .comm supports alignment. This is a hack for as long as we
29 /// support 10.4 Tiger, whose assembler doesn't support alignment on comm.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020030 bool CommDirectiveSupportsAlignment = false;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010031
32 /// True if target object file supports a weak_definition of constant 0 for an
33 /// omitted EH frame.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020034 bool SupportsWeakOmittedEHFrame = false;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010035
36 /// True if the target object file supports emitting a compact unwind section
37 /// without an associated EH frame section.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020038 bool SupportsCompactUnwindWithoutEHFrame = false;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010039
40 /// OmitDwarfIfHaveCompactUnwind - True if the target object file
41 /// supports having some functions with compact unwind and other with
42 /// dwarf unwind.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020043 bool OmitDwarfIfHaveCompactUnwind = false;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010044
Andrew Scullcdfcccc2018-10-05 20:58:37 +010045 /// 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;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010050
51 /// Compact unwind encoding indicating that we should emit only an EH frame.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020052 unsigned CompactUnwindDwarfEHFrameOnly = 0;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010053
54 /// Section directive for standard text.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020055 MCSection *TextSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010056
57 /// Section directive for standard data.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020058 MCSection *DataSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010059
60 /// Section that is default initialized to zero.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020061 MCSection *BSSSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010062
63 /// Section that is readonly and can contain arbitrary initialized data.
64 /// Targets are not required to have a readonly section. If they don't,
65 /// various bits of code will fall back to using the data section for
66 /// constants.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020067 MCSection *ReadOnlySection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010068
69 /// If exception handling is supported by the target, this is the section the
70 /// Language Specific Data Area information is emitted to.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020071 MCSection *LSDASection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010072
73 /// If exception handling is supported by the target and the target can
74 /// support a compact representation of the CIE and FDE, this is the section
75 /// to emit them into.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020076 MCSection *CompactUnwindSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010077
78 // Dwarf sections for debug info. If a target supports debug info, these must
79 // be set.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020080 MCSection *DwarfAbbrevSection = nullptr;
81 MCSection *DwarfInfoSection = nullptr;
82 MCSection *DwarfLineSection = nullptr;
83 MCSection *DwarfLineStrSection = nullptr;
84 MCSection *DwarfFrameSection = nullptr;
85 MCSection *DwarfPubTypesSection = nullptr;
86 const MCSection *DwarfDebugInlineSection = nullptr;
87 MCSection *DwarfStrSection = nullptr;
88 MCSection *DwarfLocSection = nullptr;
89 MCSection *DwarfARangesSection = nullptr;
90 MCSection *DwarfRangesSection = nullptr;
91 MCSection *DwarfMacinfoSection = nullptr;
92 MCSection *DwarfMacroSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010093 // The pubnames section is no longer generated by default. The generation
94 // can be enabled by a compiler flag.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020095 MCSection *DwarfPubNamesSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010096
Andrew Scullcdfcccc2018-10-05 20:58:37 +010097 /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5
98 /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection,
99 /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5
100 /// extensions.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200101 MCSection *DwarfDebugNamesSection = nullptr;
102 MCSection *DwarfAccelNamesSection = nullptr;
103 MCSection *DwarfAccelObjCSection = nullptr;
104 MCSection *DwarfAccelNamespaceSection = nullptr;
105 MCSection *DwarfAccelTypesSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100106
107 // These are used for the Fission separate debug information files.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200108 MCSection *DwarfInfoDWOSection = nullptr;
109 MCSection *DwarfTypesDWOSection = nullptr;
110 MCSection *DwarfAbbrevDWOSection = nullptr;
111 MCSection *DwarfStrDWOSection = nullptr;
112 MCSection *DwarfLineDWOSection = nullptr;
113 MCSection *DwarfLocDWOSection = nullptr;
114 MCSection *DwarfStrOffDWOSection = nullptr;
115 MCSection *DwarfMacinfoDWOSection = nullptr;
116 MCSection *DwarfMacroDWOSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100117
118 /// The DWARF v5 string offset and address table sections.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200119 MCSection *DwarfStrOffSection = nullptr;
120 MCSection *DwarfAddrSection = nullptr;
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100121 /// The DWARF v5 range list section.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200122 MCSection *DwarfRnglistsSection = nullptr;
Andrew Walbran16937d02019-10-22 13:54:20 +0100123 /// The DWARF v5 locations list section.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200124 MCSection *DwarfLoclistsSection = nullptr;
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100125
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200126 /// The DWARF v5 range and location list sections for fission.
127 MCSection *DwarfRnglistsDWOSection = nullptr;
128 MCSection *DwarfLoclistsDWOSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100129
130 // These are for Fission DWP files.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200131 MCSection *DwarfCUIndexSection = nullptr;
132 MCSection *DwarfTUIndexSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100133
134 /// Section for newer gnu pubnames.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200135 MCSection *DwarfGnuPubNamesSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100136 /// Section for newer gnu pubtypes.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200137 MCSection *DwarfGnuPubTypesSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100138
139 // Section for Swift AST
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200140 MCSection *DwarfSwiftASTSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100141
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200142 MCSection *COFFDebugSymbolsSection = nullptr;
143 MCSection *COFFDebugTypesSection = nullptr;
144 MCSection *COFFGlobalTypeHashesSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100145
146 /// Extra TLS Variable Data section.
147 ///
148 /// If the target needs to put additional information for a TLS variable,
149 /// it'll go here.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200150 MCSection *TLSExtraDataSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100151
152 /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200153 MCSection *TLSDataSection = nullptr; // Defaults to ".tdata".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100154
155 /// Section directive for Thread Local uninitialized data.
156 ///
157 /// Null if this target doesn't support a BSS section. ELF and MachO only.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200158 MCSection *TLSBSSSection = nullptr; // Defaults to ".tbss".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100159
160 /// StackMap section.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200161 MCSection *StackMapSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100162
163 /// FaultMap section.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200164 MCSection *FaultMapSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100165
Andrew Walbran3d2c1972020-04-07 12:24:26 +0100166 /// Remarks section.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200167 MCSection *RemarksSection = nullptr;
Andrew Walbran3d2c1972020-04-07 12:24:26 +0100168
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100169 /// EH frame section.
170 ///
171 /// It is initialized on demand so it can be overwritten (with uniquing).
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200172 MCSection *EHFrameSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100173
174 /// Section containing metadata on function stack sizes.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200175 MCSection *StackSizesSection = nullptr;
176
177 /// Section for pseudo probe information used by AutoFDO
178 MCSection *PseudoProbeSection = nullptr;
179 MCSection *PseudoProbeDescSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100180
181 // ELF specific sections.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200182 MCSection *DataRelROSection = nullptr;
183 MCSection *MergeableConst4Section = nullptr;
184 MCSection *MergeableConst8Section = nullptr;
185 MCSection *MergeableConst16Section = nullptr;
186 MCSection *MergeableConst32Section = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100187
188 // MachO specific sections.
189
190 /// Section for thread local structure information.
191 ///
192 /// Contains the source code name of the variable, visibility and a pointer to
193 /// the initial value (.tdata or .tbss).
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200194 MCSection *TLSTLVSection = nullptr; // Defaults to ".tlv".
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100195
196 /// Section for thread local data initialization functions.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200197 // Defaults to ".thread_init_func".
198 const MCSection *TLSThreadInitSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100199
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200200 MCSection *CStringSection = nullptr;
201 MCSection *UStringSection = nullptr;
202 MCSection *TextCoalSection = nullptr;
203 MCSection *ConstTextCoalSection = nullptr;
204 MCSection *ConstDataSection = nullptr;
205 MCSection *DataCoalSection = nullptr;
206 MCSection *ConstDataCoalSection = nullptr;
207 MCSection *DataCommonSection = nullptr;
208 MCSection *DataBSSSection = nullptr;
209 MCSection *FourByteConstantSection = nullptr;
210 MCSection *EightByteConstantSection = nullptr;
211 MCSection *SixteenByteConstantSection = nullptr;
212 MCSection *LazySymbolPointerSection = nullptr;
213 MCSection *NonLazySymbolPointerSection = nullptr;
214 MCSection *ThreadLocalPointerSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100215
216 /// COFF specific sections.
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200217 MCSection *DrectveSection = nullptr;
218 MCSection *PDataSection = nullptr;
219 MCSection *XDataSection = nullptr;
220 MCSection *SXDataSection = nullptr;
221 MCSection *GFIDsSection = nullptr;
222 MCSection *GIATsSection = nullptr;
223 MCSection *GLJMPSection = nullptr;
224
225 // XCOFF specific sections
226 MCSection *TOCBaseSection = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100227
228public:
229 void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
230 bool LargeCodeModel = false);
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200231 MCContext &getContext() const { return *Ctx; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100232
233 bool getSupportsWeakOmittedEHFrame() const {
234 return SupportsWeakOmittedEHFrame;
235 }
236 bool getSupportsCompactUnwindWithoutEHFrame() const {
237 return SupportsCompactUnwindWithoutEHFrame;
238 }
239 bool getOmitDwarfIfHaveCompactUnwind() const {
240 return OmitDwarfIfHaveCompactUnwind;
241 }
242
243 bool getCommDirectiveSupportsAlignment() const {
244 return CommDirectiveSupportsAlignment;
245 }
246
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100247 unsigned getFDEEncoding() const { return FDECFIEncoding; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100248
249 unsigned getCompactUnwindDwarfEHFrameOnly() const {
250 return CompactUnwindDwarfEHFrameOnly;
251 }
252
253 MCSection *getTextSection() const { return TextSection; }
254 MCSection *getDataSection() const { return DataSection; }
255 MCSection *getBSSSection() const { return BSSSection; }
256 MCSection *getReadOnlySection() const { return ReadOnlySection; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100257 MCSection *getCompactUnwindSection() const { return CompactUnwindSection; }
258 MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
259 MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
Andrew Walbran16937d02019-10-22 13:54:20 +0100260 MCSection *getDwarfInfoSection(uint64_t Hash) const {
261 return getDwarfComdatSection(".debug_info", Hash);
262 }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100263 MCSection *getDwarfLineSection() const { return DwarfLineSection; }
264 MCSection *getDwarfLineStrSection() const { return DwarfLineStrSection; }
265 MCSection *getDwarfFrameSection() const { return DwarfFrameSection; }
266 MCSection *getDwarfPubNamesSection() const { return DwarfPubNamesSection; }
267 MCSection *getDwarfPubTypesSection() const { return DwarfPubTypesSection; }
268 MCSection *getDwarfGnuPubNamesSection() const {
269 return DwarfGnuPubNamesSection;
270 }
271 MCSection *getDwarfGnuPubTypesSection() const {
272 return DwarfGnuPubTypesSection;
273 }
274 const MCSection *getDwarfDebugInlineSection() const {
275 return DwarfDebugInlineSection;
276 }
277 MCSection *getDwarfStrSection() const { return DwarfStrSection; }
278 MCSection *getDwarfLocSection() const { return DwarfLocSection; }
279 MCSection *getDwarfARangesSection() const { return DwarfARangesSection; }
280 MCSection *getDwarfRangesSection() const { return DwarfRangesSection; }
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100281 MCSection *getDwarfRnglistsSection() const { return DwarfRnglistsSection; }
Andrew Walbran16937d02019-10-22 13:54:20 +0100282 MCSection *getDwarfLoclistsSection() const { return DwarfLoclistsSection; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100283 MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; }
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200284 MCSection *getDwarfMacroSection() const { return DwarfMacroSection; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100285
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100286 MCSection *getDwarfDebugNamesSection() const {
287 return DwarfDebugNamesSection;
288 }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100289 MCSection *getDwarfAccelNamesSection() const {
290 return DwarfAccelNamesSection;
291 }
292 MCSection *getDwarfAccelObjCSection() const { return DwarfAccelObjCSection; }
293 MCSection *getDwarfAccelNamespaceSection() const {
294 return DwarfAccelNamespaceSection;
295 }
296 MCSection *getDwarfAccelTypesSection() const {
297 return DwarfAccelTypesSection;
298 }
299 MCSection *getDwarfInfoDWOSection() const { return DwarfInfoDWOSection; }
Andrew Walbran16937d02019-10-22 13:54:20 +0100300 MCSection *getDwarfTypesSection(uint64_t Hash) const {
301 return getDwarfComdatSection(".debug_types", Hash);
302 }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100303 MCSection *getDwarfTypesDWOSection() const { return DwarfTypesDWOSection; }
304 MCSection *getDwarfAbbrevDWOSection() const { return DwarfAbbrevDWOSection; }
305 MCSection *getDwarfStrDWOSection() const { return DwarfStrDWOSection; }
306 MCSection *getDwarfLineDWOSection() const { return DwarfLineDWOSection; }
307 MCSection *getDwarfLocDWOSection() const { return DwarfLocDWOSection; }
308 MCSection *getDwarfStrOffDWOSection() const { return DwarfStrOffDWOSection; }
309 MCSection *getDwarfStrOffSection() const { return DwarfStrOffSection; }
310 MCSection *getDwarfAddrSection() const { return DwarfAddrSection; }
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100311 MCSection *getDwarfRnglistsDWOSection() const {
312 return DwarfRnglistsDWOSection;
313 }
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200314 MCSection *getDwarfLoclistsDWOSection() const {
315 return DwarfLoclistsDWOSection;
316 }
317 MCSection *getDwarfMacroDWOSection() const { return DwarfMacroDWOSection; }
318 MCSection *getDwarfMacinfoDWOSection() const {
319 return DwarfMacinfoDWOSection;
320 }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100321 MCSection *getDwarfCUIndexSection() const { return DwarfCUIndexSection; }
322 MCSection *getDwarfTUIndexSection() const { return DwarfTUIndexSection; }
323 MCSection *getDwarfSwiftASTSection() const { return DwarfSwiftASTSection; }
324
325 MCSection *getCOFFDebugSymbolsSection() const {
326 return COFFDebugSymbolsSection;
327 }
328 MCSection *getCOFFDebugTypesSection() const {
329 return COFFDebugTypesSection;
330 }
331 MCSection *getCOFFGlobalTypeHashesSection() const {
332 return COFFGlobalTypeHashesSection;
333 }
334
335 MCSection *getTLSExtraDataSection() const { return TLSExtraDataSection; }
336 const MCSection *getTLSDataSection() const { return TLSDataSection; }
337 MCSection *getTLSBSSSection() const { return TLSBSSSection; }
338
339 MCSection *getStackMapSection() const { return StackMapSection; }
340 MCSection *getFaultMapSection() const { return FaultMapSection; }
Andrew Walbran3d2c1972020-04-07 12:24:26 +0100341 MCSection *getRemarksSection() const { return RemarksSection; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100342
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100343 MCSection *getStackSizesSection(const MCSection &TextSec) const;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100344
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200345 MCSection *getBBAddrMapSection(const MCSection &TextSec) const;
346
347 MCSection *getPseudoProbeSection(const MCSection *TextSec) const;
348
349 MCSection *getPseudoProbeDescSection(StringRef FuncName) const;
350
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100351 // ELF specific sections.
352 MCSection *getDataRelROSection() const { return DataRelROSection; }
353 const MCSection *getMergeableConst4Section() const {
354 return MergeableConst4Section;
355 }
356 const MCSection *getMergeableConst8Section() const {
357 return MergeableConst8Section;
358 }
359 const MCSection *getMergeableConst16Section() const {
360 return MergeableConst16Section;
361 }
362 const MCSection *getMergeableConst32Section() const {
363 return MergeableConst32Section;
364 }
365
366 // MachO specific sections.
367 const MCSection *getTLSTLVSection() const { return TLSTLVSection; }
368 const MCSection *getTLSThreadInitSection() const {
369 return TLSThreadInitSection;
370 }
371 const MCSection *getCStringSection() const { return CStringSection; }
372 const MCSection *getUStringSection() const { return UStringSection; }
373 MCSection *getTextCoalSection() const { return TextCoalSection; }
374 const MCSection *getConstTextCoalSection() const {
375 return ConstTextCoalSection;
376 }
377 const MCSection *getConstDataSection() const { return ConstDataSection; }
378 const MCSection *getDataCoalSection() const { return DataCoalSection; }
Andrew Scullcdfcccc2018-10-05 20:58:37 +0100379 const MCSection *getConstDataCoalSection() const {
380 return ConstDataCoalSection;
381 }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100382 const MCSection *getDataCommonSection() const { return DataCommonSection; }
383 MCSection *getDataBSSSection() const { return DataBSSSection; }
384 const MCSection *getFourByteConstantSection() const {
385 return FourByteConstantSection;
386 }
387 const MCSection *getEightByteConstantSection() const {
388 return EightByteConstantSection;
389 }
390 const MCSection *getSixteenByteConstantSection() const {
391 return SixteenByteConstantSection;
392 }
393 MCSection *getLazySymbolPointerSection() const {
394 return LazySymbolPointerSection;
395 }
396 MCSection *getNonLazySymbolPointerSection() const {
397 return NonLazySymbolPointerSection;
398 }
399 MCSection *getThreadLocalPointerSection() const {
400 return ThreadLocalPointerSection;
401 }
402
403 // COFF specific sections.
404 MCSection *getDrectveSection() const { return DrectveSection; }
405 MCSection *getPDataSection() const { return PDataSection; }
406 MCSection *getXDataSection() const { return XDataSection; }
407 MCSection *getSXDataSection() const { return SXDataSection; }
408 MCSection *getGFIDsSection() const { return GFIDsSection; }
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200409 MCSection *getGIATsSection() const { return GIATsSection; }
410 MCSection *getGLJMPSection() const { return GLJMPSection; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100411
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200412 // XCOFF specific sections
413 MCSection *getTOCBaseSection() const { return TOCBaseSection; }
414
415 MCSection *getEHFrameSection() const { return EHFrameSection; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100416
Andrew Walbran3d2c1972020-04-07 12:24:26 +0100417 enum Environment { IsMachO, IsELF, IsCOFF, IsWasm, IsXCOFF };
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100418 Environment getObjectFileType() const { return Env; }
419
420 bool isPositionIndependent() const { return PositionIndependent; }
421
422private:
423 Environment Env;
Olivier Deprezf4ef2d02021-04-20 13:36:24 +0200424 bool PositionIndependent = false;
425 MCContext *Ctx = nullptr;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100426 Triple TT;
Andrew Walbran16937d02019-10-22 13:54:20 +0100427 VersionTuple SDKVersion;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100428
429 void initMachOMCObjectFileInfo(const Triple &T);
430 void initELFMCObjectFileInfo(const Triple &T, bool Large);
431 void initCOFFMCObjectFileInfo(const Triple &T);
432 void initWasmMCObjectFileInfo(const Triple &T);
Andrew Walbran3d2c1972020-04-07 12:24:26 +0100433 void initXCOFFMCObjectFileInfo(const Triple &T);
Andrew Walbran16937d02019-10-22 13:54:20 +0100434 MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100435
436public:
437 const Triple &getTargetTriple() const { return TT; }
Andrew Walbran16937d02019-10-22 13:54:20 +0100438
439 void setSDKVersion(const VersionTuple &TheSDKVersion) {
440 SDKVersion = TheSDKVersion;
441 }
442
443 const VersionTuple &getSDKVersion() const { return SDKVersion; }
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100444};
445
446} // end namespace llvm
447
448#endif