From bfde407de559c10d6cef861b3873ff287c24e761 Mon Sep 17 00:00:00 2001 From: Ben Hamilton Date: Mon, 24 Apr 2023 13:53:09 -0600 Subject: [PATCH] [dump_syms] Relax name matching for marking symbols as multiple Previously, the logic to mark a symbol as "multiple" would always fire for C++ symbols for Apple `.dSYM`s built with `-gmlt`. This was because for a C++ symbol like `void foo::bar::Baz()`, the DWARF data would contain the truncated function name `Baz`, but the STABS would contain the fully-qualified name `void foo::bar::Baz()`. This CL relaxes the name matching to not mark as multiple: 1) Symbols which were missing names entirely in the DWARF (e.g, ")` 2) Symbols whose fully-qualified name includes the truncated name as a substring Bug: https://bugs.chromium.org/p/google-breakpad/issues/detail?id=883 Change-Id: I26ded7ca84d964aa4a73da19e4bdd7e686e2c998 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4470047 Reviewed-by: Joshua Peraza --- src/common/module.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/common/module.cc b/src/common/module.cc index e61c3b7a..73c4a8b1 100644 --- a/src/common/module.cc +++ b/src/common/module.cc @@ -157,8 +157,22 @@ bool Module::AddFunction(Function* function) { Extern* found_ext = it_ext->get(); bool name_mismatch = found_ext->name != function->name; if (enable_multiple_field_) { + bool is_multiple_based_on_name; + // In the case of a .dSYM built with -gmlt, the external name will be the + // fully-qualified symbol name, but the function name will be the partial + // name (or omitted). + // + // Don't mark multiple in this case. + if (name_mismatch && + (function->name == "" || + found_ext->name.find(function->name.str()) != string::npos)) { + is_multiple_based_on_name = false; + } else { + is_multiple_based_on_name = name_mismatch; + } // If the PUBLIC is for the same symbol as the FUNC, don't mark multiple. - function->is_multiple |= name_mismatch || found_ext->is_multiple; + function->is_multiple |= + is_multiple_based_on_name || found_ext->is_multiple; } if (name_mismatch && prefer_extern_name_) { function->name = AddStringToPool(it_ext->get()->name);