LCOV - code coverage report
Current view: top level - include/llvm/MC - MCSectionMachO.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 9 14 64.3 %
Date: 2018-10-20 13:21:21 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- MCSectionMachO.h - MachO 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 MCSectionMachO class.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_MC_MCSECTIONMACHO_H
      15             : #define LLVM_MC_MCSECTIONMACHO_H
      16             : 
      17             : #include "llvm/ADT/StringRef.h"
      18             : #include "llvm/BinaryFormat/MachO.h"
      19             : #include "llvm/MC/MCSection.h"
      20             : 
      21             : namespace llvm {
      22             : 
      23             : /// This represents a section on a Mach-O system (used by Mac OS X).  On a Mac
      24             : /// system, these are also described in /usr/include/mach-o/loader.h.
      25      159949 : class MCSectionMachO final : public MCSection {
      26             :   char SegmentName[16];  // Not necessarily null terminated!
      27             :   char SectionName[16];  // Not necessarily null terminated!
      28             : 
      29             :   /// This is the SECTION_TYPE and SECTION_ATTRIBUTES field of a section, drawn
      30             :   /// from the enums below.
      31             :   unsigned TypeAndAttributes;
      32             : 
      33             :   /// The 'reserved2' field of a section, used to represent the size of stubs,
      34             :   /// for example.
      35             :   unsigned Reserved2;
      36             : 
      37             :   MCSectionMachO(StringRef Segment, StringRef Section, unsigned TAA,
      38             :                  unsigned reserved2, SectionKind K, MCSymbol *Begin);
      39             :   friend class MCContext;
      40             : public:
      41             : 
      42             :   StringRef getSegmentName() const {
      43             :     // SegmentName is not necessarily null terminated!
      44       16520 :     if (SegmentName[15])
      45          41 :       return StringRef(SegmentName, 16);
      46       16479 :     return StringRef(SegmentName);
      47             :   }
      48             :   StringRef getSectionName() const {
      49             :     // SectionName is not necessarily null terminated!
      50       10648 :     if (SectionName[15])
      51         754 :       return StringRef(SectionName, 16);
      52        9894 :     return StringRef(SectionName);
      53             :   }
      54             : 
      55           0 :   unsigned getTypeAndAttributes() const { return TypeAndAttributes; }
      56           0 :   unsigned getStubSize() const { return Reserved2; }
      57             : 
      58           0 :   MachO::SectionType getType() const {
      59           0 :     return static_cast<MachO::SectionType>(TypeAndAttributes &
      60       41319 :                                            MachO::SECTION_TYPE);
      61             :   }
      62           0 :   bool hasAttribute(unsigned Value) const {
      63         969 :     return (TypeAndAttributes & Value) != 0;
      64             :   }
      65             : 
      66             :   /// Parse the section specifier indicated by "Spec". This is a string that can
      67             :   /// appear after a .section directive in a mach-o flavored .s file.  If
      68             :   /// successful, this fills in the specified Out parameters and returns an
      69             :   /// empty string.  When an invalid section specifier is present, this returns
      70             :   /// a string indicating the problem. If no TAA was parsed, TAA is not altered,
      71             :   /// and TAAWasSet becomes false.
      72             :   static std::string ParseSectionSpecifier(StringRef Spec,       // In.
      73             :                                            StringRef &Segment,   // Out.
      74             :                                            StringRef &Section,   // Out.
      75             :                                            unsigned  &TAA,       // Out.
      76             :                                            bool      &TAAParsed, // Out.
      77             :                                            unsigned  &StubSize); // Out.
      78             : 
      79             :   void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
      80             :                             raw_ostream &OS,
      81             :                             const MCExpr *Subsection) const override;
      82             :   bool UseCodeAlign() const override;
      83             :   bool isVirtualSection() const override;
      84             : 
      85             :   static bool classof(const MCSection *S) {
      86             :     return S->getVariant() == SV_MachO;
      87             :   }
      88             : };
      89             : 
      90             : } // end namespace llvm
      91             : 
      92             : #endif

Generated by: LCOV version 1.13