Mangling & Demangling
For an explanation of what mangling and demangling are, refer to the C++ section of the Wikipedia article on mangling.
Note that in the above linked article, most of the practical examples use the MSVC mangling scheme, which is not at all similar to the GHS (The Wii U C++ compiler) mangling scheme.
For reference, in this table on the same article, the closest matching one to GHS would be GCC 2.9.x. However they are not entirely equal.
For that reason, the goal of this page is to document the specific GHS mangling scheme and how to reverse (demangle) it.
Token (* = anything) | Meaning |
---|---|
?
|
Number representing the length of the next token |
{*}
|
Required placeholder string variable |
{*+}
|
Required (at least 1) sequence of variables |
{*,}
|
Required (at least 1) sequence of comma-separated variables |
{?:*}
|
Optional segment |
Operator | Code | Operator | Code | |
---|---|---|---|---|
new
|
nw
|
new[]
|
nwa
| |
delete
|
dl
|
delete[]
|
dla
| |
++
|
pp
|
()
|
cl
| |
--
|
mm
|
,
|
cm
| |
+
|
pl
|
+=
|
apl
| |
-
|
mi
|
-=
|
ami
| |
*
|
ml
|
*=
|
amu
| |
/
|
dv
|
/=
|
adv
| |
&
|
ad
|
&&
|
aa
| |
|
|
or
|
||
|
oo
| |
=
|
as
|
==
|
eq
| |
<?
|
mn
|
!=
|
ne
| |
~
|
co
|
!
|
nt
| |
^
|
er
|
%
|
md
| |
^=
|
aer
|
%=
|
amd
| |
>=
|
ge
|
<=
|
le
| |
>
|
gt
|
<
|
lt
| |
&=
|
aad
|
>>
|
rs
| |
|=
|
aor
|
<<
|
ls
| |
->
|
rf
|
>>=
|
ars
| |
<<=
|
als
| |||
cast
|
cs
|
sizeof(
|
sz
| |
builtin-operation
|
bi
|
__alignof__(
|
af
|
Mangled Type | Demangled Type | Valid Modifiers |
---|---|---|
b
|
bool
|
C V P R
|
c
|
char
|
C V P R S U
|
d
|
double
|
C V P R
|
f
|
float
|
C V P R
|
i
|
int
|
C V P R S U
|
l
|
long
|
C V P R S U
|
L
|
long long
|
C V P R S U
|
r
|
long double
|
C V P R
|
s
|
short
|
C V P R S U
|
v
|
void
|
C V P
|
w
|
wchar_t
|
C V P R
|
Mangled Modifier | Demangled Modifier (T = type the modifier is applied to) |
---|---|
C
|
const T
|
P
|
T* (pointer to type)
|
R
|
T& (reference to type)
|
S
|
signed T
|
U
|
unsigned T
|
V
|
volatile T
|
Mangled Modifier | Demangled Modifier (T = the function the modifier is applied to) | Description |
---|---|---|
C
|
T() const
|
const function
|
P
|
(*T)()
|
Function pointer (funcptr) |
R
|
(&T)()
|
Function reference (funcref) |
S
|
T()
|
static modifier, for some reason isn't shown by the demangler
|
V
|
T() volatile
|
volatile function
|
Mangled Modifier (# = digit, ? = number) | Description |
---|---|
J##J
|
Unknown |
Z?Z
|
Copy #-th template parameter in function arguments |
N##
|
Repeat (2nd #)-th function argument (1st #) times |
Item Type | Mangled Format | Source C++ Signature Format (Pre-mangle) | Mangled Example | Demangled Example |
---|---|---|---|---|
Basic
Function |
{funcName}__F{argTypes+}{?:_{returnType}}
|
{returnType} {funcName}({?:argTypes,})
|
foo__Fci_b
|
bool foo(char, int)
|
Templated
Function |
{funcName}__tm__?{_{templateTypes+}}__F{argTypes+}{_<returnType>}
|
{returnType} {funcName}<{templateTypes,}>({?:argTypes,})
|
foo__tm__3_fd__Fci_b
|
bool foo<T1, T2>(char, int) [with T1=float, T2=double]
|
Constructor | __ct__?{className}F{argTypes+}
|
{className}::{className}({?:argTypes,})
|
__ct__3FooFci
|
Foo::Foo(char, int)
|
Destructor | __dt__?{className}F{argTypes+}
|
{className}::~{className}({?:argTypes,})
|
__dt__3FooFci
|
Foo::~Foo(char, int)
|
Static
Member |
{memberName}__?{className}
|
{className}::{memberName}
|
bar__3Foo
|
Foo::bar
|
Operator | __{operatorCode}__F{argTypes+}{?:_{returnType}}
|
{returnType} operator {operator}({?:argTypes,})
|
__nw__Fci_b
|
bool operator new(char, int)
|