<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Naren Sirigere's blog</title><link>http://naren.wiki/tags/dlang/</link><description>All blog posts</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><copyright>© 2025 - 2026 by Naren Sirigere</copyright><lastBuildDate>Sat, 13 Jun 2026 00:00:00 +0530</lastBuildDate><atom:link href="http://naren.wiki/tags/dlang/index.xml" rel="self" type="application/rss+xml"/><item><title>The up-to-date DLang DMD Mangling Scheme *</title><link>http://naren.wiki/posts/dmd_mangling_scheme/</link><pubDate>Sat, 13 Jun 2026 00:00:00 +0530</pubDate><guid>http://naren.wiki/posts/dmd_mangling_scheme/</guid><description>&lt;p&gt;An updated reference for the Dlang DMD name mangling ABI.&lt;/p&gt;
&lt;p&gt;* At least up to 2026-06-13&lt;/p&gt;
&lt;h3 id="grammar-notation"&gt;Grammar Notation&lt;/h3&gt;
&lt;p&gt;This specification uses standard EBNF. Terminal characters are literal characters in the mangled string.&lt;/p&gt;
&lt;h3 id="1-the-root-symbol"&gt;1. The Root Symbol&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;MangledName:
_D QualifiedName [ M ] [ Type ] [ Z ]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;em&gt;Note: &lt;code&gt;M&lt;/code&gt; denotes a member function.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id="2-names-and-symbols"&gt;2. Names and Symbols&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;QualifiedName:
SymbolFunctionName { SymbolFunctionName }
SymbolFunctionName:
SymbolName [ M TypeModifier ] [ CallingConvention FuncAttrs (Parameters) ParamClose ]
SymbolName:
0
LName
BackRefSymbol
TemplateInstanceName
LName:
Number Name
0 // __anonymous
___S Number // Special anonymous symbol
Number:
Digit { Digit }
BackRefSymbol:
Q Base26Pos
Base26Pos:
{ UpperCaseAlpha } LowerCaseAlpha // Upper = A-Z (0-25), Lower = a-z (0-25, terminates)
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="3-types-and-modifiers"&gt;3. Types and Modifiers&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Type:
TypeModifiers Type
BasicType
DerivedType
FunctionType
DelegateType
VectorType
BackRefType
BasicType:
v | g | h | s | t | i | k | l | m | f | d | e | o | p | j | q | r | c | b | a | u | w | n | z i | z k
DerivedType:
A Type // Dynamic Array: Type[]
P Type // Pointer: Type*
G Number Type // Static Array: Type[Number]
H Type Type // Associative Array: Type[Type]
I QualifiedName // Identifier
C QualifiedName // Class
S QualifiedName // Struct
E QualifiedName // Enum
T QualifiedName // Typedef
B (Parameters) Z // Tuple
VectorType:
N h Type // __vector(Type)
BackRefType:
Q Base26Pos
TypeModifiers:
x // const
y // immutable
O // shared
O x // shared const
O N g // shared inout
O N g x // shared inout const
N g // inout
N g x // inout const
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="4-functions-and-delegates"&gt;4. Functions and Delegates&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;CallingConvention:
F // D
U // C
W // Windows
R // C++
Y // Objective-C
FunctionType:
CallingConvention FuncAttrs (Parameters) ParamClose Type // (args) return_type
DelegateType:
D [ TypeModifiers ] [ CallingConvention ] FuncAttrs (Parameters) ParamClose Type
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="5-function-attributes"&gt;5. Function Attributes&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;FuncAttrs:
{ FuncAttr }
FuncAttr:
N a // pure
N b // nothrow
N c // ref
N d // @property
N e // @trusted
N f // @safe
N i // @nogc
N j // return
N j N l // return scope
N l // scope
N l N j // scope return
N m // @live
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="6-parameters"&gt;6. Parameters&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Parameters:
{ Parameter }
Parameter:
[ ParamStorageClass ] Type
ParamStorageClass:
M N k J // scope return out
M N k K // scope return ref
N k J // return out
N k K // return ref
N k M J // return scope out
N k M K // return scope ref
N k M // return scope
M // scope
N k // return
I // in
I K // in ref
J // out
K // ref
L // lazy
ParamClose:
X // ...) (variadic)
Y // , ...) (C-style variadic)
Z // ) (standard)
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="7-templates"&gt;7. Templates&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;TemplateInstanceName:
TemplateID SymbolName TemplateArgs [ Z ]
TemplateID:
__T | __U | T | U
TemplateArgs:
{ [ H ] TemplateArg }
TemplateArg:
T Type // Type argument
V TypeChar Type Value // Value argument
S QualifiedName // Symbol argument
S _ D QualifiedName [Z] // Fully qualified symbol
X Number Name // Externally linked LName
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="8-values-and-literals"&gt;8. Values and Literals&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Value:
n // null
i Number // positive integer
N Number // negative integer
Number // positive integer (shorthand)
b Number // boolean (0/1)
e HexFloat // real
c HexFloat c HexFloat // complex real
a Number _ HexString // char string
w Number _ HexString // wchar string
d Number _ HexString // dchar string
A Number { Value } // Array
H Number { Value : Value } // Associative Array
S Number { Value } // Struct
HexFloat:
N A N // real.nan
I N F // real.infinity
N I N F // -real.infinity
[ N ] HexDigits P [ N ] Number // Hexadecimal float (e.g., 0x...p+/-...)
&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;
&lt;h3 id="deviations--additions-from-the-official-spec"&gt;Deviations &amp;amp; Additions from the Official Spec&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Parameter Storage Classes:&lt;/strong&gt; Added complex, undocumented combinations (e.g., &lt;code&gt;M N k J&lt;/code&gt; for &lt;code&gt;scope return out&lt;/code&gt;, &lt;code&gt;I K&lt;/code&gt; for &lt;code&gt;in ref&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Type Back References:&lt;/strong&gt; Specified that &lt;code&gt;Q&lt;/code&gt; compresses types (&lt;code&gt;BackRefType&lt;/code&gt;), not just symbols.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New Attributes:&lt;/strong&gt; Added &lt;code&gt;@live&lt;/code&gt; (&lt;code&gt;N m&lt;/code&gt;), &lt;code&gt;return scope&lt;/code&gt; (&lt;code&gt;N j N l&lt;/code&gt;), and &lt;code&gt;scope return&lt;/code&gt; (&lt;code&gt;N l N j&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Template Values (&lt;code&gt;V&lt;/code&gt;):&lt;/strong&gt; Added detailed grammar for arrays (&lt;code&gt;A&lt;/code&gt;), associative arrays (&lt;code&gt;H&lt;/code&gt;), structs (&lt;code&gt;S&lt;/code&gt;), and exact hex float configurations (base-16 exponents, &lt;code&gt;N A N&lt;/code&gt;, &lt;code&gt;I N F&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vectors &amp;amp; 128-bit Ints:&lt;/strong&gt; Added &lt;code&gt;__vector(Type)&lt;/code&gt; (&lt;code&gt;N h&lt;/code&gt;), &lt;code&gt;cent&lt;/code&gt; (&lt;code&gt;z i&lt;/code&gt;), and &lt;code&gt;ucent&lt;/code&gt; (&lt;code&gt;z k&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Anonymous Symbols:&lt;/strong&gt; Included &lt;code&gt;___S Number&lt;/code&gt; for special anonymous scopes.&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h3 id="implementation"&gt;Implementation&lt;/h3&gt;
&lt;p&gt;My C implementation of a demangler based on this DMD specification can be found here: &lt;a href="https://github.com/rizinorg/rz-libdemangle/blob/main/src/d/dmd.c"&gt;rz-libdemangle&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This parser was developed as part of my GSoC'26 project for the &lt;a href="https://rizin.re/"&gt;Rizin&lt;/a&gt; reverse engineering framework.&lt;/p&gt;</description></item></channel></rss>