From patchwork Wed Apr 12 23:49:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Poimboeuf X-Patchwork-Id: 13209657 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EBF9C77B73 for ; Wed, 12 Apr 2023 23:50:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbjDLXuM (ORCPT ); Wed, 12 Apr 2023 19:50:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjDLXuE (ORCPT ); Wed, 12 Apr 2023 19:50:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15BD861BF; Wed, 12 Apr 2023 16:50:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA05263A2B; Wed, 12 Apr 2023 23:50:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5B8DC433A1; Wed, 12 Apr 2023 23:50:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681343402; bh=aZ+Jm121CTQwCGer705wrEKwXxtRjeZahsDaZDvQjNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q0A/KUNqTELcfzgzINIlbc454QKQa7T9qsKJcFdNUooOWCQP9O0Gs1LyEOCdbUEUB nVC7Kp3bo7jLolqmS9ZN2WPgyFSrIWNC1SuSkc9CSEIulsNpcmigxjBR0MpDCG9ccv N/vpnZhCk7SB7lSWPo6LFkb+ULm2b0jAB9nVAVHO5ztT80kIM5YXFGScxEGEbzD+6+ T+zZQMAJsQaIkel2TFNTbP6yEgJD2rBx0sYyYNUpQsc1dBWzeTI6qalmzRXQk7m/Y/ 0RiNM4u/xxQLVEoytDmsfF3p2c85VDGEAX6gKvZ4PPzSgsC3ZQ/1/p7YZfzM056P3u WaUCwINX5Oi2Q== From: Josh Poimboeuf To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Miroslav Benes , linux-btrfs@vger.kernel.org, Mark Rutland , linux-scsi@vger.kernel.org, linux-hyperv@vger.kernel.org, Arnd Bergmann , "Guilherme G . Piccoli" , Michael Kelley , Nick Desaulniers , Nathan Chancellor , kernel test robot Subject: [PATCH v2 07/11] objtool: Include weak functions in global_noreturns check Date: Wed, 12 Apr 2023 16:49:37 -0700 Message-Id: X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Content-type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org If a global function doesn't return, and its prototype has the __noreturn attribute, its weak counterpart must also not return so that it matches the prototype and meets call site expectations. To properly follow the compiled control flow at the call sites, change the global_noreturns check to include both global and weak functions. On the other hand, if a weak function isn't in global_noreturns, assume the prototype doesn't have __noreturn. Even if the weak function doesn't return, call sites treat it like a returnable function. Fixes the following warning: kernel/sched/build_policy.o: warning: objtool: do_idle() falls through to next function play_idle_precise() Reported-by: kernel test robot Link: https://lore.kernel.org/oe-kbuild-all/202304090346.erhqxnlt-lkp@intel.com/ Signed-off-by: Josh Poimboeuf Reviewed-by: Miroslav Benes --- tools/objtool/check.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index ed42717463f9..94c16436d990 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -236,14 +236,14 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func, if (!func) return false; - if (func->bind == STB_WEAK) - return false; - - if (func->bind == STB_GLOBAL) + if (func->bind == STB_GLOBAL || func->bind == STB_WEAK) for (i = 0; i < ARRAY_SIZE(global_noreturns); i++) if (!strcmp(func->name, global_noreturns[i])) return true; + if (func->bind == STB_WEAK) + return false; + if (!func->len) return false;