From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F7B51A4E98; Tue, 25 Feb 2025 18:20:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740507616; cv=none; b=jvg2XT6KG+2PuysBmH8uCoSISJR1tjwZPiCXHcu5LhhP2TXEXFJ674chEiUccCVaZJFuzQR815BrP6ww9jWDoLYJ0u3JnpWpCJL+J1stWz/1tmeJQIurvoEWyFksuAZcz7zp0iYGL8k3hd1isZ0TBbq0dXg3SRXPx1WbSim4ETs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740507616; c=relaxed/simple; bh=YdLBlvD7KuxzSEIk+RyaPCgrtz0J+VoLSvcf9Vme8s8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=aTCzGPdvIEiaZERP+jETJE3twA+oizEhBWsO/Z0DztPLJ4VX3lytTUn9N+Nt2zYJkszzNgvldI1Bf6aZQkgnwrbQGTYsIVVLFrpeLBUUD8lh5lnZAW0DMGODw4jdFyNGIPge6LnrWzoci4wT6cdcm0uj5jKZ+8TapaNm+6+Vc+s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8A1EC4CEF2; Tue, 25 Feb 2025 18:20:15 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98) (envelope-from ) id 1tmzY6-000000095ZO-41vx; Tue, 25 Feb 2025 13:20:54 -0500 Message-ID: <20250225182054.815536219@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 25 Feb 2025 13:20:08 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , Masahiro Yamada , Catalin Marinas , Will Deacon , Nathan Chancellor , "Arnd Bergmann" , Mark Brown Subject: [PATCH 4/4] scripts/sorttable: Allow matches to functions before function entry References: <20250225182004.473875894@goodmis.org> Precedence: bulk X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Steven Rostedt ARM 64 uses -fpatchable-function-entry=4,2 which adds padding before the function and the addresses in the mcount_loc point there instead of the function entry that is returned by nm. In order to find a function from nm to make sure it's not an unused weak function, the entries in the mcount_loc section needs to match the entries from nm. Since it can be an instruction before the entry, add a before_func variable that ARM 64 can set to 8, and if the mcount_loc entry is within 8 bytes of the nm function entry, then it will be considered a match. Fixes: ef378c3b82338 ("scripts/sorttable: Zero out weak functions in mcount_loc table") Tested-by: Nathan Chancellor Signed-off-by: Steven Rostedt (Google) --- scripts/sorttable.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/sorttable.c b/scripts/sorttable.c index 07ad8116bc8d..7b4b3714b1af 100644 --- a/scripts/sorttable.c +++ b/scripts/sorttable.c @@ -611,13 +611,16 @@ static int add_field(uint64_t addr, uint64_t size) return 0; } +/* Used for when mcount/fentry is before the function entry */ +static int before_func; + /* Only return match if the address lies inside the function size */ static int cmp_func_addr(const void *K, const void *A) { uint64_t key = *(const uint64_t *)K; const struct func_info *a = A; - if (key < a->addr) + if (key + before_func < a->addr) return -1; return key >= a->addr + a->size; } @@ -1253,6 +1256,8 @@ static int do_file(char const *const fname, void *addr) #ifdef MCOUNT_SORT_ENABLED sort_reloc = true; rela_type = 0x403; + /* arm64 uses patchable function entry placing before function */ + before_func = 8; #endif /* fallthrough */ case EM_386: -- 2.47.2