Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1657221rwl; Wed, 12 Apr 2023 16:51:07 -0700 (PDT) X-Google-Smtp-Source: AKy350a8yAY66Qyg38T6U0MeKUua4GOa6xS/uA99NC1xpcQXMbViIh9S/ZxRmqKHJqfQQ9WD/u+P X-Received: by 2002:a17:902:ea03:b0:1a6:6c27:e8b8 with SMTP id s3-20020a170902ea0300b001a66c27e8b8mr1777plg.59.1681343467116; Wed, 12 Apr 2023 16:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681343467; cv=none; d=google.com; s=arc-20160816; b=0XYR52ZXBJn1jx5zivUO16XfaBLN3BTjyVsqlusX1gU61U45fF4ap5feidMDpXsqFk 1j2Jm7fmsfT7nyx5SD9XcfkLX/HbdVmJZQeBRXaddS+rf4oDkerCUfmMWwbCKzQpLjfu AG+PmsISGQANVaud/5FwVclC7uz/xpZQBQLmohYCgw+LM11TfVUg0Qyg5z9JDXdEFjsA tfbrU+1h2UsowedWEI9y73J1MIyEyvMhKEbz9UU0XxBGM/738+/zIPiFK7DfIjrnC9l6 nuSVY+rX1T0cYDgbs4WSznkyZL0uRg6WyrovZnuyw2vDzPG66gAzpBek6IcAyTSIza54 P6kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qtOA3F5t/Qm3IHg9wBEoBJO0iBJv8sT8LzhlGTOPImQ=; b=YyLj6/ADb8Bkyrpk3kc6+sqQ6OpmikVQ4xGjd99s0SD/DH70w5hzKwtfsB+Qh6B4ko 8gcA9PdlruGC6bAenmyRbPu9jPPXhqRsMG3+sY0WRutYsr69LoSvmbST3+p4FYF9hfME QCKE5wRiVL3G/rgPh0Zw/llCpjUYSuxMzFlIGHcWYpGigTUb5VycUeELw2FNAZBZZLGv N6xtF9YNkrdwhGuCFVEBboBPlh1j81ZIrSzzZ8bHqpunuUNzHTt7I6/2hI9l2+PFrg2n EWNBz+TmLuDoHXw5MQAgvnaUzoMroLQM/Eeywjm2KD/vtcoWfQYsOtbHlElqF+iZhm/1 as+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Q0A/KUNq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a170902d49100b0019e8d4cb8d3si387242plg.614.2023.04.12.16.50.55; Wed, 12 Apr 2023 16:51:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Q0A/KUNq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229498AbjDLXuV (ORCPT + 99 others); Wed, 12 Apr 2023 19:50:21 -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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 --- 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; -- 2.39.2