1 //===- MCSectionELF.h - ELF Machine Code Sections ---------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the MCSectionELF class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCSECTIONELF_H
15 #define LLVM_MC_MCSECTIONELF_H
17 #include "llvm/ADT/Twine.h"
18 #include "llvm/MC/MCSection.h"
19 #include "llvm/MC/MCSymbol.h"
20 #include "llvm/Support/Debug.h"
21 #include "llvm/Support/ELF.h"
22 #include "llvm/Support/raw_ostream.h"
28 /// MCSectionELF - This represents a section on linux, lots of unix variants
29 /// and some bare metal systems.
30 class MCSectionELF : public MCSection {
31 /// SectionName - This is the name of the section. The referenced memory is
32 /// owned by TargetLoweringObjectFileELF's ELFUniqueMap.
33 StringRef SectionName;
35 /// Type - This is the sh_type field of a section, drawn from the enums below.
38 /// Flags - This is the sh_flags field of a section, drawn from the enums.
44 /// EntrySize - The size of each entry in this section. This size only
45 /// makes sense for sections that contain fixed-sized entries. If a
46 /// section does not contain fixed-sized entries 'EntrySize' will be 0.
49 const MCSymbol *Group;
52 friend class MCContext;
53 MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K,
54 unsigned entrySize, const MCSymbol *group, unsigned UniqueID,
56 : MCSection(SV_ELF, K, Begin), SectionName(Section), Type(type),
57 Flags(flags), UniqueID(UniqueID), EntrySize(entrySize), Group(group) {}
60 void setSectionName(StringRef Name) { SectionName = Name; }
64 /// ShouldOmitSectionDirective - Decides whether a '.section' directive
65 /// should be printed before the section name
66 bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
68 StringRef getSectionName() const { return SectionName; }
69 unsigned getType() const { return Type; }
70 unsigned getFlags() const { return Flags; }
71 unsigned getEntrySize() const { return EntrySize; }
72 const MCSymbol *getGroup() const { return Group; }
74 void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
75 const MCExpr *Subsection) const override;
76 bool UseCodeAlign() const override;
77 bool isVirtualSection() const override;
79 bool isUnique() const { return UniqueID != ~0U; }
80 unsigned getUniqueID() const { return UniqueID; }
82 static bool classof(const MCSection *S) {
83 return S->getVariant() == SV_ELF;
87 } // end namespace llvm