MCSectionCOFF.h revision eb40a0fd98c44ecc6360e7fab33cf9e9911bed4f
1//===- MCSectionCOFF.h - COFF 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 MCSectionCOFF class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_MC_MCSECTIONCOFF_H
15#define LLVM_MC_MCSECTIONCOFF_H
16
17#include "llvm/MC/MCSection.h"
18
19namespace llvm {
20
21/// MCSectionCOFF - This represents a section on Windows
22  class MCSectionCOFF : public MCSection {
23    // The memory for this string is stored in the same MCContext as *this.
24    StringRef SectionName;
25
26    /// Flags - This is the Characteristics field of a section, drawn
27    /// from the enums below.
28    unsigned Flags;
29
30  private:
31    friend class MCContext;
32    MCSectionCOFF(StringRef Section, unsigned flags, SectionKind K)
33      : MCSection(K), SectionName(Section), Flags(flags) {
34    }
35    ~MCSectionCOFF();
36
37  public:
38    /// ShouldOmitSectionDirective - Decides whether a '.section' directive
39    /// should be printed before the section name
40    bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
41
42    /// Valid section flags.
43    enum {
44      IMAGE_SCN_TYPE_NO_PAD                     = 0x00000008,
45      IMAGE_SCN_CNT_CODE                        = 0x00000020,
46      IMAGE_SCN_CNT_INITIALIZED_DATA            = 0x00000040,
47      IMAGE_SCN_CNT_UNINITIALIZED_DATA          = 0x00000080,
48      IMAGE_SCN_LNK_OTHER                       = 0x00000100,
49      IMAGE_SCN_LNK_INFO                        = 0x00000200,
50      IMAGE_SCN_LNK_REMOVE                      = 0x00000800,
51      IMAGE_SCN_LNK_COMDAT                      = 0x00001000,
52      IMAGE_SCN_MEM_FARDATA                     = 0x00008000,
53      IMAGE_SCN_MEM_PURGEABLE                   = 0x00020000,
54      IMAGE_SCN_MEM_16BIT                       = 0x00020000,
55      IMAGE_SCN_MEM_LOCKED                      = 0x00040000,
56      IMAGE_SCN_MEM_PRELOAD                     = 0x00080000,
57      IMAGE_SCN_ALIGN_1BYTES                    = 0x00100000,
58      IMAGE_SCN_ALIGN_2BYTES                    = 0x00200000,
59      IMAGE_SCN_ALIGN_4BYTES                    = 0x00300000,
60      IMAGE_SCN_ALIGN_8BYTES                    = 0x00400000,
61      IMAGE_SCN_ALIGN_16BYTES                   = 0x00500000,
62      IMAGE_SCN_ALIGN_32BYTES                   = 0x00600000,
63      IMAGE_SCN_ALIGN_64BYTES                   = 0x00700000,
64      IMAGE_SCN_LNK_NRELOC_OVFL                 = 0x01000000,
65      IMAGE_SCN_MEM_DISCARDABLE                 = 0x02000000,
66      IMAGE_SCN_MEM_NOT_CACHED                  = 0x04000000,
67      IMAGE_SCN_MEM_NOT_PAGED                   = 0x08000000,
68      IMAGE_SCN_MEM_SHARED                      = 0x10000000,
69      IMAGE_SCN_MEM_EXECUTE                     = 0x20000000,
70      IMAGE_SCN_MEM_READ                        = 0x40000000,
71      IMAGE_SCN_MEM_WRITE                       = 0x80000000
72    };
73
74    StringRef getSectionName() const { return SectionName; }
75    unsigned getFlags() const { return Flags; }
76
77    virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
78                                      raw_ostream &OS) const;
79  };
80
81} // end namespace llvm
82
83#endif
84