diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2017-10-11 01:40:13 +0300 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2017-10-11 01:40:13 +0300 |
commit | 58edade60d703f18c1941541c620c649525966df (patch) | |
tree | d00cfc784948e4f41c5b5c7dc563b33ce2f823a9 /src/ILCompiler.Compiler | |
parent | 5d6bd481dd61fefaef637434d4735b39f8704ac8 (diff) |
ProjectX: Fix a dependency tracking issue for FrozenArrayNode
FrozenArrayNode depends on the preinitiailzed data which is not captured in its GetStaticDependencies routine. This is fixed.
[tfs-changeset: 1677823]
Diffstat (limited to 'src/ILCompiler.Compiler')
-rw-r--r-- | src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/FrozenArrayNode.cs | 21 | ||||
-rw-r--r-- | src/ILCompiler.Compiler/src/Compiler/PreInitFieldInfo.cs | 16 |
2 files changed, 27 insertions, 10 deletions
diff --git a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/FrozenArrayNode.cs b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/FrozenArrayNode.cs index 8a5025102..0c3cea2f5 100644 --- a/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/FrozenArrayNode.cs +++ b/src/ILCompiler.Compiler/src/Compiler/DependencyAnalysis/FrozenArrayNode.cs @@ -52,7 +52,7 @@ namespace ILCompiler.DependencyAnalysis } public override void EncodeData(ref ObjectDataBuilder dataBuilder, NodeFactory factory, bool relocsOnly) - { + { // Sync Block dataBuilder.EmitZeroPointer(); @@ -72,17 +72,28 @@ namespace ILCompiler.DependencyAnalysis } // byte contents - _preInitFieldInfo.WriteData(ref dataBuilder, factory); + _preInitFieldInfo.WriteData(ref dataBuilder, factory, relocsOnly); } protected override string GetName(NodeFactory factory) => this.GetMangledName(factory.NameMangler); public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFactory factory) { - return new DependencyListEntry[] + ObjectDataBuilder builder = new ObjectDataBuilder(factory, true); + EncodeData(ref builder, factory, true); + Relocation[] relocs = builder.ToObjectData().Relocs; + DependencyList dependencies = null; + + if (relocs != null) { - new DependencyListEntry(GetEETypeNode(factory), "Frozen preinitialized array"), - }; + dependencies = new DependencyList(); + foreach (Relocation reloc in relocs) + { + dependencies.Add(reloc.Target, "reloc"); + } + } + + return dependencies; } protected override void OnMarked(NodeFactory factory) diff --git a/src/ILCompiler.Compiler/src/Compiler/PreInitFieldInfo.cs b/src/ILCompiler.Compiler/src/Compiler/PreInitFieldInfo.cs index 46b7b98e8..da47f3539 100644 --- a/src/ILCompiler.Compiler/src/Compiler/PreInitFieldInfo.cs +++ b/src/ILCompiler.Compiler/src/Compiler/PreInitFieldInfo.cs @@ -134,7 +134,7 @@ namespace ILCompiler FixupInfos.Sort(); } - public void WriteData(ref ObjectDataBuilder builder, NodeFactory factory) + public void WriteData(ref ObjectDataBuilder builder, NodeFactory factory, bool relocsOnly = false) { int offset = Offset; @@ -150,8 +150,11 @@ namespace ILCompiler if (fixupInfo.Offset < offset) throw new BadImageFormatException(); - // emit bytes before fixup - builder.EmitBytes(Data, offset, fixupInfo.Offset - offset); + if (!relocsOnly) + { + // emit bytes before fixup + builder.EmitBytes(Data, offset, fixupInfo.Offset - offset); + } // write the fixup FixupInfos[i].WriteData(ref builder, factory); @@ -164,8 +167,11 @@ namespace ILCompiler if (offset > Data.Length) throw new BadImageFormatException(); - // Emit remaining bytes - builder.EmitBytes(Data, offset, Data.Length - offset); + if (!relocsOnly) + { + // Emit remaining bytes + builder.EmitBytes(Data, offset, Data.Length - offset); + } } public static List<PreInitFieldInfo> GetPreInitFieldInfos(TypeDesc type, bool hasGCStaticBase) |