Mangling & Demangling
Jump to navigation
Jump to search
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 (the Windows C++ compiler) 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 next number of "entries" (context dependent) |
?
|
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 |
{*::}
|
Required (at least 1) sequence of :: -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
| |
[]
|
vc
|
!=
|
ne
| |
~
|
co
|
!
|
nt
| |
^
|
er
|
%
|
md
| |
^=
|
aer
|
%=
|
amd
| |
>=
|
ge
|
<=
|
le
| |
>
|
gt
|
<
|
lt
| |
&=
|
aad
|
>>
|
rs
| |
|=
|
aor
|
<<
|
ls
| |
>?
|
mx
|
>>=
|
ars
| |
<?
|
mn
|
<<=
|
als
| |
->
|
rf
|
->*
|
rm
| |
?
|
qs
|
__uuidof(
|
uu
| |
cast
|
cs
|
__alignof__(
|
af
| |
sizeof(
|
sz
|
builtin-operation
|
bi
| |
Generic Type Operator | ||||
* = Any mangled type
ex: |
op*
|
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) | Conditions |
---|---|---|
C
|
const T
|
Reusable, any number of times |
P
|
T* (pointer to type)
|
Reusable, any number of times |
R
|
T& (reference to type)
|
Reusable, any number of times |
V
|
volatile T
|
Reusable, any number of times |
U
|
unsigned T
|
Must be the last modifier in a sequence. Mutually exclusive with S and x
|
S
|
signed T
|
Must be the last modifier in a sequence. Mutually exclusive with U and x
|
x
|
_Complex T
|
Must be the last modifier in a sequence. Mutually exclusive with S and U
|
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. Must be the first modifier in a sequence
|
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_bv__Fci_b
|
bool foo<T1, T2>(char, int) [with T1=bool, T2=void]
|
Namespace
Function |
{funcName}__Q#_{NS+}{?:funcModifs}F{argTypes+}{?:_{returnType}}
|
{returnType} {NS::}::{funcName}({?:argTypes,})
|
foo__Q1_3stdFci_b
|
bool std::foo(char, int)
|
Class
Function |
{funcName}__?{className}{?:funcModifs}F{argTypes+}{?:_{returnType}}
|
{returnType} {className}::{funcName}({?:argTypes,})
|
bar__3FooFci_b
|
bool Foo::bar(char, int)
|
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)
|
Virtual Table | __vtbl__?{className}
|
class {className} ... (Any Class Declaration)
|
__vtbl__3Foo
|
virtual function table for Foo
|
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)
|