Skip to content

3. Creating a Custom Decompiler

If you need to integrate a custom decompiler, you can extend CodableLLM by creating your own decompiler class.

All custom decompilers must subclass Decompiler, which defines the interface for extracting decompiled functions from binaries.

Method to Implement

You must override the decompile method in your custom decompiler. The decompile method decompiles a binary and returns a sequence of DecompiledFunction instances extracted from it.

Example: Creating a Custom Decompiler

Below is a template for defining your own decompiler.

Creating Your Custom Decompiler Class

from pathlib import Path
from typing import Sequence

from codablellm import decompiler
from codablellm.core.function import DecompiledFunction

class CustomDecompiler(Decompiler):
    '''
    Decompiler for extracting functions from Custom binaries.
    '''

    def decompile(self, path: Path | str) -> Sequence[DecompiledFunction]:
        # Implementation goes here: decompile the binary and return DecompiledFunction objects
        pass

Setting Your Custom Decompiler

Once your decompiler is implemented, you must set it as CodableLLM's decompiler:

from codablellm import decompiler

decompiler.set_decompiler('classpath.to.CustomDecompiler')