From patchwork Tue Feb 25 18:20:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 13990547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A21D2C021B2 for ; Tue, 25 Feb 2025 18:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:Subject:Cc:To:From:Date:Message-ID:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=tu77UTwp3wqR8RYxZC1EZe2tgjkQypdRGOMbtG4FoiU=; b=ctiE6n07HEeaXu Wi6jNQutmWZLj84cN1DrpMytbNSQjEWbT4OMF3JFsQaBUWBj7FtwQATTQfJLTCdMqOPDxtBmthBrI TJT/IZXhPuhEKm3IUpZmZQaMYRdZCtDztSlDNOYfrymZk/pBOaEulh7FD7jLbfeQQBHi0WYw+hPyo mnhQfJGjwrU6ZLGlNcIC1YIMsFzOr000RnzIFybQ+fk6jZ3dxyFWM9vdl4RSFmb6mBDgQsqcmXL94 4ywjxppsIPTgOpjfBWV0hvos4lQyINavfaHkyFl5/dW2cPh+YJyc1HqttNy8F+f39n6srptLmmzVE JmSzsSeP1ZaZnACAp2jA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tmzvz-000000010qx-1poK; Tue, 25 Feb 2025 18:45:35 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tmzXU-00000000tUI-3iVg for linux-arm-kernel@lists.infradead.org; Tue, 25 Feb 2025 18:20:16 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 5CFC761302; Tue, 25 Feb 2025 18:20:09 +0000 (UTC) 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> MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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: