Skip to content

Print vtables, VTTs and thunks as GNU and LLVM do - #321

Open
rui314 wants to merge 1 commit into
gimli-rs:masterfrom
rui314:gnu-special-names
Open

rui314 wants to merge 1 commit into
gimli-rs:masterfrom
rui314:gnu-special-names

Conversation

@rui314

@rui314 rui314 commented Nov 13, 2026

Copy link
Copy Markdown

This patch makes cpp_demangle demangle the following names in the same
way as GNU and LLVM do.

_ZTVN2ns1AE
  before: {vtable(ns::A)}
  after:  vtable for ns::A

_ZTTN2ns1DE
  before: {vtt(ns::D)}
  after:  VTT for ns::D

_ZThn16_N2ns1C1gEv
  before: {virtual override thunk({offset(-16)}, ns::C::g())}
  after:  non-virtual thunk to ns::C::g()

_ZTv0_n32_N2ns1D1fEv
  before: {virtual override thunk({virtual offset(0, -32)}, ns::D::f())}
  after:  virtual thunk to ns::D::f()

_ZTCN2ns1DE16_NS_1WE
  before: construction vtable for ns::D-in-ns::W
  after:  construction vtable for ns::W-in-ns::D

The "after" lines match what c++filt prints.

We found discrepancies in demangling while working on the mold linker.
The linker lets users assign symbol versions by matching patterns
against demangled symbol names. Because the names differ from GNU's,
some symbols end up not versioned at all.

Specifically, this patch changes `{vtable(A)}` to `vtable for A` and
`{vtt(A)}` to `VTT for A`, prints thunks as `virtual thunk to A::f()`
and so on, and fixes the order of the two classes in a construction
vtable's name.
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.

1 participant