From nobody Tue Dec 2 02:19:21 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