diff options
author | Zoltan Varga <vargaz@gmail.com> | 2020-02-23 01:34:00 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-23 01:34:00 +0300 |
commit | cc8a5b5513aa0789f50c83686f72e702dba73d56 (patch) | |
tree | cc25c7522bc7ad8e79b47d5b2d9a6594e968d61c /mcs | |
parent | 008a10c43af0cdb257b58ee14cf3dc0225bda769 (diff) |
[corlib] Link out more SR/SRE types (#18770)
* [corlib] Invoke TypeBuilderInstantiation.MakeGenericType through a delegate created in the TypeBuilder ctor to break a linker dependency between RuntimeType and TypeBuilderInstantiation.
* [corlib] Update linker descriptor.
* UnmanagedMarshal is not used from native code at all.
* AssemblyName is not used from native code at all.
Diffstat (limited to 'mcs')
-rw-r--r-- | mcs/class/corlib/LinkerDescriptor/mscorlib.xml | 6 | ||||
-rw-r--r-- | mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs | 11 | ||||
-rw-r--r-- | mcs/class/referencesource/mscorlib/system/rttype.cs | 13 |
3 files changed, 14 insertions, 16 deletions
diff --git a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml index cc06dbfe9e8..8768d2f3106 100644 --- a/mcs/class/corlib/LinkerDescriptor/mscorlib.xml +++ b/mcs/class/corlib/LinkerDescriptor/mscorlib.xml @@ -541,8 +541,6 @@ <!-- appdomain.c: ves_icall_System_AppDomain_GetAssemblies --> <type fullname="System.Reflection.Assembly" preserve="fields"/> - <type fullname="System.Reflection.AssemblyName" preserve="fields" /> - <type fullname="System.Reflection.EventInfo" preserve="fields"> <method name="AddEventFrame" /> <method name="StaticAddEventAdapterFrame" /> @@ -656,10 +654,6 @@ <!-- reflection.c mono_reflection_call_is_assignable_to () --> <method name="IsAssignableTo" feature="sre" /> </type> - <type fullname="System.Reflection.Emit.UnmanagedMarshal" preserve="fields" feature="sre" > - <method name="DefineCustom" feature="sre" /> - <method name="DefineLPArrayInternal" feature="sre" /> - </type> <type fullname="System.Reflection.Emit.ArrayType" preserve="fields" feature="sre" /> <type fullname="System.Reflection.Emit.ByRefType" preserve="fields" feature="sre" /> <type fullname="System.Reflection.Emit.PointerType" preserve="fields" feature="sre" /> diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs index cc943475316..c2c6135bde3 100644 --- a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs +++ b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs @@ -120,8 +120,15 @@ namespace System.Reflection.Emit return attrs; } + TypeBuilder () + { + // Use this delegate to avoid a linker dependency between RuntimeType and SRE code when SRE is not used + if (RuntimeType.MakeTypeBuilderInstantiation == null) + RuntimeType.MakeTypeBuilderInstantiation = System.Reflection.Emit.TypeBuilderInstantiation.MakeGenericType; + } + [PreserveDependency ("DoTypeBuilderResolve", "System.AppDomain")] - internal TypeBuilder (ModuleBuilder mb, TypeAttributes attr, int table_idx) + internal TypeBuilder (ModuleBuilder mb, TypeAttributes attr, int table_idx) : this () { this.parent = null; this.attrs = attr; @@ -133,7 +140,7 @@ namespace System.Reflection.Emit pmodule = mb; } - internal TypeBuilder (ModuleBuilder mb, string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packing_size, int type_size, Type nesting_type) + internal TypeBuilder (ModuleBuilder mb, string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packing_size, int type_size, Type nesting_type) : this () { int sep_index; this.parent = ResolveUserType (parent); diff --git a/mcs/class/referencesource/mscorlib/system/rttype.cs b/mcs/class/referencesource/mscorlib/system/rttype.cs index 5184305c5aa..6e3ab286e89 100644 --- a/mcs/class/referencesource/mscorlib/system/rttype.cs +++ b/mcs/class/referencesource/mscorlib/system/rttype.cs @@ -4298,6 +4298,10 @@ namespace System return types; } + // Points to System.Reflection.Emit.TypeBuilderInstantiation.MakeGenericType + // Initialized when a TypeBuilder is created to avoid link-time SRE dependencies in this file + internal static Func<Type, Type[], Type> MakeTypeBuilderInstantiation; + [System.Security.SecuritySafeCritical] // auto-generated public override Type MakeGenericType(Type[] instantiation) { @@ -4338,7 +4342,7 @@ namespace System #pragma warning disable 162 if (!RuntimeFeature.IsDynamicCodeSupported) throw new PlatformNotSupportedException(); - return MakeTypeBuilderInstantiation(instantiation); + return MakeTypeBuilderInstantiation(this, instantiation); #pragma warning restore 162 #endif } @@ -4369,13 +4373,6 @@ namespace System return ret; } -#if !NETCORE - Type MakeTypeBuilderInstantiation(Type[] instantiation) - { - return System.Reflection.Emit.TypeBuilderInstantiation.MakeGenericType(this, instantiation); - } -#endif - public override bool IsGenericTypeDefinition { get { return RuntimeTypeHandle.IsGenericTypeDefinition(this); } |