1 //===- MCSectionCOFF.h - COFF Machine Code Sections -------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the MCSectionCOFF class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCSECTIONCOFF_H
15 #define LLVM_MC_MCSECTIONCOFF_H
17 #include "llvm/MC/MCSection.h"
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;
26 /// Characteristics - This is the Characteristics field of a section,
27 // drawn from the enums below.
28 unsigned Characteristics;
30 /// Selection - This is the Selection field for the section symbol, if
31 /// it is a COMDAT section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0
35 friend class MCContext;
36 MCSectionCOFF(StringRef Section, unsigned Characteristics,
37 int Selection, SectionKind K)
38 : MCSection(SV_COFF, K), SectionName(Section),
39 Characteristics(Characteristics), Selection (Selection) {
40 assert ((Characteristics & 0x00F00000) == 0 &&
41 "alignment must not be set upon section creation");
46 /// ShouldOmitSectionDirective - Decides whether a '.section' directive
47 /// should be printed before the section name
48 bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
50 //FIXME: all COFF enumerations/flags should be standardized into one place...
51 // Target/X86COFF.h doesn't seem right as COFF can be used for other targets,
52 // MC/WinCOFF.h maybe right as it isn't target or entity specific, and it is
53 // pretty low on the dependancy graph (is there any need to support non
55 // here is good for section stuff, but others should go elsewhere
57 /// Valid section flags.
59 IMAGE_SCN_TYPE_NO_PAD = 0x00000008,
60 IMAGE_SCN_CNT_CODE = 0x00000020,
61 IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040,
62 IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080,
63 IMAGE_SCN_LNK_OTHER = 0x00000100,
64 IMAGE_SCN_LNK_INFO = 0x00000200,
65 IMAGE_SCN_LNK_REMOVE = 0x00000800,
66 IMAGE_SCN_LNK_COMDAT = 0x00001000,
67 IMAGE_SCN_MEM_FARDATA = 0x00008000,
68 IMAGE_SCN_MEM_PURGEABLE = 0x00020000,
69 IMAGE_SCN_MEM_16BIT = 0x00020000,
70 IMAGE_SCN_MEM_LOCKED = 0x00040000,
71 IMAGE_SCN_MEM_PRELOAD = 0x00080000,
72 /* these are handled elsewhere
73 IMAGE_SCN_ALIGN_1BYTES = 0x00100000,
74 IMAGE_SCN_ALIGN_2BYTES = 0x00200000,
75 IMAGE_SCN_ALIGN_4BYTES = 0x00300000,
76 IMAGE_SCN_ALIGN_8BYTES = 0x00400000,
77 IMAGE_SCN_ALIGN_16BYTES = 0x00500000,
78 IMAGE_SCN_ALIGN_32BYTES = 0x00600000,
79 IMAGE_SCN_ALIGN_64BYTES = 0x00700000,
81 IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000,
82 IMAGE_SCN_MEM_DISCARDABLE = 0x02000000,
83 IMAGE_SCN_MEM_NOT_CACHED = 0x04000000,
84 IMAGE_SCN_MEM_NOT_PAGED = 0x08000000,
85 IMAGE_SCN_MEM_SHARED = 0x10000000,
86 IMAGE_SCN_MEM_EXECUTE = 0x20000000,
87 IMAGE_SCN_MEM_READ = 0x40000000,
88 IMAGE_SCN_MEM_WRITE = 0x80000000
92 IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
93 IMAGE_COMDAT_SELECT_ANY,
94 IMAGE_COMDAT_SELECT_SAME_SIZE,
95 IMAGE_COMDAT_SELECT_EXACT_MATCH,
96 IMAGE_COMDAT_SELECT_ASSOCIATIVE,
97 IMAGE_COMDAT_SELECT_LARGEST
100 StringRef getSectionName() const { return SectionName; }
101 unsigned getCharacteristics() const { return Characteristics; }
102 int getSelection () const { return Selection; }
104 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
105 raw_ostream &OS) const;
107 static bool classof(const MCSection *S) {
108 return S->getVariant() == SV_COFF;
110 static bool classof(const MCSectionCOFF *) { return true; }
113 } // end namespace llvm