1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System;
6 
7 namespace ILCompiler.DependencyAnalysis
8 {
9     public enum SectionType
10     {
11         ReadOnly,
12         Writeable,
13         Executable
14     }
15 
16     /// <summary>
17     /// Specifies the object file section a node will be placed in; ie "text" or "data"
18     /// </summary>
19     public class ObjectNodeSection
20     {
21         public string Name { get; }
22         public SectionType Type { get; }
23         public string ComdatName { get; }
24 
ObjectNodeSection(string name, SectionType type, string comdatName)25         public ObjectNodeSection(string name, SectionType type, string comdatName)
26         {
27             Name = name;
28             Type = type;
29             ComdatName = comdatName;
30         }
31 
ObjectNodeSection(string name, SectionType type)32         public ObjectNodeSection(string name, SectionType type) : this(name, type, null)
33         { }
34 
35         /// <summary>
36         /// Returns true if the section is a standard one (defined as text, data, or rdata currently)
37         /// </summary>
38         public bool IsStandardSection
39         {
40             get
41             {
42                 return this == DataSection || this == ReadOnlyDataSection || this == FoldableReadOnlyDataSection || this == TextSection || this == XDataSection;
43             }
44         }
45 
46         public static readonly ObjectNodeSection XDataSection = new ObjectNodeSection("xdata", SectionType.ReadOnly);
47         public static readonly ObjectNodeSection DataSection = new ObjectNodeSection("data", SectionType.Writeable);
48         public static readonly ObjectNodeSection ReadOnlyDataSection = new ObjectNodeSection("rdata", SectionType.ReadOnly);
49         public static readonly ObjectNodeSection FoldableReadOnlyDataSection = new ObjectNodeSection("rdata$ICF", SectionType.ReadOnly);
50         public static readonly ObjectNodeSection TextSection = new ObjectNodeSection("text", SectionType.Executable);
51         public static readonly ObjectNodeSection TLSSection = new ObjectNodeSection("TLS", SectionType.Writeable);
52     }
53 }
54