mwccgap is a tool that enables individual functions within a C file to be replaced with assembly code, drawing heavy inspiration from asm-processor.
While the MWCC compiler does support embedding raw assembly within a C file, it requires that all variables and functions be fully defined. This limitation makes the traditional Ship of Theseus approach to matching decompiled code slow and cumbersome.
Unlike asm-processor, which uses a GLOBAL_ASM pragma, mwccgap adopts an INCLUDE_ASM macro to align with the needs of its first supported project, which uses GCC. Future updates may add support for both approaches.
When a function in a C file is marked defined using the INCLUDE_ASM macro, it is replaced with a series of nop instructions of the appropriate size during compilation. The C file is then compiled as usual. Separately, the assembly code for these functions is assembled, and the resulting object data is transplanted back into the C object. Symbols and relocations are updated as needed to ensure correctness.
Any .rodata symbols defined in the assembly code will also be transplanted into the C object.
mwccgap input.c output.o [ -O4,p -sym on ... ]
mwccgap supports the following arguments:
The path to the MWCC executable, defaults to mwccpsp.exe
The path to GNU as, defaults to mipsel-linux-gnu-as
The -march= value to pass to GNU as, defaults to allegrex
The -mabi= value to pass to GNU as, defaults to 32
Whether or not to prefix the call to the MWCC executable with wibo, defaults to false.
Path to wibo (i.e. if wibo is not on your path, or you wish to use wine instead), defaults to wibo.
Optional directory prefix for INCLUDE_ASM files.
Optional path to your macro.inc file.
Optional encoding that the input c file should be converted to, before being passed to the compiler.
Optional path to use when passing data over stdin to interpret relative path include statements.
All additional arguments will be passed to the MWCC executable.
Symbols that start with an @ are not valid syntax. mwccgap will temporarily rename these symbols during processing.
Symbols that contain $ are not valid synctax, mwccgap will temporarily rename these symbols during processing and also mark them as static (i.e. local to the file being compiled).
Known limitations:
.rodataalignment set to0x8for allINCLUDE_RODATAsections.
This project is in its infancy and is full of assumptions, and therefore likely riddled with bugs; PRs are welcomed!
Projects that use mwccgap include: