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