Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ public SimpleAssemblyMetadata(string path)
_peReader = new PEReader(new MemoryStream(imageBytes));
}

public PEReader ImageReader => _peReader;
public BlobReader GetSectionData(int relativeVirtualAddress) => _peReader.GetSectionData(relativeVirtualAddress).GetReader();

public MetadataReader MetadataReader => _peReader.GetMetadataReader();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace ILCompiler.Reflection.ReadyToRun
/// </summary>
public interface IAssemblyMetadata
{
PEReader ImageReader { get; }

BlobReader GetSectionData(int relativeVirtualAddress);
MetadataReader MetadataReader { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<Compile Include="..\..\Common\Internal\Runtime\ReadyToRunInstructionSet.cs" Link="Common\ReadyToRunInstructionSet.cs" />
<Compile Include="..\..\Common\MachO\**\*.cs" Link="MachO\%(RecursiveDir)%(Filename)%(Extension)" />
<Compile Include="..\..\Common\Pgo\PgoFormat.cs" Link="Common\PgoFormat.cs" />
<Compile Include="..\..\Common\Wasm\Webcil.cs" Link="Webcil\Webcil.cs" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ public ManifestAssemblyMetadata(PEReader peReader, MetadataReader metadataReader
_peReader = peReader;
}

public PEReader ImageReader => _peReader;
public BlobReader GetSectionData(int relativeVirtualAddress)
{
if (_peReader is null)
return default;
return _peReader.GetSectionData(relativeVirtualAddress).GetReader();
}

public MetadataReader MetadataReader => _metadataReader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,15 @@ public ReadyToRunMethod(
MethodDefinition methodDef = ComponentReader.MetadataReader.GetMethodDefinition((MethodDefinitionHandle)MethodHandle);
if (methodDef.RelativeVirtualAddress != 0)
{
System.Diagnostics.Debug.Assert(ComponentReader.ImageReader != null, "Component should be a PE and have an associated PEReader");
MethodBodyBlock mbb = ComponentReader.ImageReader.GetMethodBody(methodDef.RelativeVirtualAddress);
if (!mbb.LocalSignature.IsNil)
BlobReader sectionData = ComponentReader.GetSectionData(methodDef.RelativeVirtualAddress);
if (sectionData.Length > 0)
{
StandaloneSignature ss = ComponentReader.MetadataReader.GetStandaloneSignature(mbb.LocalSignature);
LocalSignature = ss.DecodeLocalSignature(typeProvider, genericContext);
MethodBodyBlock mbb = MethodBodyBlock.Create(sectionData);
if (!mbb.LocalSignature.IsNil)
{
StandaloneSignature ss = ComponentReader.MetadataReader.GetStandaloneSignature(mbb.LocalSignature);
LocalSignature = ss.DecodeLocalSignature(typeProvider, genericContext);
}
}
}
Name = ComponentReader.MetadataReader.GetString(methodDef.Name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@ private unsafe void Initialize(IAssemblyMetadata metadata)
{
CompositeReader = new MachO.MachOImageReader(image);
}
else if (WebcilImageReader.IsWebcilImage(image))
{
CompositeReader = new WebcilImageReader(image);
}
Comment on lines +504 to +507
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a future problem.

else
{
CompositeReader = new PEImageReader(new PEReader(Unsafe.As<byte[], ImmutableArray<byte>>(ref image)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public StandaloneAssemblyMetadata(PEReader peReader)
_metadataReader = _peReader.GetMetadataReader();
}

public PEReader ImageReader => _peReader;
public BlobReader GetSectionData(int relativeVirtualAddress) => _peReader.GetSectionData(relativeVirtualAddress).GetReader();

public MetadataReader MetadataReader => _metadataReader;
}
Expand Down
Loading
Loading