revng icon indicating copy to clipboard operation
revng copied to clipboard

Add support for loading object files (and kernel modules)

Open darkstar opened this issue 1 year ago • 2 comments

revng currently doesn't seem to recognize ELF kernel modules:

[orchestra] [darkstar@shiina revng]$ ./revng artifact --analyze --progress decompile-to-single-file ../maytag.ko 
[=======================================] 100% 0.57s Analysis list revng-initial-auto-analysis (5): import-binary
[===================>                   ]  50% 0.57s Run analyses lists (2): revng-initial-auto-analysis
[=========>                             ]  25% 0.57s revng-artifact (2): Run analyses
Only ELF executables and ELF dynamic libraries are supported

[orchestra] [darkstar@shiina revng]$ file ../maytag.ko 
../maytag.ko: ELF 64-bit LSB relocatable, x86-64, version 1 (FreeBSD), not stripped

[orchestra] [darkstar@shiina revng]$ ./revng --version
rev.ng version @VERSION@

The --version output doesn't seem very helpful

darkstar avatar Mar 29 '24 13:03 darkstar

Can you attach any FreeBSD kernel module?

The Linux kernel modules seem to be object files. They contain relocations targeting .text, which are not easy to handle.

I think a roadmap for this would be:

  1. Add support for loading from section list, instead than using program headers.
  2. Perform the linking phase, i.e., apply the relocations, making up the locations of the symbols we depend upon.

Doing 1) is rather easy and could start showing some decompiled code, hopefully.

aleclearmind avatar Apr 03 '24 14:04 aleclearmind

Here is an example object file object.ko.zip

darkstar avatar Apr 03 '24 18:04 darkstar