Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===-- llvm/MC/MCObjectFileInfo.h - Object File Info -----------*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 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 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 16 | #include "llvm/ADT/DenseMap.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 17 | #include "llvm/ADT/Triple.h" |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 18 | #include "llvm/MC/MCSymbol.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 19 | #include "llvm/Support/CodeGen.h" |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 20 | #include "llvm/Support/VersionTuple.h" |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 21 | |
| 22 | namespace llvm { |
| 23 | class MCContext; |
| 24 | class MCSection; |
| 25 | |
| 26 | class MCObjectFileInfo { |
| 27 | protected: |
| 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 Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 30 | bool CommDirectiveSupportsAlignment = false; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 31 | |
| 32 | /// True if target object file supports a weak_definition of constant 0 for an |
| 33 | /// omitted EH frame. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 34 | bool SupportsWeakOmittedEHFrame = false; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 35 | |
| 36 | /// True if the target object file supports emitting a compact unwind section |
| 37 | /// without an associated EH frame section. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 38 | bool SupportsCompactUnwindWithoutEHFrame = false; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 39 | |
| 40 | /// OmitDwarfIfHaveCompactUnwind - True if the target object file |
| 41 | /// supports having some functions with compact unwind and other with |
| 42 | /// dwarf unwind. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 43 | bool OmitDwarfIfHaveCompactUnwind = false; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 44 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 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; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 50 | |
| 51 | /// Compact unwind encoding indicating that we should emit only an EH frame. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 52 | unsigned CompactUnwindDwarfEHFrameOnly = 0; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 53 | |
| 54 | /// Section directive for standard text. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 55 | MCSection *TextSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 56 | |
| 57 | /// Section directive for standard data. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 58 | MCSection *DataSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 59 | |
| 60 | /// Section that is default initialized to zero. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 61 | MCSection *BSSSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 62 | |
| 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 Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 67 | MCSection *ReadOnlySection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 68 | |
| 69 | /// If exception handling is supported by the target, this is the section the |
| 70 | /// Language Specific Data Area information is emitted to. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 71 | MCSection *LSDASection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 72 | |
| 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 Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 76 | MCSection *CompactUnwindSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 77 | |
| 78 | // Dwarf sections for debug info. If a target supports debug info, these must |
| 79 | // be set. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 80 | 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 Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 93 | // The pubnames section is no longer generated by default. The generation |
| 94 | // can be enabled by a compiler flag. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 95 | MCSection *DwarfPubNamesSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 96 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 97 | /// Accelerator table sections. DwarfDebugNamesSection is the DWARF v5 |
| 98 | /// accelerator table, while DwarfAccelNamesSection, DwarfAccelObjCSection, |
| 99 | /// DwarfAccelNamespaceSection, DwarfAccelTypesSection are pre-DWARF v5 |
| 100 | /// extensions. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 101 | MCSection *DwarfDebugNamesSection = nullptr; |
| 102 | MCSection *DwarfAccelNamesSection = nullptr; |
| 103 | MCSection *DwarfAccelObjCSection = nullptr; |
| 104 | MCSection *DwarfAccelNamespaceSection = nullptr; |
| 105 | MCSection *DwarfAccelTypesSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 106 | |
| 107 | // These are used for the Fission separate debug information files. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 108 | 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 Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 117 | |
| 118 | /// The DWARF v5 string offset and address table sections. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 119 | MCSection *DwarfStrOffSection = nullptr; |
| 120 | MCSection *DwarfAddrSection = nullptr; |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 121 | /// The DWARF v5 range list section. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 122 | MCSection *DwarfRnglistsSection = nullptr; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 123 | /// The DWARF v5 locations list section. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 124 | MCSection *DwarfLoclistsSection = nullptr; |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 125 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 126 | /// The DWARF v5 range and location list sections for fission. |
| 127 | MCSection *DwarfRnglistsDWOSection = nullptr; |
| 128 | MCSection *DwarfLoclistsDWOSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 129 | |
| 130 | // These are for Fission DWP files. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 131 | MCSection *DwarfCUIndexSection = nullptr; |
| 132 | MCSection *DwarfTUIndexSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 133 | |
| 134 | /// Section for newer gnu pubnames. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 135 | MCSection *DwarfGnuPubNamesSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 136 | /// Section for newer gnu pubtypes. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 137 | MCSection *DwarfGnuPubTypesSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 138 | |
| 139 | // Section for Swift AST |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 140 | MCSection *DwarfSwiftASTSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 141 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 142 | MCSection *COFFDebugSymbolsSection = nullptr; |
| 143 | MCSection *COFFDebugTypesSection = nullptr; |
| 144 | MCSection *COFFGlobalTypeHashesSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 145 | |
| 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 Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 150 | MCSection *TLSExtraDataSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 151 | |
| 152 | /// Section directive for Thread Local data. ELF, MachO, COFF, and Wasm. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 153 | MCSection *TLSDataSection = nullptr; // Defaults to ".tdata". |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 154 | |
| 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 Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 158 | MCSection *TLSBSSSection = nullptr; // Defaults to ".tbss". |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 159 | |
| 160 | /// StackMap section. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 161 | MCSection *StackMapSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 162 | |
| 163 | /// FaultMap section. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 164 | MCSection *FaultMapSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 165 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 166 | /// Remarks section. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 167 | MCSection *RemarksSection = nullptr; |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 168 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 169 | /// EH frame section. |
| 170 | /// |
| 171 | /// It is initialized on demand so it can be overwritten (with uniquing). |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 172 | MCSection *EHFrameSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 173 | |
| 174 | /// Section containing metadata on function stack sizes. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 175 | MCSection *StackSizesSection = nullptr; |
| 176 | |
| 177 | /// Section for pseudo probe information used by AutoFDO |
| 178 | MCSection *PseudoProbeSection = nullptr; |
| 179 | MCSection *PseudoProbeDescSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 180 | |
| 181 | // ELF specific sections. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 182 | MCSection *DataRelROSection = nullptr; |
| 183 | MCSection *MergeableConst4Section = nullptr; |
| 184 | MCSection *MergeableConst8Section = nullptr; |
| 185 | MCSection *MergeableConst16Section = nullptr; |
| 186 | MCSection *MergeableConst32Section = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 187 | |
| 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 Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 194 | MCSection *TLSTLVSection = nullptr; // Defaults to ".tlv". |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 195 | |
| 196 | /// Section for thread local data initialization functions. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 197 | // Defaults to ".thread_init_func". |
| 198 | const MCSection *TLSThreadInitSection = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 199 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 200 | 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 Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 215 | |
| 216 | /// COFF specific sections. |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 217 | 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 Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 227 | |
| 228 | public: |
| 229 | void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx, |
| 230 | bool LargeCodeModel = false); |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 231 | MCContext &getContext() const { return *Ctx; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 232 | |
| 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 Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 247 | unsigned getFDEEncoding() const { return FDECFIEncoding; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 248 | |
| 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 Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 257 | MCSection *getCompactUnwindSection() const { return CompactUnwindSection; } |
| 258 | MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; } |
| 259 | MCSection *getDwarfInfoSection() const { return DwarfInfoSection; } |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 260 | MCSection *getDwarfInfoSection(uint64_t Hash) const { |
| 261 | return getDwarfComdatSection(".debug_info", Hash); |
| 262 | } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 263 | 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 Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 281 | MCSection *getDwarfRnglistsSection() const { return DwarfRnglistsSection; } |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 282 | MCSection *getDwarfLoclistsSection() const { return DwarfLoclistsSection; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 283 | MCSection *getDwarfMacinfoSection() const { return DwarfMacinfoSection; } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 284 | MCSection *getDwarfMacroSection() const { return DwarfMacroSection; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 285 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 286 | MCSection *getDwarfDebugNamesSection() const { |
| 287 | return DwarfDebugNamesSection; |
| 288 | } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 289 | 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 Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 300 | MCSection *getDwarfTypesSection(uint64_t Hash) const { |
| 301 | return getDwarfComdatSection(".debug_types", Hash); |
| 302 | } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 303 | 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 Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 311 | MCSection *getDwarfRnglistsDWOSection() const { |
| 312 | return DwarfRnglistsDWOSection; |
| 313 | } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 314 | MCSection *getDwarfLoclistsDWOSection() const { |
| 315 | return DwarfLoclistsDWOSection; |
| 316 | } |
| 317 | MCSection *getDwarfMacroDWOSection() const { return DwarfMacroDWOSection; } |
| 318 | MCSection *getDwarfMacinfoDWOSection() const { |
| 319 | return DwarfMacinfoDWOSection; |
| 320 | } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 321 | 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 Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 341 | MCSection *getRemarksSection() const { return RemarksSection; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 342 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 343 | MCSection *getStackSizesSection(const MCSection &TextSec) const; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 344 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 345 | MCSection *getBBAddrMapSection(const MCSection &TextSec) const; |
| 346 | |
| 347 | MCSection *getPseudoProbeSection(const MCSection *TextSec) const; |
| 348 | |
| 349 | MCSection *getPseudoProbeDescSection(StringRef FuncName) const; |
| 350 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 351 | // 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 Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 379 | const MCSection *getConstDataCoalSection() const { |
| 380 | return ConstDataCoalSection; |
| 381 | } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 382 | 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 Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 409 | MCSection *getGIATsSection() const { return GIATsSection; } |
| 410 | MCSection *getGLJMPSection() const { return GLJMPSection; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 411 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 412 | // XCOFF specific sections |
| 413 | MCSection *getTOCBaseSection() const { return TOCBaseSection; } |
| 414 | |
| 415 | MCSection *getEHFrameSection() const { return EHFrameSection; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 416 | |
Andrew Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 417 | enum Environment { IsMachO, IsELF, IsCOFF, IsWasm, IsXCOFF }; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 418 | Environment getObjectFileType() const { return Env; } |
| 419 | |
| 420 | bool isPositionIndependent() const { return PositionIndependent; } |
| 421 | |
| 422 | private: |
| 423 | Environment Env; |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 424 | bool PositionIndependent = false; |
| 425 | MCContext *Ctx = nullptr; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 426 | Triple TT; |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 427 | VersionTuple SDKVersion; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 428 | |
| 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 Walbran | 3d2c197 | 2020-04-07 12:24:26 +0100 | [diff] [blame] | 433 | void initXCOFFMCObjectFileInfo(const Triple &T); |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 434 | MCSection *getDwarfComdatSection(const char *Name, uint64_t Hash) const; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 435 | |
| 436 | public: |
| 437 | const Triple &getTargetTriple() const { return TT; } |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 438 | |
| 439 | void setSDKVersion(const VersionTuple &TheSDKVersion) { |
| 440 | SDKVersion = TheSDKVersion; |
| 441 | } |
| 442 | |
| 443 | const VersionTuple &getSDKVersion() const { return SDKVersion; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 444 | }; |
| 445 | |
| 446 | } // end namespace llvm |
| 447 | |
| 448 | #endif |