From: Josef Weidendorfer Date: Wed, 7 Apr 2021 22:34:48 +0000 (+0200) Subject: Callgrind: Broader handling of _dl_runtime_resolve variants X-Git-Tag: VALGRIND_3_18_0~137 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e41080720e451cefc2265c64f82fb77a9f29151;p=thirdparty%2Fvalgrind.git Callgrind: Broader handling of _dl_runtime_resolve variants This is a supplement to commit 86277041 To improve its results, Callgrind does special handling for the runtime linker entry point to resolve symbols. However, it only used the exact symbol name "_dl_runtime_resolve", as well as specific machine code templates (when the runtime linker was stripped from symbol names) as basis. Recent glibc added multiple similar symbol names as variants, such as _dl_runtime_resolve_xsave. The above-mentioned commit 86277041 solves this by extending the check for machine code templates for specific Linux distributions. This patch extends this for more architectures and variants by checking if a function starts with "_dl_runtime_resolve". Furthermore, the original function names of the variants still are visible in the output (and not forced to the prefix). While the heuristic that every function symbol starting with the prefix "_dl_runtime_resolve" as being an entry point into the runtime linker for resolving a function address may be a bit rough, this prefix is not expected to be used often in other source code for anything else. The worst case is a slightly misleading call graph only visible in a very specific situation: if the wrongly-detected function does a tail call (ie instead of returning, jumping to another function), it will be shown as 2 calls in a row from the original caller. --- diff --git a/callgrind/fn.c b/callgrind/fn.c index 7cce1a0c71..45d26ed43f 100644 --- a/callgrind/fn.c +++ b/callgrind/fn.c @@ -665,7 +665,7 @@ fn_node* CLG_(get_fn_node)(BB* bb) if (bb->sect_kind == Vg_SectPLT) fn->skip = CLG_(clo).skip_plt; - if (VG_(strcmp)(fn->name, "_dl_runtime_resolve")==0) { + if (VG_(strncmp)(fn->name, "_dl_runtime_resolve", 19)==0) { fn->pop_on_jump = True; if (VG_(clo_verbosity) > 1)