• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- MCSectionELF.h - ELF Machine Code Sections ---------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the MCSectionELF class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_MC_MCSECTIONELF_H
15 #define LLVM_MC_MCSECTIONELF_H
16 
17 #include "llvm/MC/MCSection.h"
18 #include "llvm/Support/ELF.h"
19 
20 namespace llvm {
21 
22 class MCSymbol;
23 
24 /// MCSectionELF - This represents a section on linux, lots of unix variants
25 /// and some bare metal systems.
26 class MCSectionELF : public MCSection {
27   /// SectionName - This is the name of the section.  The referenced memory is
28   /// owned by TargetLoweringObjectFileELF's ELFUniqueMap.
29   StringRef SectionName;
30 
31   /// Type - This is the sh_type field of a section, drawn from the enums below.
32   unsigned Type;
33 
34   /// Flags - This is the sh_flags field of a section, drawn from the enums.
35   /// below.
36   unsigned Flags;
37 
38   /// EntrySize - The size of each entry in this section. This size only
39   /// makes sense for sections that contain fixed-sized entries. If a
40   /// section does not contain fixed-sized entries 'EntrySize' will be 0.
41   unsigned EntrySize;
42 
43   const MCSymbol *Group;
44 
45 private:
46   friend class MCContext;
MCSectionELF(StringRef Section,unsigned type,unsigned flags,SectionKind K,unsigned entrySize,const MCSymbol * group)47   MCSectionELF(StringRef Section, unsigned type, unsigned flags,
48                SectionKind K, unsigned entrySize, const MCSymbol *group)
49     : MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags),
50       EntrySize(entrySize), Group(group) {}
51   ~MCSectionELF();
52 public:
53 
54   /// ShouldOmitSectionDirective - Decides whether a '.section' directive
55   /// should be printed before the section name
56   bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
57 
getSectionName()58   StringRef getSectionName() const { return SectionName; }
getType()59   unsigned getType() const { return Type; }
getFlags()60   unsigned getFlags() const { return Flags; }
getEntrySize()61   unsigned getEntrySize() const { return EntrySize; }
getGroup()62   const MCSymbol *getGroup() const { return Group; }
63 
64   void PrintSwitchToSection(const MCAsmInfo &MAI,
65                             raw_ostream &OS) const;
66   virtual bool UseCodeAlign() const;
67   virtual bool isVirtualSection() const;
68 
69   /// isBaseAddressKnownZero - We know that non-allocatable sections (like
70   /// debug info) have a base of zero.
isBaseAddressKnownZero()71   virtual bool isBaseAddressKnownZero() const {
72     return (getFlags() & ELF::SHF_ALLOC) == 0;
73   }
74 
classof(const MCSection * S)75   static bool classof(const MCSection *S) {
76     return S->getVariant() == SV_ELF;
77   }
classof(const MCSectionELF *)78   static bool classof(const MCSectionELF *) { return true; }
79 
80   // Return the entry size for sections with fixed-width data.
81   static unsigned DetermineEntrySize(SectionKind Kind);
82 
83 };
84 
85 } // end namespace llvm
86 
87 #endif
88