rizin icon indicating copy to clipboard operation
rizin copied to clipboard

Initialize RzIL VM when opening a core dump

Open Rot127 opened this issue 3 months ago • 2 comments

Is your feature request related to a problem? Please describe.

Once we have the RzIL analysis implemented the VM should be updated with information with from a core dump. This is useful, because it enables easy analysis with via RzIL. And skips our somewhat buggy debugging code.

Describe the solution you'd like

Currently the register state is restored from the core dump is done here: https://github.com/rizinorg/rizin/blob/095d53a075fb2c6239d91a70e925940269976d87/librz/core/cfile.c#L1109-L1113

But it just memcpy the bytes and can't handle register files which might have different orders. This is buggy for floating point registers and some OS (OpenBSD) doesn't share the same reg file layout with Linux.

Also the debug register file can be different from the VM one. So the coredump regs should be restored additionally in the RzIL VM for further analysis. Preferably in a user defined manner.

Describe alternatives you've considered

Fixing the RzBin code and restore the registers properly there. Then init the VM from it.

Additional context

Related because it documents broken handling of floating point register: https://github.com/rizinorg/rizin/issues/5334

Rot127 avatar Sep 02 '25 20:09 Rot127

I think implementing parsing properly in the RzDebug/RzBin is a cleaner solution, though. Not sure how RzIL could help for this task, to be honest. Could you please share the details?

notxvilka avatar Sep 03 '25 16:09 notxvilka

The core dump is essentially a snapshot of the machine state. The RzBin/RzDebug plugin just doesn't handle most of it. For example, Sparc can save and restore register files (usually up to 8). But RzDebug doesn't really have the concept of stored register files. Because they are inherently a dynamic property of the machine.

For these things it would make sense to directly init a VM.

Rot127 avatar Sep 03 '25 19:09 Rot127