Tool:Metrowerks CodeWarrior
| Vendor | Metrowerks (Freescale, NXP) |
|---|---|
| Platforms | Platform:Nintendo GameCube, Wii, Nintendo DS, PlayStation 2, PSP, embedded PowerPC |
| Versions | GameCube compilers GC/1.0-GC/3.0 (e.g. GC/1.2.5n, GC/1.3, GC/1.3.2); Wii GC/3.x and Wii/1.x |
| On this wiki | Facts · Code · Notes · Topics |
Metrowerks' C/C++ compiler suite (later Freescale), the standard compiler of GameCube, Wii, DS and many PowerPC embedded targets. Its C++ name mangling (name__<len>ClassF<params>), its PowerPC EABI runtime (_savegpr_14.._savegpr_31, __ptmf_*, __init_cpp) and the "CodeWarrior" .comment record in object files identify its output.
Overview
CodeWarrior for GameCube (mwcceppc.exe, mwldeppc.exe) is a Win32 command-line toolchain. Matching decompilations run the original compiler versions (through wibo on Linux/macOS) because each version schedules and allocates registers differently: Software:The Legend of Zelda: The Wind Waker uses GC/1.3.2 for most code, GC/1.2.5n and GC/1.3 for some libraries (configure.py in zeldaret/tww). Typical flags there: -proc gekko -fp hardware -align powerpc -enum int -Cpp_exceptions off -RTTI off -inline auto -str reuse.
Name mangling
CodeWarrior uses a cfront/ARM-style scheme, unlike both MSVC (?name@@..., see Platform:Microsoft Visual C++ ABI/Name decoration) and the Itanium ABI of GCC and Clang (_Z..., see Platform:Itanium C++ ABI/Name mangling):
function__F<params>for a free function:__nw__FUl=operator new(unsigned long),__dl__FPv=operator delete(void*).method__<len><Class>F<params>:decodeSZS__9JKRDecompFPUcPUcUlUl=JKRDecomp::decodeSZS(unsigned char*, unsigned char*, unsigned long, unsigned long);CbeforeFmarks a const method (__ml__4cXyzCFf).- Nested names:
Q<count>+ length-prefixed parts:store__Q210JKRArchive8CArcNameFPCcc=JKRArchive::CArcName::store(const char*, char). - Special names:
__ctconstructor,__dtdestructor,__asoperator=,__mloperator*,__ploperator+,__nw/__dlnew/delete;__vt__<len><Class>is a vtable,__RTTI__<len><Class>RTTI (absent when compiled with-RTTI off),__sinit_<file>_cppa file's static initializer. - Templates keep their arguments literally in the name and the length counts them:
34JPACallBackBase<P14JPABaseEmitter>(34 characters),cLib_calcTimer<Uc>__FPUc. - Types:
vvoid,cchar,sshort,iint,llong,xlong long,ffloat,ddouble,bbool,wwchar_t,Uunsigned,Ssigned,Ppointer,Rreference,Cconst,A<n>_array,F...function type.
Compiler-generated locals appear in symbol maps as @1234 (string and float constants, @etb_/@eti_ exception table entries).
Runtime
The PowerPC EABI runtime (Runtime/Src/runtime.c) provides register save/restore stubs that functions call instead of stmw/lmw when many non-volatile registers are live: _savegpr_14 .. _savegpr_31 and _restgpr_14 .. _restgpr_31 are entry points into one sequence of stw rN, -(32-N)*4(r11) (and lwz) ending in blr; _savefpr_14/_restfpr_14 do the same for FPRs. Pointer-to-member helpers are __ptmf_test, __ptmf_cmpr, __ptmf_scall. Byte signatures for the GPR stubs are facts of this page.
Object files
CodeWarrior ELF objects carry a .comment section starting with the 11 bytes CodeWarrior, a format version byte (8, 10, 11, 13, 14 or 15 accepted by decomp-toolkit) and a 4-byte compiler version, followed by one entry per symbol (decomp-toolkit src/util/comment.rs). dtk's mw_comment_version setting (10 = GC Linker 1.3.2 in zeldaret/tww) recreates it so that objdiff can match objects.
Code & repositories
- https://github.com/encounter/decomp-toolkit @
0645e16511814920ffb05b25615dd71f1af73e4c· license: Apache-2.0
decomp-toolkit (dtk, Rust, MIT OR Apache-2.0): splits GameCube/Wii DOLs and RELs into objects for matching decompilations, reads and writes DOL, REL, RARC, U8, Yaz0/Yay0 and the CodeWarrior .comment section, and generates symbols.txt/splits.txt configurations.
Tested on: Read at commit 0645e16: src/util/dol.rs (DolHeader), src/util/rel.rs (R_DOLPHIN_* types), src/util/rarc.rs, src/util/comment.rs; not built. · checked 2026-10-17; last activity 2026-09-10; Note: the latest release ships binaries; the wiki links only the source, never the binaries