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

github.com/mono/linker.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/linker
diff options
context:
space:
mode:
authorSwaroop Sridhar <swaroops@microsoft.com>2017-04-24 23:57:24 +0300
committerMarek Safar <marek.safar@gmail.com>2017-04-25 10:47:15 +0300
commit33c1b81a2906d5dade470bbd8a4caeaac5f84cd0 (patch)
treeb519acc1879c33e5ae720a35d3b134120103cd47 /linker
parentc6e16db810411c8f16cbd4b34f96545eebbfd67e (diff)
Fix marking of FunctionPointer Types
The MarkStep doesn't handle function pointer types correctly. For example, the linker crashes while marking the method Fnxn. .method int32 Fnxn(method explicit instance int32 *(int32), int32) { ... } This change fixes the bug in MarkStep.
Diffstat (limited to 'linker')
-rw-r--r--linker/Mono.Linker.Steps/MarkStep.cs26
1 files changed, 24 insertions, 2 deletions
diff --git a/linker/Mono.Linker.Steps/MarkStep.cs b/linker/Mono.Linker.Steps/MarkStep.cs
index 9aab4a102..2d5f508b8 100644
--- a/linker/Mono.Linker.Steps/MarkStep.cs
+++ b/linker/Mono.Linker.Steps/MarkStep.cs
@@ -544,11 +544,14 @@ namespace Mono.Linker.Steps {
reference = GetOriginalType (reference);
+ if (reference is FunctionPointerType)
+ return null;
+
if (reference is GenericParameter)
return null;
// if (IgnoreScope (reference.Scope))
-// return;
+// return null;
TypeDefinition type = ResolveTypeDefinition (reference);
@@ -1029,12 +1032,31 @@ namespace Mono.Linker.Steps {
if (mod != null)
MarkModifierType (mod);
- type = ((TypeSpecification) type).ElementType;
+ var fnptr = type as FunctionPointerType;
+ if (fnptr != null) {
+ MarkParameters (fnptr);
+ MarkType (fnptr.ReturnType);
+ break; // FunctionPointerType is the original type
+ }
+ else {
+ type = ((TypeSpecification) type).ElementType;
+ }
}
return type;
}
+ void MarkParameters (FunctionPointerType fnptr)
+ {
+ if (!fnptr.HasParameters)
+ return;
+
+ for (int i = 0; i < fnptr.Parameters.Count; i++)
+ {
+ MarkType (fnptr.Parameters[i].ParameterType);
+ }
+ }
+
void MarkModifierType (IModifierType mod)
{
MarkType (mod.ModifierType);