Microsoft Demangler library#92
Open
vuzelac-amd wants to merge 4 commits intoamd-stagingfrom
Open
Conversation
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().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.