From nobody Tue Dec 2 02:04:08 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 A23883128C2 for ; Thu, 20 Nov 2025 20:52:31 +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=1763671951; cv=none; b=Im2/GE2eONxzDoAsmiD43tBHm+oknsEBVBnMCqO01SDnhNAqMx5zjtuXL/+rTvYBc0qTq7L7BcUzZZD8HVjljOnAR8sBZiM6jzuLriQjyYVE9W9kMmTdxjc/PyaZpOM56CfSEyWNmqAIQ/tmXNdCQfu71YpzRhJlzchg5Yr6VnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763671951; c=relaxed/simple; bh=yVPXgFgLhUXVYeyXMObs6I+Dwf2pTCNgh6Y6W1RoUPk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TgnySK3vS6JZ6kaH4ELh5BhRtcPIHTWS3ZyQ6iyPIesbYtk5HVHXm3yU2v4F6r/qf5UECwalIozI/0Ts7/zxvvrS95NuWiK9yDVkUxa3se+HqOImt5hVIMO8qE8LAMiwD6zaKj57YJPT4zbep3jmt9wmuCo5v8oBIKMclQ3I3vI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F45muqmf; 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="F45muqmf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 151B2C16AAE; Thu, 20 Nov 2025 20:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763671951; bh=yVPXgFgLhUXVYeyXMObs6I+Dwf2pTCNgh6Y6W1RoUPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F45muqmfZ29KyJBqoCZB/fT9NoMW9F7csMcmC1J3gxUgCqUsPiirWzFRr8CS/KRyP 5abju3dkNiJ2sRdzqHchTxfsCjWo0oGV0ejmQ0jkq+xxRS9oHZjhgOKpcPs84YOavd BwFspgbMgEjKwffV4dxzPcJlgzWsn2P6kxOZjzg+uCOdg+Bx4lnCZdR4WzkxcGpRHa sP8rwhyQpI92XOVzdH3lK/HHmloEzXFFiibSPZwsdEHpIFl05fkvFSgMk8OodJHob+ Bz8qGrLdYtgGbCK9edJpZUasTTLmXRkBVwUgZG1v23m0Kp3eIPq6/+xq2S8t2GKgL/ jG95uJxL3TnnQ== 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 1/6] objtool: Support Clang AUTOFDO .cold functions Date: Thu, 20 Nov 2025 12:52:15 -0800 Message-ID: <20a67326f04b2a361c031b56d58e8a803b3c5893.1763671318.git.jpoimboe@kernel.org> 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" AutoFDO enables -fsplit-machine-functions which can move the cold parts of a function to a .cold symbol in a .text.split. section. Unlike GCC, the Clang .cold symbols are not marked STT_FUNC. This confuses objtool in several ways, resulting in warnings like the following: vmlinux.o: warning: objtool: apply_retpolines.cold+0xfc: unsupported inst= ruction in callable function vmlinux.o: warning: objtool: machine_check_poll.cold+0x2e: unsupported in= struction in callable function vmlinux.o: warning: objtool: free_deferred_objects.cold+0x1f: relocation = to !ENDBR: free_deferred_objects.cold+0x26 vmlinux.o: warning: objtool: rpm_idle.cold+0xe0: relocation to !ENDBR: rp= m_idle.cold+0xe7 vmlinux.o: warning: objtool: tcp_rcv_state_process.cold+0x1c: relocation = to !ENDBR: tcp_rcv_state_process.cold+0x23 Fix it by marking the .cold symbols as STT_FUNC. Fixes: 2fd65f7afd5a ("AutoFDO: Enable machine function split optimization f= or AutoFDO") Reported-by: Rong Xu Closes: https://lore.kernel.org/20251103215244.2080638-2-xur@google.com Signed-off-by: Josh Poimboeuf Reviewed-by: xur@google.com Tested-by: xur@google.com --- tools/objtool/elf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 3f20b257ab25..7895f65aca2a 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -502,8 +502,16 @@ static int elf_add_symbol(struct elf *elf, struct symb= ol *sym) if (strstarts(sym->name, ".klp.sym")) sym->klp =3D 1; =20 - if (!sym->klp && is_func_sym(sym) && strstr(sym->name, ".cold")) + if (!sym->klp && !is_sec_sym(sym) && strstr(sym->name, ".cold")) { sym->cold =3D 1; + + /* + * Clang doesn't mark cold subfunctions as STT_FUNC, which + * breaks several objtool assumptions. Fake it. + */ + sym->type =3D STT_FUNC; + } + sym->pfunc =3D sym->cfunc =3D sym; =20 sym->demangled_name =3D demangle_name(sym); --=20 2.51.1 From nobody Tue Dec 2 02:04:08 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 1E1B43242A4 for ; Thu, 20 Nov 2025 20:52:31 +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=1763671952; cv=none; b=FVbMz6dp3NYGkc70E2iXY30UV6+llXrk1aXBGzBN/+bvAFkKGVf8F5a1gvKwGOOJ4ERsM1jnAuy58k+jFuj14VF1qjwofOuuP3rVHcxSK2b6Va2f/t/o3/h8rJh0vzoutanLh9Jxm3ATrkWEeB6nuu4Iu2xgeRXRw0JrfQe8Xk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763671952; c=relaxed/simple; bh=8GNjVMtK9NJAT4U3TdvqgZ/kDsLlD1r/0G46aAc1HSM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n9kErX+7iaCaUo49fkjU4k9BIxK4n8rYb2Gu2XvNF3vwaAe+BsBPzgBebpggppGuiJTgxFaH4hSLAt6CFiAKokxkKx4PSxJ+bNCa9Dm40KGYv1rFwF1sRS0tpmOynHvW+dpZhi8MplJ88jlBzTafeS9FaI6O0O2eWIymeR9k8/E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=izqgExvl; 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="izqgExvl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 795F5C116C6; Thu, 20 Nov 2025 20:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763671951; bh=8GNjVMtK9NJAT4U3TdvqgZ/kDsLlD1r/0G46aAc1HSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=izqgExvlZDC9mfDtrdEijEa++D1WcG3lCJglmw+s6JMecMNY8nzmg5zqutk/JpgnN d4iuXCfJZA030mU8GRoe6D02npKZaYhYg8rhTvFBbDqISpuUvjha01u9eRhc2BfE4K Ei4P2hNnQhUKfQWCiEIaCYYvaqQQXziu1JcL4ejWrSMzt7msuSNj8jkcIWHGq6kX3m R/MSRMUm+oqrTXQ355ZBvar3F5PRkrlorXr3Ny9aXrqN9bMcWONNwo7aS4qVwuIBH2 SqEQqM26Wrz9TsDlW+wVZ4QgQTzCKhwSf0mXxqRLBYTmGVSBEYYY88MbmC2F5fRG7u MAsgQxS60XJ3A== 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 2/6] objtool: Fix .cold function detection for duplicate symbols Date: Thu, 20 Nov 2025 12:52:16 -0800 Message-ID: <82c7b52e40efa75dd10e1c550cc75c1ce10ac2c9.1763671318.git.jpoimboe@kernel.org> 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 objtool .cold child/parent correlation is done in two phases: first in elf_add_symbol() and later in add_jump_destinations(). The first phase is rather crude and can pick the wrong parent if there are duplicates with the same name. The second phase usually fixes that, but only if the parent has a direct jump to the child. It does *not* work if the only branch from the parent to the child is an alternative or jump table entry. Make the first phase more robust by looking for the parent in the same STT_FILE as the child. Fixes the following objtool warnings in an AutoFDO build with a large CLANG_AUTOFDO_PROFILE profile: vmlinux.o: warning: objtool: rdev_add_key() falls through to next functio= n rdev_add_key.cold() vmlinux.o: warning: objtool: rdev_set_default_key() falls through to next= function rdev_set_default_key.cold() Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions") Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 28 ++++++++++++++++++++++++++-- tools/objtool/include/objtool/elf.h | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 7895f65aca2a..fffca31d47ed 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -288,6 +288,23 @@ struct symbol *find_symbol_by_name(const struct elf *e= lf, const char *name) return NULL; } =20 +/* Find local symbol with matching STT_FILE */ +static struct symbol *find_local_symbol_by_file_and_name(const struct elf = *elf, + struct symbol *file, + const char *name) +{ + struct symbol *sym; + + elf_hash_for_each_possible(symbol_name, sym, name_hash, str_hash(name)) { + if (sym->bind =3D=3D STB_LOCAL && sym->file =3D=3D file && + !strcmp(sym->name, name)) { + return sym; + } + } + + return NULL; +} + struct symbol *find_global_symbol_by_name(const struct elf *elf, const cha= r *name) { struct symbol *sym; @@ -524,7 +541,7 @@ static int elf_add_symbol(struct elf *elf, struct symbo= l *sym) static int read_symbols(struct elf *elf) { struct section *symtab, *symtab_shndx, *sec; - struct symbol *sym, *pfunc; + struct symbol *sym, *pfunc, *file =3D NULL; int symbols_nr, i; char *coldstr; Elf_Data *shndx_data =3D NULL; @@ -597,6 +614,11 @@ static int read_symbols(struct elf *elf) =20 if (elf_add_symbol(elf, sym)) return -1; + + if (sym->type =3D=3D STT_FILE) + file =3D sym; + else if (sym->bind =3D=3D STB_LOCAL) + sym->file =3D file; } =20 if (opts.stats) { @@ -626,7 +648,9 @@ static int read_symbols(struct elf *elf) return -1; } =20 - pfunc =3D find_symbol_by_name(elf, pname); + pfunc =3D find_local_symbol_by_file_and_name(elf, sym->file, pname); + if (!pfunc) + pfunc =3D find_global_symbol_by_name(elf, pname); free(pname); =20 if (!pfunc) { diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/ob= jtool/elf.h index 21d8b825fd8f..e12c516bd320 100644 --- a/tools/objtool/include/objtool/elf.h +++ b/tools/objtool/include/objtool/elf.h @@ -69,7 +69,7 @@ struct symbol { unsigned int idx, len; unsigned long offset; unsigned long __subtree_last; - struct symbol *pfunc, *cfunc, *alias; + struct symbol *pfunc, *cfunc, *alias, *file; unsigned char bind, type; u8 uaccess_safe : 1; u8 static_call_tramp : 1; --=20 2.51.1 From nobody Tue Dec 2 02:04:08 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 8F21B33A706 for ; Thu, 20 Nov 2025 20:52:32 +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=1763671952; cv=none; b=HlHOyfX5hurAYLO8dQsH+OwSHr3Dd8Kx3t81sT1Jjw6DFzSAzfQzhIeD+hhLUX6Kze9+rv7ukFGOwvRH9A563fovmKI/sDT2YntQTkCHzq/Q2bPkfYrlPmLMiHd5Gd5Vp7YXGrm+QwOjzpe4OZrWV3InhvaTzC7k5MLX2a88Tpk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763671952; c=relaxed/simple; bh=6/+C8C8ScN5yQ87KESOLlqwTA36gwEDleRj9B/At4yY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nCOzbSFljgdId12wRXGtnqnN4ZRTtEQiqeD6DvdzI7V8LrUgIMz7f3wgxw8i3qTdR6z2sEkCcJek9hZ/NwutgX1h4voZnc88FIb0L3EtS0huvMm1X/fYwC0ghXWwb0DXgSYPtCXu9JQ/ltg39lnj73aR1p2TjMGAdfGKc6ipWv8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DpXeSI9N; 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="DpXeSI9N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3B34C4CEF1; Thu, 20 Nov 2025 20:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763671952; bh=6/+C8C8ScN5yQ87KESOLlqwTA36gwEDleRj9B/At4yY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DpXeSI9N9nohX3vNhtII1hn5yM3L+99HGGpacyF42tG5CvG8Eb7uv7TySzngcghWq 5rqLjSc0j1yyIog40uM+5OjRZxWCVGacx8E4wNwwZAtiVCMQX+5fsA68cIAyusgvld LwanWIYB8I9em5BzqNBcGy+VaBqi/25SM/NkOGtUhTczJ6ABB+NUGO6aPjQkFcyHgl 423PRHonEnrdwu46qWfMCkB4aWJfVs+m0LNy1/Aou/BjLQE/Eh8iuUYkZDhJcXQ+LU YV8ddHaRmXdiWkfHPgGIKh9HvzU/M3fteCswDTjACJq6J9cAI0UVtsAsp6J2fEi3xC B7OkpknrpZ/oQ== 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 3/6] objtool: Don't alias undefined symbols Date: Thu, 20 Nov 2025 12:52:17 -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" Objtool is mistakenly aliasing all undefined symbols. That's obviously wrong, though it has no consequence since objtool happens to only use sym->alias for defined symbols. Fix it regardless. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index fffca31d47ed..4f15643ad70c 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -492,8 +492,8 @@ static int elf_add_symbol(struct elf *elf, struct symbo= l *sym) sym->len =3D sym->sym.st_size; =20 __sym_for_each(iter, &sym->sec->symbol_tree, sym->offset, sym->offset) { - if (iter->offset =3D=3D sym->offset && iter->type =3D=3D sym->type && - iter->len =3D=3D sym->len) + if (!is_undef_sym(iter) && iter->offset =3D=3D sym->offset && + iter->type =3D=3D sym->type && iter->len =3D=3D sym->len) iter->alias =3D sym; } =20 --=20 2.51.1 From nobody Tue Dec 2 02:04:08 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 01F01347BB4 for ; Thu, 20 Nov 2025 20:52:32 +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=dw/knRz2tXlEt0F7YCjX1hZIyQ8vq98HdKmSsA1LoeE9Khi/spHmE+Y5lRbhFW8pzsHFcpQmBV6wZTd0QcNjruDTCXhMwKotrCxPjGqJeDemC3JCRXoi5g6ebLjaIrkLzN0mkKwIYe21iChBZSvDV5ljgyavOlG/FCM+PvoQoDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763671953; c=relaxed/simple; bh=dzNDka3UmxjfIrn2FFuMv2/doJEJWvhSa8rFn1L16uQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KnA6w7dDZqIVYh/BhIV4ezobcIUBKl1peAh6TjTzUXMQt26HZutqlpnjM7DNWzSuhIUPADsB8MpZVYV4juefBel+6crObG4m0wFXTJbxYCctZYpzgp4juVksKlxpHSfSac59ffXiaLzWMWaYjAJH1x2wnsjPrdfO5QR16ICGGso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eVzUShTI; 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="eVzUShTI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 555B9C116C6; Thu, 20 Nov 2025 20:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763671952; bh=dzNDka3UmxjfIrn2FFuMv2/doJEJWvhSa8rFn1L16uQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eVzUShTIpzoERmqYOAKdoLhox0plTGD6aL3Dx+kVejeA4GqR/QGnXcae39tbxPcSX 4EhQ7h2V7lX2GMo9c2NSuDBAWr3d9SB1lrTqdtE5imFLoO6F/8HRsC80bcO1Tah19a NUUn4ckNvrvSsaCvTHZLGduWCGX5oWwJ12RFtFPM5zQGMRfI2yEhs6V/czhfw9UePx LtEmHlletMZcfZPAEW/hw5OjVWKxBujhTBOpm7Bsd59Brp/DGCUdMSmfZWTcudpjfF 3D11kbbNLXJS17msL7eZi48tXBo51X3o4OQ92k1QP/q7jtg1IvBG73j+Qz1Mmn+d7q T/vemmGfoSbUQ== 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 4/6] objtool: Return canonical symbol when aliases exist in symbol finding helpers Date: Thu, 20 Nov 2025 12:52:18 -0800 Message-ID: <450470a4897706af77453ad333e18af5ebab653c.1763671318.git.jpoimboe@kernel.org> 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" When symbol alias ambiguity exists in the symbol finding helper functions, return the canonical sym->alias, as that's the one which gets used by validate_branch() and elsewhere. This doesn't fix any known issues, just makes the symbol alias behavior more robust. Signed-off-by: Josh Poimboeuf --- tools/objtool/elf.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 4f15643ad70c..7e2c0ae6b41a 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -172,11 +172,11 @@ static struct symbol *find_symbol_by_index(struct elf= *elf, unsigned int idx) struct symbol *find_symbol_by_offset(struct section *sec, unsigned long of= fset) { struct rb_root_cached *tree =3D (struct rb_root_cached *)&sec->symbol_tre= e; - struct symbol *iter; + struct symbol *sym; =20 - __sym_for_each(iter, tree, offset, offset) { - if (iter->offset =3D=3D offset && !is_sec_sym(iter)) - return iter; + __sym_for_each(sym, tree, offset, offset) { + if (sym->offset =3D=3D offset && !is_sec_sym(sym)) + return sym->alias; } =20 return NULL; @@ -185,11 +185,11 @@ struct symbol *find_symbol_by_offset(struct section *= sec, unsigned long offset) struct symbol *find_func_by_offset(struct section *sec, unsigned long offs= et) { struct rb_root_cached *tree =3D (struct rb_root_cached *)&sec->symbol_tre= e; - struct symbol *iter; + struct symbol *func; =20 - __sym_for_each(iter, tree, offset, offset) { - if (iter->offset =3D=3D offset && is_func_sym(iter)) - return iter; + __sym_for_each(func, tree, offset, offset) { + if (func->offset =3D=3D offset && is_func_sym(func)) + return func->alias; } =20 return NULL; @@ -220,7 +220,7 @@ struct symbol *find_symbol_containing(const struct sect= ion *sec, unsigned long o } } =20 - return sym; + return sym ? sym->alias : NULL; } =20 /* @@ -266,11 +266,11 @@ int find_symbol_hole_containing(const struct section = *sec, unsigned long offset) struct symbol *find_func_containing(struct section *sec, unsigned long off= set) { struct rb_root_cached *tree =3D (struct rb_root_cached *)&sec->symbol_tre= e; - struct symbol *iter; + struct symbol *func; =20 - __sym_for_each(iter, tree, offset, offset) { - if (is_func_sym(iter)) - return iter; + __sym_for_each(func, tree, offset, offset) { + if (is_func_sym(func)) + return func->alias; } =20 return NULL; --=20 2.51.1 From nobody Tue Dec 2 02:04:08 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 2D2A934DCC8 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=QZ09QrcGNo7dnWv3Me5Bi3NlSAzfNg/MxeWiNLctfh3LjnZuNl7+wfEuSMjD5KvXlSNIzJj0EEceMeMilw/7yvnPbKyRA7a4zhAAye3c8X84Q7HUfireR5tSWsV4zeiAlUaCoEtlnLDbxP1pZG2g8DVFzgqSFVnC9sH6qmHN0GE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763671953; c=relaxed/simple; bh=9DYHInCp4UN/1Osqd7TzWniVLGeZ3xqkycie73ZSf7k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A9vf7p8FW/awOfH0yPh417gZBDJaFvTi377c/FlcXgG1ftOt0zqdrXRjVlpw+x9xVwMSp+QCVLobCAR7OTnSe7KjIZXAUFWbcIPLNUlgsKCUj7WsH1CbwhBhuzkLl2SHdetvQivh04BovmfyQFY5ZbCc2OLSYnvPV5FsbRrGlRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OP7MjrHW; 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="OP7MjrHW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7CC6C19421; Thu, 20 Nov 2025 20:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763671953; bh=9DYHInCp4UN/1Osqd7TzWniVLGeZ3xqkycie73ZSf7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OP7MjrHW9UdmVXvM4x/520j9u876tXceW4EUPqpT77lNbN0PYxgB9+yKU6Ni+0PpS RRcsEfp0CT7UxYCErcPC2RDtGR/DBzWcQXsrKBSb8396zDaWLvRgOaZUGzBxSbsxID i96ikT3DcNgwx0zdrt9c9TUDsjV8TlZi/R4zBr+3TTtI7NCAioKFIa0SG0NBI9HItl YiYT7ixV8z1N0EggoHxqLfPKGl3SXDpygpKxR8Bpx/g6ElLg8ceJ4WGC7brzcBSHOu n+qtgJUReqysN6MNKqIA9Mwvoo++gkD1BQqFtn1ARbDTkA3umWB011xNYy0JZxFuJn 0BxTUL/DotL7Q== 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 5/6] objtool: Skip non-canonical aliased symbols in add_jump_table_alts() Date: Thu, 20 Nov 2025 12:52:19 -0800 Message-ID: <169aa17564b9aadb74897945ea74ac2eb70c5b13.1763671318.git.jpoimboe@kernel.org> 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" If a symbol has aliases, make add_jump_table_alts() skip the non-canonical ones to avoid any surprises. Signed-off-by: Josh Poimboeuf --- tools/objtool/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 72c7f6f03350..6a4a29f8f2f5 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2197,7 +2197,7 @@ static int add_jump_table_alts(struct objtool_file *f= ile) return 0; =20 for_each_sym(file->elf, func) { - if (!is_func_sym(func)) + if (!is_func_sym(func) || func->alias !=3D func) continue; =20 mark_func_jump_tables(file, func); --=20 2.51.1 From nobody Tue Dec 2 02:04:08 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