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_MCSECTIONELF_H
0014 #define LLVM_MC_MCSECTIONELF_H
0015
0016 #include "llvm/ADT/PointerIntPair.h"
0017 #include "llvm/ADT/StringRef.h"
0018 #include "llvm/BinaryFormat/ELF.h"
0019 #include "llvm/MC/MCSection.h"
0020 #include "llvm/MC/MCSymbolELF.h"
0021 #include "llvm/MC/SectionKind.h"
0022
0023 namespace llvm {
0024
0025
0026
0027 class MCSectionELF final : public MCSection {
0028
0029 unsigned Type;
0030
0031
0032 unsigned Flags;
0033
0034 unsigned UniqueID;
0035
0036
0037
0038
0039 unsigned EntrySize;
0040
0041
0042
0043 const PointerIntPair<const MCSymbolELF *, 1, bool> Group;
0044
0045
0046
0047 const MCSymbol *LinkedToSym;
0048
0049
0050 uint64_t StartOffset;
0051 uint64_t EndOffset;
0052
0053 private:
0054 friend class MCContext;
0055
0056
0057 MCSectionELF(StringRef Name, unsigned type, unsigned flags,
0058 unsigned entrySize, const MCSymbolELF *group, bool IsComdat,
0059 unsigned UniqueID, MCSymbol *Begin,
0060 const MCSymbolELF *LinkedToSym)
0061 : MCSection(SV_ELF, Name, flags & ELF::SHF_EXECINSTR,
0062 type == ELF::SHT_NOBITS, Begin),
0063 Type(type), Flags(flags), UniqueID(UniqueID), EntrySize(entrySize),
0064 Group(group, IsComdat), LinkedToSym(LinkedToSym) {
0065 assert((!(Flags & ELF::SHF_GROUP) || Group.getPointer()) &&
0066 "Group section without signature!");
0067 if (Group.getPointer())
0068 Group.getPointer()->setIsSignature();
0069 }
0070
0071
0072
0073 void setSectionName(StringRef Name) { this->Name = Name; }
0074
0075 public:
0076
0077
0078 bool shouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
0079
0080 unsigned getType() const { return Type; }
0081 unsigned getFlags() const { return Flags; }
0082 unsigned getEntrySize() const { return EntrySize; }
0083 void setFlags(unsigned F) { Flags = F; }
0084 const MCSymbolELF *getGroup() const { return Group.getPointer(); }
0085 bool isComdat() const { return Group.getInt(); }
0086
0087 void printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
0088 raw_ostream &OS,
0089 uint32_t Subsection) const override;
0090 bool useCodeAlign() const override;
0091 StringRef getVirtualSectionKind() const override;
0092
0093 bool isUnique() const { return UniqueID != NonUniqueID; }
0094 unsigned getUniqueID() const { return UniqueID; }
0095
0096 const MCSection *getLinkedToSection() const {
0097 return &LinkedToSym->getSection();
0098 }
0099 const MCSymbol *getLinkedToSymbol() const { return LinkedToSym; }
0100
0101 void setOffsets(uint64_t Start, uint64_t End) {
0102 StartOffset = Start;
0103 EndOffset = End;
0104 }
0105 std::pair<uint64_t, uint64_t> getOffsets() const {
0106 return std::make_pair(StartOffset, EndOffset);
0107 }
0108
0109 static bool classof(const MCSection *S) {
0110 return S->getVariant() == SV_ELF;
0111 }
0112 };
0113
0114 }
0115
0116 #endif