LLVM  10.0.0svn
Go to the documentation of this file.
1 //===- MCSectionELF.h - ELF Machine Code Sections ---------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the MCSectionELF class.
10 //
11 //===----------------------------------------------------------------------===//
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/MC/MCSection.h"
18 #include "llvm/MC/MCSymbolELF.h"
19 #include "llvm/MC/SectionKind.h"
21 namespace llvm {
23 class MCSymbol;
25 /// This represents a section on linux, lots of unix variants and some bare
26 /// metal systems.
27 class MCSectionELF final : public MCSection {
28  /// This is the name of the section. The referenced memory is owned by
29  /// TargetLoweringObjectFileELF's ELFUniqueMap.
32  /// This is the sh_type field of a section, drawn from the enums below.
33  unsigned Type;
35  /// This is the sh_flags field of a section, drawn from the enums below.
36  unsigned Flags;
38  unsigned UniqueID;
40  /// The size of each entry in this section. This size only makes sense for
41  /// sections that contain fixed-sized entries. If a section does not contain
42  /// fixed-sized entries 'EntrySize' will be 0.
43  unsigned EntrySize;
45  const MCSymbolELF *Group;
47  /// sh_info for SHF_LINK_ORDER (can be null).
48  const MCSymbol *AssociatedSymbol;
50 private:
51  friend class MCContext;
53  MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K,
54  unsigned entrySize, const MCSymbolELF *group, unsigned UniqueID,
55  MCSymbol *Begin, const MCSymbolELF *AssociatedSymbol)
56  : MCSection(SV_ELF, K, Begin), SectionName(Section), Type(type),
57  Flags(flags), UniqueID(UniqueID), EntrySize(entrySize), Group(group),
58  AssociatedSymbol(AssociatedSymbol) {
59  if (Group)
60  Group->setIsSignature();
61  }
63  void setSectionName(StringRef Name) { SectionName = Name; }
65 public:
66  /// Decides whether a '.section' directive should be printed before the
67  /// section name
68  bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
70  StringRef getSectionName() const { return SectionName; }
71  unsigned getType() const { return Type; }
72  unsigned getFlags() const { return Flags; }
73  unsigned getEntrySize() const { return EntrySize; }
74  void setFlags(unsigned F) { Flags = F; }
75  const MCSymbolELF *getGroup() const { return Group; }
77  void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
78  raw_ostream &OS,
79  const MCExpr *Subsection) const override;
80  bool UseCodeAlign() const override;
81  bool isVirtualSection() const override;
83  bool isUnique() const { return UniqueID != ~0U; }
84  unsigned getUniqueID() const { return UniqueID; }
86  const MCSection *getAssociatedSection() const { return &AssociatedSymbol->getSection(); }
87  const MCSymbol *getAssociatedSymbol() const { return AssociatedSymbol; }
89  static bool classof(const MCSection *S) {
90  return S->getVariant() == SV_ELF;
91  }
92 };
94 } // end namespace llvm
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:38
MessagePack types as defined in the standard, with the exception of Integer being divided into a sign...
Definition: MsgPackReader.h:48
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:23
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
const MCSection * getAssociatedSection() const
Definition: MCSectionELF.h:86
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
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:65
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:84
const MCSymbolELF * getGroup() const
Definition: MCSectionELF.h:75
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
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:74
static bool classof(const MCSection *S)
Definition: MCSectionELF.h:89
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
SectionVariant getVariant() const
Definition: MCSection.h:107
unsigned getEntrySize() const
Definition: MCSectionELF.h:73
bool isUnique() const
Definition: MCSectionELF.h:83
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
unsigned getType() const
Definition: MCSectionELF.h:71
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition: MCSymbol.h:268
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition: MCSectionELF.h:27
const char SectionName[]
Definition: AMDGPUPTNote.h:23
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, const MCExpr *Subsection) const override
const MCSymbol * getAssociatedSymbol() const
Definition: MCSectionELF.h:87
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
unsigned getFlags() const
Definition: MCSectionELF.h:72
StringRef getSectionName() const
Definition: MCSectionELF.h:70