Skip to content

Commit

Permalink
Report RhpInitialDynamicInterfaceDispatch reference in gfids (#103948)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MichalStrehovsky authored Jun 25, 2024
1 parent c5e8f83 commit b8b3bf2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@ public override string ToString()
return _name.ToString();
}
}

public class AddressTakenExternSymbolNode : ExternSymbolNode
{
public AddressTakenExternSymbolNode(Utf8String name)
: base(name) { }

public override int ClassCode => -45645737;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,7 @@ public override IEnumerable<DependencyListEntry> GetStaticDependencies(NodeFacto

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

TargetArchitecture targetArchitecture = factory.Target.Architecture;
if (targetArchitecture == TargetArchitecture.ARM)
{
result.Add(factory.InitialInterfaceDispatchStub, "Initial interface dispatch stub");
}
else
{
result.Add(factory.ExternSymbol("RhpInitialDynamicInterfaceDispatch"), "Initial interface dispatch stub");
}
result.Add(factory.InitialInterfaceDispatchStub, "Initial interface dispatch stub");

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

public override void EncodeData(ref ObjectDataBuilder objData, NodeFactory factory, bool relocsOnly)
{
TargetArchitecture targetArchitecture = factory.Target.Architecture;
if (targetArchitecture == TargetArchitecture.ARM)
{
objData.EmitPointerReloc(factory.InitialInterfaceDispatchStub);
}
else
{
objData.EmitPointerReloc(factory.ExternSymbol("RhpInitialDynamicInterfaceDispatch"));
}
objData.EmitPointerReloc(factory.InitialInterfaceDispatchStub);

// We counter-intuitively ask for a constructed type symbol. This is needed due to IDynamicInterfaceCastable.
// If this dispatch cell is ever used with an object that implements IDynamicIntefaceCastable, user code will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public NodeFactory(
ObjectDataInterner dataInterner)
{
_target = context.Target;

InitialInterfaceDispatchStub = _target.Architecture == TargetArchitecture.ARM
? new InitialInterfaceDispatchStubNode()
: new AddressTakenExternSymbolNode("RhpInitialDynamicInterfaceDispatch");

_context = context;
_compilationModuleGroup = compilationModuleGroup;
_vtableSliceProvider = vtableSliceProvider;
Expand Down Expand Up @@ -102,6 +107,11 @@ public NameMangler NameMangler
get;
}

public ISymbolNode InitialInterfaceDispatchStub
{
get;
}

public PreinitializationManager PreinitializationManager
{
get;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private void EmitObject(string objectFilePath, IReadOnlyCollection<DependencyNod
relocTarget.Offset);

if (_options.HasFlag(ObjectWritingOptions.ControlFlowGuard) &&
relocTarget is IMethodNode or AssemblyStubNode)
relocTarget is IMethodNode or AssemblyStubNode or AddressTakenExternSymbolNode)
{
// For now consider all method symbols address taken.
// We could restrict this in the future to those that are referenced from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@
<Compile Include="Compiler\DependencyAnalysis\StringAllocatorMethodNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\Target_X64\X64ReadyToRunGenericHelperNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\Target_ARM\ARMInitialInterfaceDispatchStubNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\Target_ARM\ARMNodeFactory.cs" />
<Compile Include="Compiler\DependencyAnalysis\VTableSliceNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\EETypeOptionalFieldsNode.cs" />
<Compile Include="Compiler\DependencyAnalysis\EmbeddedObjectNode.cs" />
Expand Down

0 comments on commit b8b3bf2

Please sign in to comment.