MWCC is a commercial compiler by Metrowerks (now owned by Freescale) as part of the CodeWarrior line of compilers and tools available for a large number of platforms. It is a proprietary compiler platform, unlike GCC, which was licensed out to developers for use on their respective consoles.
A decompilation of the GC MWCC compiler is underway.
For unstripped binaries, some versions of the linker (MWLD) may include a comment string in a .comment
section that can be used to indentify that the binary has been linked with a Metrowerks linker. An example of such a string on the PS2 is the following: MW MIPS C Compiler (2.4.1.01)
. Note that this does not identify the exact version of MWCC used, as this version number is generated by MWLD and a version number was often shared by multiple releases of CodeWarrior. Further investigation will be required to identify the exact compiler version used.
This section is not present in GameCube releases of MWCC.
The default linker script for PS2 MWLD joins the text, data, and rodata sections into a single section called main
. This can be an indicator that the binary may have been linked by MWLD.
Overlays can be identified by their headers which start with an MWo
identifier.
For PS2 ELF binaries that have been compiled with debug information that has not been stripped the information is stored in a .debug
section containing DWARF 1 format debug information.
GameCube/Wii releases of MWCC supported generating debug information in both DWARF 1 format as well as DWARF 2 as of version 3.0. DWARF 1 and 2 debug information utilize a different structure of sections in the linked binary.
.comment
MW compiler string..comment
MW compiler string..comment
MW compiler string..comment
MW compiler string..comment
MW compiler string..comment
MW compiler string..comment
MW compiler string (found in SLUS-20767)..comment
MW compiler string (found in SLES_50412).In cases where matching a greater/lesser than if conditional that uses the AT
register rather than a standard variable register, it may be required to swap the positions of the literal and the variable.
For example, take the following C code:
Example C:
if (tmp >= 0x100) {
tmp = 0xFF;
}
The above C code will generate MIPS asm that makes use of an available variable register by default. However, in order to produce the AT
register to be used, the C will need to be adjusted to the following:
if (0xFF < tmp) {
tmp = 0xFF;
}
And here is a comparison of the two conditionals and the MIPS assembly output:
if (tmp >= 0x100) | if (0xFF < tmp) |
---|---|
slti v0,s0,0x100 bnez at,40 nop |
slti at,s0,0x100 bnez at,40 nop |