LLVM  8.0.1
MCSectionELF.h
Go to the documentation of this file.
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/ADT/StringRef.h"
18 #include "llvm/MC/MCSection.h"
19 #include "llvm/MC/MCSymbolELF.h"
20 #include "llvm/MC/SectionKind.h"
21 
22 namespace llvm {
23 
24 class MCSymbol;
25 
26 /// This represents a section on linux, lots of unix variants and some bare
27 /// metal systems.
28 class MCSectionELF final : public MCSection {
29  /// This is the name of the section. The referenced memory is owned by
30  /// TargetLoweringObjectFileELF's ELFUniqueMap.
32 
33  /// This is the sh_type field of a section, drawn from the enums below.
34  unsigned Type;
35 
36  /// This is the sh_flags field of a section, drawn from the enums below.
37  unsigned Flags;
38 
39  unsigned UniqueID;
40 
41  /// The size of each entry in this section. This size only makes sense for
42  /// sections that contain fixed-sized entries. If a section does not contain
43  /// fixed-sized entries 'EntrySize' will be 0.
44  unsigned EntrySize;
45 
46  const MCSymbolELF *Group;
47 
48  /// sh_info for SHF_LINK_ORDER (can be null).
49  const MCSymbol *AssociatedSymbol;
50 
51 private:
52  friend class MCContext;
53 
54  MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K,
55  unsigned entrySize, const MCSymbolELF *group, unsigned UniqueID,
56  MCSymbol *Begin, const MCSymbolELF *AssociatedSymbol)
57  : MCSection(SV_ELF, K, Begin), SectionName(Section), Type(type),
58  Flags(flags), UniqueID(UniqueID), EntrySize(entrySize), Group(group),
59  AssociatedSymbol(AssociatedSymbol) {
60  if (Group)
61  Group->setIsSignature();
62  }
63 
64  void setSectionName(StringRef Name) { SectionName = Name; }
65 
66 public:
67  ~MCSectionELF();
68 
69  /// Decides whether a '.section' directive should be printed before the
70  /// section name
71  bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
72 
73  StringRef getSectionName() const { return SectionName; }
74  unsigned getType() const { return Type; }
75  unsigned getFlags() const { return Flags; }
76  unsigned getEntrySize() const { return EntrySize; }
77  void setFlags(unsigned F) { Flags = F; }
78  const MCSymbolELF *getGroup() const { return Group; }
79 
80  void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
81  raw_ostream &OS,
82  const MCExpr *Subsection) const override;
83  bool UseCodeAlign() const override;
84  bool isVirtualSection() const override;
85 
86  bool isUnique() const { return UniqueID != ~0U; }
87  unsigned getUniqueID() const { return UniqueID; }
88 
89  const MCSection *getAssociatedSection() const { return &AssociatedSymbol->getSection(); }
90  const MCSymbol *getAssociatedSymbol() const { return AssociatedSymbol; }
91 
92  static bool classof(const MCSection *S) {
93  return S->getVariant() == SV_ELF;
94  }
95 };
96 
97 } // end namespace llvm
98 
99 #endif // LLVM_MC_MCSECTIONELF_H
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
Type
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:49
bool UseCodeAlign() const override
Return true if a .align directive should use "optimized nops" to fill instead of 0s.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
F(f)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
const MCSection * getAssociatedSection() const
Definition: MCSectionELF.h:89
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const
Decides whether a '.section' directive should be printed before the section name. ...
Context object for machine code objects.
Definition: MCContext.h:63
void setIsSignature() const
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
unsigned getUniqueID() const
Definition: MCSectionELF.h:87
const MCSymbolELF * getGroup() const
Definition: MCSectionELF.h:78
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
bool isVirtualSection() const override
Check whether this section is "virtual", that is has no actual object file contents.
void setFlags(unsigned F)
Definition: MCSectionELF.h:77
static bool classof(const MCSection *S)
Definition: MCSectionELF.h:92
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:23
SectionVariant getVariant() const
Definition: MCSection.h:108
unsigned getEntrySize() const
Definition: MCSectionELF.h:76
bool isUnique() const
Definition: MCSectionELF.h:86
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
unsigned getType() const
Definition: MCSectionELF.h:74
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition: MCSymbol.h:267
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition: MCSectionELF.h:28
const char SectionName[]
Definition: AMDGPUPTNote.h:24
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, const MCExpr *Subsection) const override
const MCSymbol * getAssociatedSymbol() const
Definition: MCSectionELF.h:90
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
unsigned getFlags() const
Definition: MCSectionELF.h:75
StringRef getSectionName() const
Definition: MCSectionELF.h:73