From 3b6e83297b6b3d0fb11a1a467d4f84dda223cad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Guidi?= Date: Mon, 19 Jun 2023 12:50:40 -0400 Subject: [PATCH] dynamic: Save original instructions only once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't save instructions if they are already present in the code hmap. Signed-off-by: Clément Guidi --- libmcount/dynamic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmcount/dynamic.c b/libmcount/dynamic.c index 21a85415e..ce88dd8b4 100644 --- a/libmcount/dynamic.c +++ b/libmcount/dynamic.c @@ -105,6 +105,9 @@ void mcount_save_code(struct mcount_disasm_info *info, unsigned call_size, void struct mcount_orig_insn *orig; int patch_size; + if (hashmap_get(code_hmap, (void *)info->addr + call_size)) + return; + if (unlikely(info->modified)) { /* it needs to save original instructions as well */ int orig_size = ALIGN(info->orig_size, 16);