File indexing completed on 2026-05-10 08:44:14
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_MC_MCSECTIONCOFF_H
0014 #define LLVM_MC_MCSECTIONCOFF_H
0015
0016 #include "llvm/ADT/StringRef.h"
0017 #include "llvm/BinaryFormat/COFF.h"
0018 #include "llvm/MC/MCSection.h"
0019 #include "llvm/MC/SectionKind.h"
0020 #include <cassert>
0021
0022 namespace llvm {
0023
0024 class MCSymbol;
0025
0026
0027 class MCSectionCOFF final : public MCSection {
0028
0029
0030
0031
0032
0033 mutable unsigned Characteristics;
0034
0035
0036
0037
0038
0039
0040 mutable unsigned WinCFISectionID = ~0U;
0041
0042
0043
0044 MCSymbol *COMDATSymbol;
0045
0046
0047
0048 mutable int Selection;
0049
0050 private:
0051 friend class MCContext;
0052
0053 MCSectionCOFF(StringRef Name, unsigned Characteristics,
0054 MCSymbol *COMDATSymbol, int Selection, MCSymbol *Begin)
0055 : MCSection(SV_COFF, Name, Characteristics & COFF::IMAGE_SCN_CNT_CODE,
0056 Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA,
0057 Begin),
0058 Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
0059 Selection(Selection) {
0060 assert((Characteristics & 0x00F00000) == 0 &&
0061 "alignment must not be set upon section creation");
0062 }
0063
0064 public:
0065
0066
0067 bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
0068
0069 unsigned getCharacteristics() const { return Characteristics; }
0070 MCSymbol *getCOMDATSymbol() const { return COMDATSymbol; }
0071 int getSelection() const { return Selection; }
0072
0073 void setSelection(int Selection) const;
0074
0075 void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
0076 raw_ostream &OS,
0077 uint32_t Subsection) const override;
0078 bool useCodeAlign() const override;
0079 StringRef getVirtualSectionKind() const override;
0080
0081 unsigned getOrAssignWinCFISectionID(unsigned *NextID) const {
0082 if (WinCFISectionID == ~0U)
0083 WinCFISectionID = (*NextID)++;
0084 return WinCFISectionID;
0085 }
0086
0087 static bool isImplicitlyDiscardable(StringRef Name) {
0088 return Name.starts_with(".debug");
0089 }
0090
0091 static bool classof(const MCSection *S) { return S->getVariant() == SV_COFF; }
0092 };
0093
0094 }
0095
0096 #endif