Skip to content

Commit b8b3bf2

Browse files
Report RhpInitialDynamicInterfaceDispatch reference in gfids (#103948)
Some subset of tests is failing with control flow guard enabled because we're not able to indirectly call `RhpInitialDynamicInterfaceDispatch`. It's not clear why since we address take this method in C++ source files as well, but we should be reporting this from our object file too and doing that fixes it.
1 parent c5e8f83 commit b8b3bf2

File tree

6 files changed

+21
-41
lines changed

6 files changed

+21
-41
lines changed

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/ExternSymbolNode.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,12 @@ public override string ToString()
5555
return _name.ToString();
5656
}
5757
}
58+
59+
public class AddressTakenExternSymbolNode : ExternSymbolNode
60+
{
61+
public AddressTakenExternSymbolNode(Utf8String name)
62+
: base(name) { }
63+
64+
public override int ClassCode => -45645737;
65+
}
5866
}

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/InterfaceDispatchCellNode.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,7 @@ public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFacto
6161

6262
factory.MetadataManager.GetDependenciesDueToVirtualMethodReflectability(ref result, factory, _targetMethod);
6363

64-
TargetArchitecture targetArchitecture = factory.Target.Architecture;
65-
if (targetArchitecture == TargetArchitecture.ARM)
66-
{
67-
result.Add(factory.InitialInterfaceDispatchStub, "Initial interface dispatch stub");
68-
}
69-
else
70-
{
71-
result.Add(factory.ExternSymbol("RhpInitialDynamicInterfaceDispatch"), "Initial interface dispatch stub");
72-
}
64+
result.Add(factory.InitialInterfaceDispatchStub, "Initial interface dispatch stub");
7365

7466
// We counter-intuitively ask for a constructed type symbol. This is needed due to IDynamicInterfaceCastable.
7567
// If this dispatch cell is ever used with an object that implements IDynamicIntefaceCastable, user code will
@@ -81,15 +73,7 @@ public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFacto
8173

8274
public override void EncodeData(ref ObjectDataBuilder objData, NodeFactory factory, bool relocsOnly)
8375
{
84-
TargetArchitecture targetArchitecture = factory.Target.Architecture;
85-
if (targetArchitecture == TargetArchitecture.ARM)
86-
{
87-
objData.EmitPointerReloc(factory.InitialInterfaceDispatchStub);
88-
}
89-
else
90-
{
91-
objData.EmitPointerReloc(factory.ExternSymbol("RhpInitialDynamicInterfaceDispatch"));
92-
}
76+
objData.EmitPointerReloc(factory.InitialInterfaceDispatchStub);
9377

9478
// We counter-intuitively ask for a constructed type symbol. This is needed due to IDynamicInterfaceCastable.
9579
// If this dispatch cell is ever used with an object that implements IDynamicIntefaceCastable, user code will

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/NodeFactory.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public NodeFactory(
4444
ObjectDataInterner dataInterner)
4545
{
4646
_target = context.Target;
47+
48+
InitialInterfaceDispatchStub = _target.Architecture == TargetArchitecture.ARM
49+
? new InitialInterfaceDispatchStubNode()
50+
: new AddressTakenExternSymbolNode("RhpInitialDynamicInterfaceDispatch");
51+
4752
_context = context;
4853
_compilationModuleGroup = compilationModuleGroup;
4954
_vtableSliceProvider = vtableSliceProvider;
@@ -102,6 +107,11 @@ public NameMangler NameMangler
102107
get;
103108
}
104109

110+
public ISymbolNode InitialInterfaceDispatchStub
111+
{
112+
get;
113+
}
114+
105115
public PreinitializationManager PreinitializationManager
106116
{
107117
get;

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/Target_ARM/ARMNodeFactory.cs

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ObjectWriter/ObjectWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ private void EmitObject(string objectFilePath, IReadOnlyCollection<DependencyNod
469469
relocTarget.Offset);
470470

471471
if (_options.HasFlag(ObjectWritingOptions.ControlFlowGuard) &&
472-
relocTarget is IMethodNode or AssemblyStubNode)
472+
relocTarget is IMethodNode or AssemblyStubNode or AddressTakenExternSymbolNode)
473473
{
474474
// For now consider all method symbols address taken.
475475
// We could restrict this in the future to those that are referenced from

src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@
530530
<Compile Include="Compiler\DependencyAnalysis\StringAllocatorMethodNode.cs" />
531531
<Compile Include="Compiler\DependencyAnalysis\Target_X64\X64ReadyToRunGenericHelperNode.cs" />
532532
<Compile Include="Compiler\DependencyAnalysis\Target_ARM\ARMInitialInterfaceDispatchStubNode.cs" />
533-
<Compile Include="Compiler\DependencyAnalysis\Target_ARM\ARMNodeFactory.cs" />
534533
<Compile Include="Compiler\DependencyAnalysis\VTableSliceNode.cs" />
535534
<Compile Include="Compiler\DependencyAnalysis\EETypeOptionalFieldsNode.cs" />
536535
<Compile Include="Compiler\DependencyAnalysis\EmbeddedObjectNode.cs" />

0 commit comments

Comments
 (0)