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 compiled, and the resulting object data is transplanted back into the C object. Symbols and relocations are updated as needed to ensure correctness.
Any .rodata sections within 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 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.
All additional arguments will be passed to the MWCC executable.
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: