Skip to content

Microsoft Demangler library#92

Open
vuzelac-amd wants to merge 4 commits intoamd-stagingfrom
users/vuzelac/libdemangle-msvc
Open

Microsoft Demangler library#92
vuzelac-amd wants to merge 4 commits intoamd-stagingfrom
users/vuzelac/libdemangle-msvc

Conversation

@vuzelac-amd
Copy link
Copy Markdown

This library provides MSVC symbol demangling functionality, currently using
the existing LLVM's MSVC demangler code. It can be used by BFD, GDB and
binutils to demangle Microsoft Visual C++ symbols.

The library exposes msvc_demangle() function, compatible with libiberty's
demangling interface. msvc_demangle() is invoked from within bfd_demangle_new
by checking the mangled name prefix and determining whether the symbol is in
MSVC format.
msvc_demangle is provided to bfd_demangle_new as a callback in order to
avoid linking libbfd with libdemangle_msvc. Only the tools that require
libdemangle_msvc will pass this callback and link the library.

For all it's demangling needs, GDB almost exclusively uses gdb_demangle_new,
which returns plain demangled string. This call is supported by msvc_demangle.
GDB also has a few places where it demangles into the demangle_component
AST. These functions are not relevant to PE/COFF binaries and MSVC demangling,
however, the appropriate functions are added for completeness:
msvc_class_name_from_physname() and msvc_method_name_from_physname().

To discuss:

remove two additional functions.
Possibly disable for Linux
replace string_view with a local function to avoid cxx17.

vuzelac added 4 commits April 19, 2026 15:30
Demangler is implemented using the existing LLVM Demangler.
The demangler is built as a separate library (libdemangle_msvc)
due to the licensing issues - normally, it would be integrated
into libiberty.

The library exposes msvc_demangle() call while BFD adds
bfd_demangle_new() which automatically demangles using
libdemangle_msvc or libiberty. GDB now uses bfd_demangle_new()
instead of bfd_demangle(). Binutils that want MSVC demangling
should switch to the new function as well.

For all it's demangling needs, GDB almost exclusively uses
gdb_demangle(), which returns plain demangled string.
However, GDB also has a few places where it demangles into the
demangle_component AST. These functions are not relavant to
PE/COFF binaries and MSVC demangling, however, the appropriate
functions are added for completeness:
msvc_class_name_from_physname() and msvc_method_name_from_physname().
@vuzelac-amd vuzelac-amd requested a review from a team as a code owner April 19, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants