The GNU3 demangler adds the name of the entity being mangled to its substitution table in cases where the Itanium ABI excludes it. This shifts subsequent S_ references, producing incorrect parameter types.
Reproducer with an existing BinaryView bv:
symbols = [
"_ZN1A1BINS_1CEE1fENS_1DES2_S3_",
"_ZN1A1fINS_1CEEEvNS_1BIT_EES4_PS3_S5_",
"_ZSt2swIiEvPT_S1_St1WIS0_ES3_",
]
for symbol in symbols:
print(demangle_gnu3(bv.arch, symbol)[0])
Expected demangled signatures from c++filt, in the same order:
A::B<A::C>::f(A::D, A::B<A::C>, A::D)
void A::f<A::C>(A::B<A::C>, A::B<A::C>, A::C*, A::C*)
void std::sw<int>(int*, int*, std::W<int>, std::W<int>)
Actual Binary Ninja types:
int64_t(struct A::B<A::C>* this, A::D, A::B<A::C>, A::B<A::C>::f)
void(struct A* this, A::B<A::C>, A::C, A::B*, A::B<A::C>)
void(int32_t*, int32_t, std::W<std::sw<int32_t> >, std::W)
The GNU3 demangler adds the name of the entity being mangled to its substitution table in cases where the Itanium ABI excludes it. This shifts subsequent S_ references, producing incorrect parameter types.
Reproducer with an existing BinaryView bv:
Expected demangled signatures from c++filt, in the same order:
Actual Binary Ninja types: