Author: jbevain
Date: 2006-08-21 05:35:51 -0400 (Mon, 21 Aug 2006)
New Revision: 64133
Added:
trunk/cecil/linker/Descriptors/
trunk/cecil/linker/Descriptors/corlib.xml
trunk/cecil/linker/Descriptors/corlib2.xml
Modified:
trunk/cecil/linker/ChangeLog
trunk/cecil/linker/Mono.Linker.csproj
trunk/cecil/linker/Mono.Linker/Driver.cs
trunk/cecil/linker/Mono.Linker/LinkContext.cs
trunk/cecil/linker/Mono.Linker/MarkStep.cs
trunk/cecil/linker/Mono.Linker/SweepStep.cs
Log:
2006-08-21 Jb Evain <[EMAIL PROTECTED]>
* mark types used within the runtime
Modified: trunk/cecil/linker/ChangeLog
===================================================================
--- trunk/cecil/linker/ChangeLog 2006-08-21 09:27:16 UTC (rev 64132)
+++ trunk/cecil/linker/ChangeLog 2006-08-21 09:35:51 UTC (rev 64133)
@@ -1,3 +1,7 @@
+2006-08-21 Jb Evain <[EMAIL PROTECTED]>
+
+ * mark types used within the runtime
+
2006-08-20 Jb Evain <[EMAIL PROTECTED]>
* mark the custom attributes from the assemblies, modules and
Added: trunk/cecil/linker/Descriptors/corlib.xml
===================================================================
--- trunk/cecil/linker/Descriptors/corlib.xml 2006-08-21 09:27:16 UTC (rev
64132)
+++ trunk/cecil/linker/Descriptors/corlib.xml 2006-08-21 09:35:51 UTC (rev
64133)
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<linker>
+ <assembly fullname="mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
+ <type fullname="System.AppDomain" />
+ <type fullname="System.AppDomainSetup" />
+ <type fullname="System.AppDomainUnloadedException" />
+ <type fullname="System.ArgumentException" />
+ <type fullname="System.ArgumentNullException" />
+ <type fullname="System.ArgumentOutOfRangeException" />
+ <type fullname="System.ArithmeticException" />
+ <type fullname="System.Array" />
+ <type fullname="System.ArrayTypeMismatchException" />
+ <type fullname="System.BadImageFormatException" />
+ <type fullname="System.Boolean" />
+ <type fullname="System.Byte" />
+ <type fullname="System.CannotUnloadAppDomainException" />
+ <type fullname="System.Char" />
+ <type fullname="System.Delegate" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackTrace" />
+ <type fullname="System.DivideByZeroException" />
+ <type fullname="System.Double" />
+ <type fullname="System.Enum" />
+ <type fullname="System.Environment" />
+ <type fullname="System.Exception" />
+ <type fullname="System.ExecutionEngineException" />
+ <type fullname="System.FieldAccessException" />
+ <type fullname="System.FormatException" />
+ <type fullname="System.IO.FileNotFoundException" />
+ <type fullname="System.IO.IOException" />
+ <type fullname="System.IndexOutOfRangeException" />
+ <type fullname="System.Int16" />
+ <type fullname="System.Int32" />
+ <type fullname="System.Int64" />
+ <type fullname="System.IntPtr" />
+ <type fullname="System.InvalidCastException" />
+ <type fullname="System.InvalidOperationException" />
+ <type fullname="System.InvalidProgramException" />
+ <type fullname="System.MarshalByRefObject" />
+ <type fullname="System.Math" />
+ <type fullname="System.MethodAccessException" />
+ <type fullname="System.MissingFieldException" />
+ <type fullname="System.MissingMethodException" />
+ <type fullname="System.MonoType" />
+ <type fullname="System.MulticastDelegate" />
+ <type fullname="System.NotImplementedException" />
+ <type fullname="System.NotSupportedException" />
+ <type fullname="System.NullReferenceException" />
+ <type fullname="System.Object" />
+ <type fullname="System.Object" />
+ <type fullname="System.OutOfMemoryException" />
+ <type fullname="System.Reflection.Assembly" />
+ <type fullname="System.Reflection.ConstructorInfo" />
+ <type fullname="System.Reflection.EventInfo" />
+ <type fullname="System.Reflection.FieldInfo" />
+ <type fullname="System.Reflection.MethodInfo" />
+ <type fullname="System.Reflection.PropertyInfo" />
+ <type fullname="System.Reflection.ReflectionTypeLoadException"
/>
+ <type fullname="System.Reflection.TargetException" />
+ <type
fullname="System.Reflection.TargetParameterCountException" />
+ <type fullname="System.Runtime.InteropServices.Marshal" />
+ <type fullname="System.Runtime.Remoting.Contexts.Context" />
+ <type fullname="System.Runtime.Remoting.IRemotingTypeInfo" />
+ <type fullname="System.Runtime.Remoting.Messaging" />
+ <type
fullname="System.Runtime.Remoting.Messaging.MonoMethodMessage" />
+ <type fullname="System.Runtime.Remoting.Proxies.RealProxy" />
+ <type
fullname="System.Runtime.Remoting.Proxies.TransparentProxy" />
+ <type fullname="System.Runtime.Serialization.ISerializable" />
+ <type
fullname="System.Runtime.Serialization.SerializationException" />
+ <type fullname="System.Runtime.Serialization.SerializationInfo"
/>
+ <type fullname="System.Runtime.StreamingContext" />
+ <type fullname="System.RuntimeArgumentHandle" />
+ <type fullname="System.RuntimeFieldHandle" />
+ <type fullname="System.RuntimeMethodHandle" />
+ <type fullname="System.RuntimeTypeHandle" />
+ <type fullname="System.SByte" />
+ <type fullname="System.Security.RuntimeSecurityFrame" />
+ <type fullname="System.Security.SecurityException" />
+ <type fullname="System.Security.VerificationException" />
+ <type fullname="System.Single" />
+ <type fullname="System.StackOverflowException" />
+ <type fullname="System.String" />
+ <type fullname="System.SynchronizationLocalException" />
+ <type fullname="System.Text.StringBuilder" />
+ <type fullname="System.Threading.ExecutionContext" />
+ <type fullname="System.Threading.Monitor" />
+ <type fullname="System.Threading.Thread" />
+ <type fullname="System.Threading.ThreadAbortException" />
+ <type fullname="System.Threading.ThreadStateException" />
+ <type fullname="System.Threading.WaitHandle" />
+ <type fullname="System.Type" />
+ <type fullname="System.TypeInitializationException" />
+ <type fullname="System.TypeLoadException" />
+ <type fullname="System.TypedReference" />
+ <type fullname="System.UInt16" />
+ <type fullname="System.UInt32" />
+ <type fullname="System.UInt64" />
+ <type fullname="System.UIntPtr" />
+ <type fullname="System.ValueType" />
+ <type fullname="System.Variant" />
+ <type fullname="System.Void" />
+ </assembly>
+</linker>
Property changes on: trunk/cecil/linker/Descriptors/corlib.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Added: trunk/cecil/linker/Descriptors/corlib2.xml
===================================================================
--- trunk/cecil/linker/Descriptors/corlib2.xml 2006-08-21 09:27:16 UTC (rev
64132)
+++ trunk/cecil/linker/Descriptors/corlib2.xml 2006-08-21 09:35:51 UTC (rev
64133)
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<linker>
+ <assembly fullname="mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
+ <type fullname="System.AppDomain" />
+ <type fullname="System.AppDomainSetup" />
+ <type fullname="System.AppDomainUnloadedException" />
+ <type fullname="System.ArgumentException" />
+ <type fullname="System.ArgumentNullException" />
+ <type fullname="System.ArgumentOutOfRangeException" />
+ <type fullname="System.ArithmeticException" />
+ <type fullname="System.Array" />
+ <type fullname="System.Array/InternalArray`1" />
+ <type fullname="System.ArrayTypeMismatchException" />
+ <type fullname="System.BadImageFormatException" />
+ <type fullname="System.Boolean" />
+ <type fullname="System.Byte" />
+ <type fullname="System.CannotUnloadAppDomainException" />
+ <type fullname="System.Char" />
+ <type fullname="System.Delegate" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackFrame" />
+ <type fullname="System.Diagnostics.StackTrace" />
+ <type fullname="System.DivideByZeroException" />
+ <type fullname="System.Double" />
+ <type fullname="System.Enum" />
+ <type fullname="System.Environment" />
+ <type fullname="System.Exception" />
+ <type fullname="System.ExecutionEngineException" />
+ <type fullname="System.FieldAccessException" />
+ <type fullname="System.FormatException" />
+ <type fullname="System.IO.FileNotFoundException" />
+ <type fullname="System.IO.IOException" />
+ <type fullname="System.IndexOutOfRangeException" />
+ <type fullname="System.Int16" />
+ <type fullname="System.Int32" />
+ <type fullname="System.Int64" />
+ <type fullname="System.IntPtr" />
+ <type fullname="System.InvalidCastException" />
+ <type fullname="System.InvalidOperationException" />
+ <type fullname="System.InvalidProgramException" />
+ <type fullname="System.MarshalByRefObject" />
+ <type fullname="System.Math" />
+ <type fullname="System.MethodAccessException" />
+ <type fullname="System.MissingFieldException" />
+ <type fullname="System.MissingMethodException" />
+ <type fullname="System.MonoType" />
+ <type fullname="System.MulticastDelegate" />
+ <type fullname="System.NotImplementedException" />
+ <type fullname="System.NotSupportedException" />
+ <type fullname="System.NullReferenceException" />
+ <type fullname="System.Nullable`1" />
+ <type fullname="System.Object" />
+ <type fullname="System.Object" />
+ <type fullname="System.OutOfMemoryException" />
+ <type fullname="System.Reflection.Assembly" />
+ <type fullname="System.Reflection.ConstructorInfo" />
+ <type fullname="System.Reflection.EventInfo" />
+ <type fullname="System.Reflection.FieldInfo" />
+ <type fullname="System.Reflection.MethodInfo" />
+ <type fullname="System.Reflection.PropertyInfo" />
+ <type fullname="System.Reflection.ReflectionTypeLoadException"
/>
+ <type fullname="System.Reflection.TargetException" />
+ <type
fullname="System.Reflection.TargetParameterCountException" />
+ <type
fullname="System.Runtime.CompilerServices.InternalsVisibleToAttribute" />
+ <type fullname="System.Runtime.InteropServices.Marshal" />
+ <type fullname="System.Runtime.Remoting.Contexts.Context" />
+ <type fullname="System.Runtime.Remoting.IRemotingTypeInfo" />
+ <type fullname="System.Runtime.Remoting.Messaging" />
+ <type
fullname="System.Runtime.Remoting.Messaging.MonoMethodMessage" />
+ <type fullname="System.Runtime.Remoting.Proxies.RealProxy" />
+ <type
fullname="System.Runtime.Remoting.Proxies.TransparentProxy" />
+ <type fullname="System.Runtime.Serialization.ISerializable" />
+ <type
fullname="System.Runtime.Serialization.SerializationException" />
+ <type fullname="System.Runtime.Serialization.SerializationInfo"
/>
+ <type fullname="System.Runtime.StreamingContext" />
+ <type fullname="System.RuntimeArgumentHandle" />
+ <type fullname="System.RuntimeFieldHandle" />
+ <type fullname="System.RuntimeMethodHandle" />
+ <type fullname="System.RuntimeTypeHandle" />
+ <type fullname="System.SByte" />
+ <type fullname="System.Security.RuntimeSecurityFrame" />
+ <type fullname="System.Security.SecurityException" />
+ <type fullname="System.Security.VerificationException" />
+ <type fullname="System.Single" />
+ <type fullname="System.StackOverflowException" />
+ <type fullname="System.String" />
+ <type fullname="System.SynchronizationLocalException" />
+ <type fullname="System.Text.StringBuilder" />
+ <type fullname="System.Threading.ExecutionContext" />
+ <type fullname="System.Threading.Monitor" />
+ <type fullname="System.Threading.Thread" />
+ <type fullname="System.Threading.ThreadAbortException" />
+ <type fullname="System.Threading.ThreadStateException" />
+ <type fullname="System.Threading.WaitHandle" />
+ <type fullname="System.Type" />
+ <type fullname="System.TypeInitializationException" />
+ <type fullname="System.TypeLoadException" />
+ <type fullname="System.TypedReference" />
+ <type fullname="System.UInt16" />
+ <type fullname="System.UInt32" />
+ <type fullname="System.UInt64" />
+ <type fullname="System.UIntPtr" />
+ <type fullname="System.ValueType" />
+ <type fullname="System.Variant" />
+ <type fullname="System.Void" />
+ </assembly>
+</linker>
Property changes on: trunk/cecil/linker/Descriptors/corlib2.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/cecil/linker/Mono.Linker/Driver.cs
===================================================================
--- trunk/cecil/linker/Mono.Linker/Driver.cs 2006-08-21 09:27:16 UTC (rev
64132)
+++ trunk/cecil/linker/Mono.Linker/Driver.cs 2006-08-21 09:35:51 UTC (rev
64133)
@@ -30,6 +30,8 @@
using System;
using System.Collections;
+ using System.IO;
+ using SR = System.Reflection;
using System.Xml.XPath;
public class Driver {
@@ -113,12 +115,26 @@
}
}
+ if (!context.PreserveCoreLibraries) {
+ p.AddStepBefore (typeof (MarkStep), new
ResolveFromXmlStep (
+ new XPathDocument (
+ GetCorlibDescriptor ())));
+ }
+
if (!resolver)
Usage ();
p.Process(context);
}
+ static Stream GetCorlibDescriptor ()
+ {
+ return SR.Assembly.GetExecutingAssembly
().GetManifestResourceStream (
+ typeof (object).Assembly.GetName
().Version.Major == 2 ?
+ "Mono.Linker.Descriptors.corlib2.xml" :
+ "Mono.Linker.Descriptors.corlib.xml");
+ }
+
static LinkContext GetDefaultContext ()
{
LinkContext context = new LinkContext ();
Modified: trunk/cecil/linker/Mono.Linker/LinkContext.cs
===================================================================
--- trunk/cecil/linker/Mono.Linker/LinkContext.cs 2006-08-21 09:27:16 UTC
(rev 64132)
+++ trunk/cecil/linker/Mono.Linker/LinkContext.cs 2006-08-21 09:35:51 UTC
(rev 64133)
@@ -50,6 +50,10 @@
set { _preserveCoreLibraries = value; }
}
+ public bool OnMono {
+ get { return BaseAssemblyResolver.OnMono (); }
+ }
+
public LinkContext ()
{
_asmCtx = new Hashtable ();
Modified: trunk/cecil/linker/Mono.Linker/MarkStep.cs
===================================================================
--- trunk/cecil/linker/Mono.Linker/MarkStep.cs 2006-08-21 09:27:16 UTC (rev
64132)
+++ trunk/cecil/linker/Mono.Linker/MarkStep.cs 2006-08-21 09:35:51 UTC (rev
64133)
@@ -154,6 +154,10 @@
MarkType (td.DeclaringType);
MarkCustomAttributes(td);
+ if (td.BaseType != null && td.BaseType.FullName ==
"System.MulticastDelegate")
+ foreach (MethodDefinition ctor in
td.Constructors)
+ MarkMethod (ctor);
+
foreach (GenericParameter p in td.GenericParameters)
MarkCustomAttributes (p);
Modified: trunk/cecil/linker/Mono.Linker/SweepStep.cs
===================================================================
--- trunk/cecil/linker/Mono.Linker/SweepStep.cs 2006-08-21 09:27:16 UTC (rev
64132)
+++ trunk/cecil/linker/Mono.Linker/SweepStep.cs 2006-08-21 09:35:51 UTC (rev
64133)
@@ -66,19 +66,10 @@
fieldsUsed.Add (fm.Field.ToString (), fm.Field);
foreach (FieldDefinition field in new ArrayList
(tm.Type.Fields))
- if (!fieldsUsed.Contains (field.ToString ()) &&
CanBeRemoved (field))
+ if (!fieldsUsed.Contains (field.ToString ()))
tm.Type.Fields.Remove (field);
}
- bool CanBeRemoved (FieldDefinition field)
- {
- TypeDefinition declaringType = (TypeDefinition)
field.DeclaringType;
- if (declaringType.IsEnum && field.Name == "value__")
- return false;
-
- return true;
- }
-
void SweepMethods (TypeMarker tm)
{
Hashtable methodsUsed = new Hashtable ();
@@ -86,26 +77,12 @@
methodsUsed.Add (mm.Method.ToString (),
mm.Method);
foreach (MethodDefinition meth in new ArrayList
(tm.Type.Methods))
- if (!methodsUsed.Contains (meth.ToString ()) &&
CanBeRemoved (meth))
+ if (!methodsUsed.Contains (meth.ToString ()))
tm.Type.Methods.Remove (meth);
foreach (MethodDefinition ctor in new ArrayList
(tm.Type.Constructors))
- if (!methodsUsed.Contains (ctor.ToString ()) &&
CanBeRemoved (ctor))
+ if (!methodsUsed.Contains (ctor.ToString ()))
tm.Type.Constructors.Remove (ctor);
}
-
- bool CanBeRemoved (MethodDefinition meth)
- {
- TypeDefinition declaringType = (TypeDefinition)
meth.DeclaringType;
- if (meth.IsVirtual)
- return false;
-
- if (meth.Name == MethodDefinition.Ctor &&
- declaringType.BaseType != null &&
- declaringType.BaseType.FullName ==
"System.MulticastDelegate")
- return false;
-
- return true;
- }
}
}
Modified: trunk/cecil/linker/Mono.Linker.csproj
===================================================================
--- trunk/cecil/linker/Mono.Linker.csproj 2006-08-21 09:27:16 UTC (rev
64132)
+++ trunk/cecil/linker/Mono.Linker.csproj 2006-08-21 09:35:51 UTC (rev
64133)
@@ -71,6 +71,12 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="Descriptors\corlib.xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="Descriptors\corlib2.xml" />
+ </ItemGroup>
+ <ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
\ No newline at end of file
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches