blob: 784f791baae4fb9f4eea753a923f2716d3b2ac37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Internal.Text;
using Internal.TypeSystem;
namespace ILCompiler.DependencyAnalysis
{
/// <summary>
/// Represents a single PInvoke ModuleFixupCell as defined in the core library.
/// </summary>
public class PInvokeModuleFixupNode : ObjectNode, ISymbolDefinitionNode
{
public string _moduleName;
public PInvokeModuleFixupNode(string moduleName)
{
_moduleName = moduleName;
}
public void AppendMangledName(NameMangler nameMangler, Utf8StringBuilder sb)
{
sb.Append("__nativemodule_");
sb.Append(_moduleName);
}
public int Offset => 0;
public override bool IsShareable => true;
protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler);
public override ObjectNodeSection Section => ObjectNodeSection.DataSection;
public override bool StaticDependenciesAreComputed => true;
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
ObjectDataBuilder builder = new ObjectDataBuilder(factory, relocsOnly);
builder.AddSymbol(this);
ISymbolNode nameSymbol = factory.ConstantUtf8String(_moduleName);
//
// Emit a ModuleFixupCell struct
//
builder.EmitZeroPointer();
builder.EmitPointerReloc(nameSymbol);
return builder.ToObjectData();
}
public override int ClassCode => 159930099;
public override int CompareToImpl(ISortableNode other, CompilerComparer comparer)
{
return string.Compare(_moduleName, ((PInvokeModuleFixupNode)other)._moduleName);
}
}
}
|