Coverage Report

Created: 2019-02-20 00:17

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/MC/MCSectionELF.h
Line
Count
Source
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
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_MC_MCSECTIONELF_H
14
#define LLVM_MC_MCSECTIONELF_H
15
16
#include "llvm/ADT/StringRef.h"
17
#include "llvm/MC/MCSection.h"
18
#include "llvm/MC/MCSymbolELF.h"
19
#include "llvm/MC/SectionKind.h"
20
21
namespace llvm {
22
23
class MCSymbol;
24
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.
30
  StringRef SectionName;
31
32
  /// This is the sh_type field of a section, drawn from the enums below.
33
  unsigned Type;
34
35
  /// This is the sh_flags field of a section, drawn from the enums below.
36
  unsigned Flags;
37
38
  unsigned UniqueID;
39
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;
44
45
  const MCSymbolELF *Group;
46
47
  /// sh_info for SHF_LINK_ORDER (can be null).
48
  const MCSymbol *AssociatedSymbol;
49
50
private:
51
  friend class MCContext;
52
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
1.82M
        AssociatedSymbol(AssociatedSymbol) {
59
1.82M
    if (Group)
60
434
      Group->setIsSignature();
61
1.82M
  }
62
63
7
  void setSectionName(StringRef Name) { SectionName = Name; }
64
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;
69
70
1.42M
  StringRef getSectionName() const { return SectionName; }
71
2.49M
  unsigned getType() const { return Type; }
72
937k
  unsigned getFlags() const { return Flags; }
73
423k
  unsigned getEntrySize() const { return EntrySize; }
74
6
  void setFlags(unsigned F) { Flags = F; }
75
827k
  const MCSymbolELF *getGroup() const { return Group; }
76
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;
82
83
211k
  bool isUnique() const { return UniqueID != ~0U; }
84
816
  unsigned getUniqueID() const { return UniqueID; }
85
86
7.77k
  const MCSection *getAssociatedSection() const { return &AssociatedSymbol->getSection(); }
87
234
  const MCSymbol *getAssociatedSymbol() const { return AssociatedSymbol; }
88
89
105
  static bool classof(const MCSection *S) {
90
105
    return S->getVariant() == SV_ELF;
91
105
  }
92
};
93
94
} // end namespace llvm
95
96
#endif // LLVM_MC_MCSECTIONELF_H