Skip to content

Commit a40e1f3

Browse files
committed
[RISC-V] Enable R2RDump
1 parent 2e595fb commit a40e1f3

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/coreclr/tools/r2rdump/CoreDisTools.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ public enum TargetArch
2222
Target_X64,
2323
Target_Thumb,
2424
Target_Arm64,
25-
Target_LoongArch64
25+
Target_LoongArch64,
26+
Target_RiscV64,
2627
};
2728

2829
[DllImport(_dll, CallingConvention = CallingConvention.Cdecl)]
@@ -77,6 +78,9 @@ public static IntPtr GetDisasm(Machine machine)
7778
case Machine.LoongArch64:
7879
target = TargetArch.Target_LoongArch64;
7980
break;
81+
case Machine.RiscV64:
82+
target = TargetArch.Target_RiscV64;
83+
break;
8084
default:
8185
Program.WriteWarning($"{machine} not supported on CoreDisTools");
8286
return IntPtr.Zero;
@@ -191,6 +195,10 @@ private void SetIndentations()
191195
// Instructions are dumped as 4-byte hexadecimal integers
192196
Machine.LoongArch64 => 4 * 2 + 1,
193197

198+
// Instructions are dumped as 4-byte hexadecimal integers
199+
// TODO: update once RISC-V runtime supports "C" extension (compressed instructions)
200+
Machine.RiscV64 => 4 * 2 + 1,
201+
194202
_ => throw new NotImplementedException()
195203
};
196204

@@ -260,7 +268,8 @@ public int GetInstruction(RuntimeFunction rtf, int imageOffset, int rtfOffset, o
260268
}
261269
else
262270
{
263-
if ((_reader.Machine == Machine.Arm64) || (_reader.Machine == Machine.LoongArch64))
271+
// TODO: update once RISC-V runtime supports "C" extension (compressed instructions)
272+
if (_reader.Machine is Machine.Arm64 or Machine.LoongArch64 or Machine.RiscV64)
264273
{
265274
// Replace " hh hh hh hh " byte dump with " hhhhhhhh ".
266275
// CoreDisTools should be fixed to dump bytes this way for ARM64.

src/coreclr/tools/r2rdump/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ public void Dump(ReadyToRunReader r2r)
210210
Machine.ArmThumb2 => TargetArchitecture.ARM,
211211
Machine.Arm64 => TargetArchitecture.ARM64,
212212
Machine.LoongArch64 => TargetArchitecture.LoongArch64,
213+
Machine.RiscV64 => TargetArchitecture.RiscV64,
213214
_ => throw new NotImplementedException(r2r.Machine.ToString()),
214215
};
215216
TargetOS os = r2r.OperatingSystem switch

src/coreclr/tools/r2rdump/R2RDump.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<AssemblyVersion>1.0.0.0</AssemblyVersion>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<OutputType>Exe</OutputType>
7-
<Platforms>x64;x86;arm64;arm;loongarch64</Platforms>
7+
<Platforms>x64;x86;arm64;arm;loongarch64;riscv64</Platforms>
88
<AssemblyKey>Open</AssemblyKey>
99
<IsDotNetFrameworkProductAssembly>true</IsDotNetFrameworkProductAssembly>
1010
<TargetFramework>$(NetCoreAppToolCurrent)</TargetFramework>

0 commit comments

Comments
 (0)