From nobody Tue Dec 2 02:05:53 2025 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 90BC1357732 for ; Thu, 20 Nov 2025 20:52:33 +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=1763671953; cv=none; b=L+jFgTziX4TiJQtyqYdTieKOu4q2dbWTJyy/64NNbJbN59njeuRtPRXjyAef9I9NOULWCBNjhMhrCJMtPmrhcX4p46E8uRP17DfKu301CpDS4Rwtua4boYDnlRWLCxUhmonnn7f3nmGukPjnZdRG15Pe31ZQfgwVqO6VjOL31Tw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763671953; c=relaxed/simple; bh=CtdrCf6U+lVneM6FFRF7pUJ+2tAMSHDn6G/1xHXuxAo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WHQ3vliU8oIxWMXL3Z8axZKzf7/PBS0m38nuS/qv/hSpHmG9bAHjE5ysgxaIi/u20SvEm+kAcSWsEzCruRpGu7BwWQbEKCE5N9MyX/X9pM20k5R6xTYyMrG8EtG4mYwYOToGjdd9ua1D0sS6UY8aVCh2TeN0ba3dlpBR0g3weFE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q4h3BS4F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q4h3BS4F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31128C4CEF1; Thu, 20 Nov 2025 20:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763671953; bh=CtdrCf6U+lVneM6FFRF7pUJ+2tAMSHDn6G/1xHXuxAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q4h3BS4Fg5r1eTRSXqWcH7VvUMK9yhDMplQBkd/B+PLu+1GbIjO659pXmGrAGvih9 eLV/2HtUZndQKSgs3vSc0PW+6UOcpckJgfpP+S9vNJ1BlhW4K7DWOlihnnyCrQfTX+ sDPPtyrfmIebckqcP5fnctAK0vBLXjxW2Omuel/BM5RzKB0GZMTRjA5GBdc48y4/yV GCIHcLDs+pq+I6hvRvGxzWiMXTgopJI/7C4xt+u4rNWbwiMCblLDNWQVCbqTIqoRBb jvpmQPn1aYZM8LVedr8S/kMBiAG0cGXMxCvb/a04UzKXl0WM9W6O83juOFc91v2zN1 shV1k0toweAoA== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Rong Xu , Han Shen , Sriraman Tallam , Krzysztof Pszeniczny Subject: [PATCH 6/6] objtool: Remove second pass of .cold function correlation Date: Thu, 20 Nov 2025 12:52:20 -0800 Message-ID: X-Mailer: git-send-email 2.51.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The .cold function parent/child correlation logic has two passes: one in read_symbols() and one in add_jump_destinations(). The second pass was added with commit cd77849a69cf ("objtool: Fix GCC 8 cold subfunction detection for aliased functions") to ensure that if the parent symbol had aliases then the canonical symbol was chosen as the parent. That solution was rather clunky, not to mention incomplete due to the existence of alternatives and switch tables. Now that we have sym->alias, the canonical alias fix can be done much simpler in the first pass, making the second pass obsolete. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 23 +---------------------- tools/objtool/elf.c | 3 ++- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 6a4a29f8f2f5..1a20ff89df74 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -1623,34 +1623,13 @@ static int add_jump_destinations(struct objtool_fil= e *file) continue; } =20 - if (!insn->sym || insn->sym =3D=3D dest_insn->sym) + if (!insn->sym || insn->sym->pfunc =3D=3D dest_sym->pfunc) goto set_jump_dest; =20 /* * Internal cross-function jump. */ =20 - /* - * For GCC 8+, create parent/child links for any cold - * subfunctions. This is _mostly_ redundant with a - * similar initialization in read_symbols(). - * - * If a function has aliases, we want the *first* such - * function in the symbol table to be the subfunction's - * parent. In that case we overwrite the - * initialization done in read_symbols(). - * - * However this code can't completely replace the - * read_symbols() code because this doesn't detect the - * case where the parent function's only reference to a - * subfunction is through a jump table. - */ - if (func && dest_sym->cold) { - func->cfunc =3D dest_sym; - dest_sym->pfunc =3D func; - goto set_jump_dest; - } - if (is_first_func_insn(file, dest_insn)) { /* Internal sibling call */ if (add_call_dest(file, insn, dest_sym, true)) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 7e2c0ae6b41a..6a8ed9c62323 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -658,8 +658,9 @@ static int read_symbols(struct elf *elf) return -1; } =20 - sym->pfunc =3D pfunc; + sym->pfunc =3D pfunc->alias; pfunc->cfunc =3D sym; + pfunc->alias->cfunc =3D sym; =20 /* * Unfortunately, -fnoreorder-functions puts the child --=20 2.51.1