From f0641b065fb24966b0979c6a711baf85f68e7fb8 Mon Sep 17 00:00:00 2001 From: Jayant Chowdhary Date: Tue, 22 May 2018 10:55:17 -0700 Subject: [PATCH] vndk-vtable-dumper: Use demangled name of symbol while handling symbol aliasing. While trying to handle cases where multiple symbols could be aliased, we were trying to relate a symbol to its class by trying to find the class' demangled name as a substring of the symbol's mangled name. This might lead to errors when the class is in a qualified namespace (due to C++ mangled names having fully qualified namespaces of the form . Having interspersed between namespaces makes finding the substring inaccurate). Now, we try find the class' demangled name in the demangled symbol name instead. Bug: 80088849 Test: Without this change, vndk-vtable-dumper for libstagefright_bufferqueue_helper.so has an incorrect entry in the vtable for android::GraphicsBuffer at offset 20 : _ZNK7android6VectorIiE12do_constructEPvj Test: With this change, vndk-vtable-dumper for libstagefright_bufferqueue_helper.so has the correct entry in the vtable for android::GraphicsBuffer at offset 20 : _ZN7android19GraphicBufferSource23onSidebandStreamChangedEv Change-Id: I16507f3cef4d9c252aae3d27bef34563e2679703 --- vndk/tools/vtable-dumper/elf_handling.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vndk/tools/vtable-dumper/elf_handling.cpp b/vndk/tools/vtable-dumper/elf_handling.cpp index e0483dbdb..7b115dfbe 100644 --- a/vndk/tools/vtable-dumper/elf_handling.cpp +++ b/vndk/tools/vtable-dumper/elf_handling.cpp @@ -329,8 +329,9 @@ SymbolRef ELFSharedObject::matchValueToSymbol( const std::string ClassName(Vtablep->getDemangledName().substr(pos)); for (const SymbolRef &Symbol : SymVec) { StringRef SymbolName = UnWrap(Symbol.getName()); - if (SymbolName.str().find(ClassName) != std::string::npos) + if (demangle(SymbolName.str()).find(ClassName) != std::string::npos) { return Symbol; + } } // Return the 1st Symbol by default. return SymVec[0];