Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <martin.baulig@xamarin.com>2013-10-25 17:15:18 +0400
committerMartin Baulig <martin.baulig@xamarin.com>2013-10-25 17:17:02 +0400
commitc29ac46c408aa2ae588548fa36a0aa9bf0b01014 (patch)
tree8ddfb2ac7f943acfbfa589e12b8fec341dc90f14
parentf16333347399978cc1b2643a5c79c61996503c7e (diff)
[linker]: Also reference all type-references for LinkAction.Link and Save.
-rw-r--r--mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs26
1 files changed, 25 insertions, 1 deletions
diff --git a/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs b/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs
index 5cea341b099..20f06f3bb58 100644
--- a/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs
+++ b/mcs/tools/linker/Mono.Linker.Steps/SweepStep.cs
@@ -37,6 +37,7 @@ namespace Mono.Linker.Steps {
public class SweepStep : BaseStep {
AssemblyDefinition [] assemblies;
+ HashSet<AssemblyDefinition> resolvedTypeReferences;
protected override void Process ()
{
@@ -102,15 +103,38 @@ namespace Mono.Linker.Steps {
references.RemoveAt (i);
// Removing the reference does not mean it will be saved back to disk!
// That depends on the AssemblyAction set for the `assembly`
- if (Annotations.GetAction (assembly) == AssemblyAction.Copy) {
+ switch (Annotations.GetAction (assembly)) {
+ case AssemblyAction.Copy:
// Copy means even if "unlinked" we still want that assembly to be saved back
// to disk (OutputStep) without the (removed) reference
Annotations.SetAction (assembly, AssemblyAction.Save);
+ ResolveAllTypeReferences (assembly);
+ break;
+
+ case AssemblyAction.Save:
+ case AssemblyAction.Link:
+ ResolveAllTypeReferences (assembly);
+ break;
}
return;
}
}
+ void ResolveAllTypeReferences (AssemblyDefinition assembly)
+ {
+ if (resolvedTypeReferences == null)
+ resolvedTypeReferences = new HashSet<AssemblyDefinition> ();
+ if (resolvedTypeReferences.Contains (assembly))
+ return;
+ resolvedTypeReferences.Add (assembly);
+
+ foreach (TypeReference tr in assembly.MainModule.GetTypeReferences ()) {
+ var td = tr.Resolve ();
+ // at this stage reference might include things that can't be resolved
+ tr.Scope = td == null ? null : assembly.MainModule.Import (td).Scope;
+ }
+ }
+
void SweepType (TypeDefinition type)
{
if (type.HasFields)