Watcom's Name-Mangleing

tmbinc/daze

(Version 0.1, INCOMPLETE!)

Certainly you have met symbol names like W?test$:test_c$n(ipipipipi)v and wondered what they actually meant... Maybe you also realized that they are just normal C++ symbols which were mangled. This is used for distinguishing an array from a variable with the same name.

"Then", in the good(?), old, normal C nothing like this existed. So sometimes an array was linked in where actually a variable should be linked in. This caused a total chaos and crashing programs ("That is not my fault but the compiler's!" etc.).

In C++, the mangled names were introduced so that the linker realizes that something is wrong.

Good disassemblers like IDA (*advert*) from version 3.6 (or 3.7) on can also re-convert and display these names.

But sometimes you also want to do that yourself.

At least for Watcom C++ 10.6 I made the effort to summarize the most important chunks. Moreover, I listed the default calling convention because I didn't find it in the help file.

(I noted the whole thing for myself and hope it's understandable.)

The Watcom Calling Convention

name mangleing:

 a       char
 b       float
 c       signed char
 d       double
 n       near
 f       far
 i       int
 p       pointer (followed by f or n)
 q       bool
 s       short
 t       long double
 u       unsigned
 v       void
 $*$     struct

special names:

 $da     operator delete []
 $ob     ?
 $dl     operator delete ??

 W?<name>$[:classname$]<near|far>(<parms>)<return>

'this's are passed in the usual way, i.e in eax.

The usual order is:

 eax = parm1
 edx = parm2
 ebx = parm3
 ecx = parm4

The rest gets onto the stack in reverse order.
Therefore the rightmost parameter gets PUSHed first.

The background value is in eax, all other registers get destroyed.

(Of course you can change everything by #pragma. :)

Maybe this is useful for someone.

- tmbinc/daze