Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5006754ybb; Tue, 24 Mar 2020 09:14:15 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtrxAlF1ewOkUkLlRgx2zTrnOuI45mYO71YVQsYXA+YAjMvuzz1K9dIhSsxeEQicJJ+GeAZ X-Received: by 2002:aca:af12:: with SMTP id y18mr3807941oie.78.1585066455565; Tue, 24 Mar 2020 09:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585066455; cv=none; d=google.com; s=arc-20160816; b=KbIhDpgbRbkht1JJ9t1EGLIPkZvPr43SkrqlbGaExPHPBgk56dzI1pHWFfaiSPHTsI BGJd+6dNJH/YYmjwZwkIZafvD2MzcbsqTS2ntIEMLVXYI9bhB0dvQZORf8x8KxOmFU06 CApnliWnx44Ousv5TzvWiBRb2dgtZhV4+fhdvqCP2tYcYQqy9EpQwdaogaAAhk+eNVsq dDQF+bpvvnJ0Cjwi4s+E71AZF52NDOz/qa1rmFR2/T8rt4dELrrpvCjZ2y25j7KTEwCC xeOionipXE7Q5zNDRutXMmhyfeI0rPHOfDwXJvY9sDRyvq//FmoB7HXutv9zN7OVnlGN hdjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id:dkim-signature; bh=o7RVv3CUxPNg2jYu+UyuSePNLr3TfhvVjvW78jQ2xdI=; b=yDjUDu0+V292/ug3sGTYgN6c/ZFHIaaC/GxPohgvg58Eo5CEfgHSfaUK2StnK7GdiD UHL7XnrijQ3fi/mE+jvIXOt5Jgra2VGx9LtikuZjD9Jw6suDa8rHDGfxfeUx5aFBEb7F e+1Y9oo99OOx4aiJs2ljqda5wx1tK/zD6AEtf+hF9b473NVpnUeeoX6/uYEClCNs1xa9 ieDyPioY4iKv+q36oM73VfWyy5QDI79nBNlkPn0fs3xrXJQXtVXohSrB88bCGgvsAPTs fLXUbM6AssNc82fcnG+b7ydxDBUs2rkzIqjIcfmpxwHjZ6zRTlGWKrb1Z9rcj022cE6h raGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fx7Dkrtk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f19si353973oos.45.2020.03.24.09.14.02; Tue, 24 Mar 2020 09:14:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=fx7Dkrtk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729049AbgCXQNJ (ORCPT + 99 others); Tue, 24 Mar 2020 12:13:09 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:51012 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728339AbgCXQLg (ORCPT ); Tue, 24 Mar 2020 12:11:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=o7RVv3CUxPNg2jYu+UyuSePNLr3TfhvVjvW78jQ2xdI=; b=fx7Dkrtkrtnc7RuojEKOo7tzgE 4LigaAKR02Gnj76ssof/X42oEltOQNRfk6lac2xWgu0x3qa6yFKyXygFDiPYG8Q3j01I7AcSml+j7 QbhEjxrj3cXacjQjI5R/OnW3HbhZQhTm6td/Uzl7dS6g3DcaeOY91E8pQ/xVMwwsDY1nRFAPjGaFv Ywy/3DDwb9JPJaB3ujE4dd1wH3qma4W7VJ36rru3E7I86MzMLyLV5xNMuCguXuHNCj/fsNFtsqY74 X7vv+lgGr8sAexPzylNRT9bGv6vTXciu+u7ib20e5bjhTsbfMrntRFEcSBbdlJrjmhJ70SPGkC65f AHBbKRDg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jGm9M-0000Bv-1v; Tue, 24 Mar 2020 16:11:32 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 5FE5B3073F6; Tue, 24 Mar 2020 17:11:28 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 52C9D29A490F6; Tue, 24 Mar 2020 17:11:28 +0100 (CET) Message-Id: <20200324160924.924304616@infradead.org> User-Agent: quilt/0.65 Date: Tue, 24 Mar 2020 16:31:30 +0100 From: Peter Zijlstra To: tglx@linutronix.de, jpoimboe@redhat.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, peterz@infradead.org, mhiramat@kernel.org, mbenes@suse.cz, brgerst@gmail.com Subject: [PATCH v3 17/26] objtool: Re-arrange validate_functions() References: <20200324153113.098167666@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation to adding a vmlinux.o specific pass, rearrange some code. No functional changes intended. Signed-off-by: Peter Zijlstra (Intel) --- tools/objtool/check.c | 60 ++++++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 26 deletions(-) --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -2413,9 +2413,8 @@ static bool ignore_unreachable_insn(stru return false; } -static int validate_functions(struct objtool_file *file) +static int validate_section(struct objtool_file *file, struct section *sec) { - struct section *sec; struct symbol *func; struct instruction *insn; struct insn_state state; @@ -2428,35 +2427,44 @@ static int validate_functions(struct obj CFI_NUM_REGS * sizeof(struct cfi_reg)); state.stack_size = initial_func_cfi.cfa.offset; - for_each_sec(file, sec) { - list_for_each_entry(func, &sec->symbol_list, list) { - if (func->type != STT_FUNC) - continue; - - if (!func->len) { - WARN("%s() is missing an ELF size annotation", - func->name); - warnings++; - } - - if (func->pfunc != func || func->alias != func) - continue; - - insn = find_insn(file, sec, func->offset); - if (!insn || insn->ignore || insn->visited) - continue; - - state.uaccess = func->uaccess_safe; - - ret = validate_branch(file, func, insn, state); - if (ret && backtrace) - BT_FUNC("<=== (func)", insn); - warnings += ret; + list_for_each_entry(func, &sec->symbol_list, list) { + if (func->type != STT_FUNC) + continue; + + if (!func->len) { + WARN("%s() is missing an ELF size annotation", + func->name); + warnings++; } + + if (func->pfunc != func || func->alias != func) + continue; + + insn = find_insn(file, sec, func->offset); + if (!insn || insn->ignore || insn->visited) + continue; + + state.uaccess = func->uaccess_safe; + + ret = validate_branch(file, func, insn, state); + if (ret && backtrace) + BT_FUNC("<=== (func)", insn); + warnings += ret; } return warnings; } + +static int validate_functions(struct objtool_file *file) +{ + struct section *sec; + int warnings = 0; + + for_each_sec(file, sec) + warnings += validate_section(file, sec); + + return warnings; +} static int validate_reachable_instructions(struct objtool_file *file) {