revng / revng

revng: the core repository of the rev.ng project

Home Page:https://rev.ng/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for loading object files (and kernel modules)

darkstar opened this issue · 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

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.

Here is an example object file
object.ko.zip