_sectionContents = true;
}
- _disasm = false; // TODO: this requires the coredistools nuget package with the most recent changes
-
return argSyntax;
}
if (_disasm)
{
- disassembler = new Disassembler(r2r.Image, r2r.Machine);
+ // TODO: Fix R2RDump issue where an x64 R2R image cannot be dissassembled with the x86 CoreDisTools
+ // For the short term, we want to error out with a decent message explaining the unexpected error
+ // Issue #19564: https://github.com/dotnet/coreclr/issues/19564
+ if (r2r.InputArchitectureMatchesDisassemblerArchitecture())
+ {
+ disassembler = new Disassembler(r2r.Image, r2r.Machine);
+ }
+ else
+ {
+ throw new ArgumentException($"The architecture of input file {filename} is {r2r.Machine.ToString()} and does not match the architecture of the disassembler tools {System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString()}");
+ }
}
if (_xml)
-<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
<PropertyGroup>
<AssemblyName>R2RDump</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>Exe</OutputType>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <AssemblyKey>Open</AssemblyKey>
- <IsDotNetFrameworkProductAssembly>true</IsDotNetFrameworkProductAssembly>
- <TargetFramework>netcoreapp2.0</TargetFramework>
- <RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
- <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
- <CLSCompliant>false</CLSCompliant>
- <NoWarn>8002,NU1701</NoWarn>
+ <AssemblyKey>Open</AssemblyKey>
+ <IsDotNetFrameworkProductAssembly>true</IsDotNetFrameworkProductAssembly>
+ <TargetFramework>netcoreapp2.0</TargetFramework>
+ <RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
+ <TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
+ <CLSCompliant>false</CLSCompliant>
+ <NoWarn>8002,NU1701</NoWarn>
+ <RuntimeIdentifiers>win-x64;win-x86</RuntimeIdentifiers>
</PropertyGroup>
+
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.CoreDisTools">
- <Version>1.0.1-prerelease-00003</Version>
+ <Version>1.0.1-prerelease-00005</Version>
</PackageReference>
<PackageReference Include="System.CommandLine">
<Version>0.1.0-e160119-1</Version>
}
}
+ public bool InputArchitectureMatchesDisassemblerArchitecture()
+ {
+ System.Runtime.InteropServices.Architecture val = System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture;
+ switch (Machine)
+ {
+ case Machine.Amd64:
+ return val == System.Runtime.InteropServices.Architecture.X64;
+ case Machine.I386:
+ return val == System.Runtime.InteropServices.Architecture.X86;
+ case Machine.Arm64:
+ return val == System.Runtime.InteropServices.Architecture.Arm64;
+ case Machine.ArmThumb2:
+ return val == System.Runtime.InteropServices.Architecture.Arm;
+ default:
+ return false;
+ }
+ }
+
/// <summary>
/// Each runtime function entry has 3 fields for Amd64 machines (StartAddress, EndAddress, UnwindRVA), otherwise 2 fields (StartAddress, UnwindRVA)
/// </summary>