From 5e41080720e451cefc2265c64f82fb77a9f29151 Mon Sep 17 00:00:00 2001 From: Josef Weidendorfer Date: Thu, 8 Apr 2021 00:34:48 +0200 Subject: [PATCH] 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. --- callgrind/fn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) -- 2.47.2