Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1708027ybt; Thu, 18 Jun 2020 15:29:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHjh8hhDj7+oY0/EPKn4h/isBwDpGVWhtYgcsnMbta1iuKtN5gYOY2teD9dd+l8aqemT29 X-Received: by 2002:aa7:c790:: with SMTP id n16mr443447eds.54.1592519359555; Thu, 18 Jun 2020 15:29:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592519359; cv=none; d=google.com; s=arc-20160816; b=Xu9qRsSiRKej1RHI5O7T6r1+idfEgKNa2kkHoHkABp4ARrQEqlF3KKc6244wwFPoYy y7im8VoLxSRwvq8eO1MS70tB3GxdKAO8dLnB1b9l7FNEBBbdI5uRqn0T1kgGnCKxVcdq aYSG/xFdoUBdwaKYylh/8HUsjnkTkPBIk4VtHsKoSDNd+kqp3nqARfO9l7LiBpjm7pSS oxjZiDuWhb541GcHC+VziE7gaagoYlfW+gH6yODMRgkvj/wOJiMjWjJ3ErsHv8lT0vWm Sk8hL+S4HXKuZrnx48+qGJGY16TSXR1XKaWV+M7vUOZLEnpi2DLFtHyhCqIOyX5gxeRl 2WBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=QKtBKoII+7ZNS5T25jlDeBbL12j02+65esLrEEK8KZ8=; b=mTtZn9qcFi8yoqoIrIKLNbcG0kYY1TEiZjou3mf5+Rj31lduWwD5x4eOjd/DDpbVys Gm1NpMrWcrEjb7+xI0DuIodErPhUS8dqhpQRY8PBd2CzCxWEWngf96yi5WSdprmmj5HU n3R3cHqiOp9zjfCR87e0sYhiiogLnztEqKWmQgBp48A30sM+47Mxx6L3yRSHmKKxWEO+ Xivs9qhydg+Z7aO31UIFeWTO4ViMNUFOf1Kuht79tu0NRuDpscaOr+m534RqzURk0mYx oKgwKQvWVTSjH9O1xuRtQKae3q8OMkyORPdAXX4cR5g32C6lrwRS02eouf5/c0B3nZvt tAmw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm27si2674017edb.248.2020.06.18.15.28.57; Thu, 18 Jun 2020 15:29:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727787AbgFRUlX (ORCPT + 99 others); Thu, 18 Jun 2020 16:41:23 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:36734 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731566AbgFRUjs (ORCPT ); Thu, 18 Jun 2020 16:39:48 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Thu, 18 Jun 2020 13:39:38 -0700 Received: from sc9-mailhost2.vmware.com (unknown [10.129.221.29]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 73BC8B265A; Thu, 18 Jun 2020 16:39:41 -0400 (EDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Julien Thierry , Kamalesh Babulal , Matt Helsley Subject: [RFC][PATCH v5 50/51] objtool: mcount: Remove useless lookup Date: Thu, 18 Jun 2020 13:38:36 -0700 Message-ID: <5b0c55a54fec946cbbea4a3e0e87485d71123e47.1592510545.git.mhelsley@vmware.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII Received-SPF: None (EX13-EDG-OU-002.vmware.com: mhelsley@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since the relocation section's sh_info points back to the text section it applies to and we already have that we can just pass it in and greatly simplify find_section_sym_index(). Signed-off-by: Matt Helsley --- tools/objtool/mcount.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/tools/objtool/mcount.c b/tools/objtool/mcount.c index 084bbc02de0c..a74625aed09b 100644 --- a/tools/objtool/mcount.c +++ b/tools/objtool/mcount.c @@ -198,35 +198,27 @@ static const unsigned int missing_sym = (unsigned int)-1; * Num: Value Size Type Bind Vis Ndx Name * 2: 00000000 0 SECTION LOCAL DEFAULT 1 */ -static int find_section_sym_index(unsigned const txtndx, - char const *const txtname, - unsigned long *const recvalp, - unsigned int *sym_index) +static int find_section_sym_index(const struct section * const txts, + unsigned long *const recvalp, + unsigned int *sym_index) { struct symbol *sym; - struct section *txts = find_section_by_index(lf, txtndx); - - if (!txts) { - fprintf(stderr, "Cannot find section %u: %s.\n", - txtndx, txtname); - return missing_sym; - } list_for_each_entry(sym, &txts->symbol_list, list) { /* avoid symbols with weak binding */ - if ((sym->bind == STB_LOCAL) || (sym->bind == STB_GLOBAL)) { - /* function symbols on ARM have quirks, avoid them */ - if (lf->ehdr.e_machine == EM_ARM - && sym->type == STT_FUNC) - continue; - - *recvalp = sym->sym.st_value; - *sym_index = sym->idx; - return 0; - } + if ((sym->bind != STB_LOCAL) && (sym->bind != STB_GLOBAL)) + continue; + + /* function symbols on ARM have quirks, avoid them */ + if (lf->ehdr.e_machine == EM_ARM && sym->type == STT_FUNC) + continue; + + *recvalp = sym->sym.st_value; + *sym_index = sym->idx; + return 0; } fprintf(stderr, "Cannot find symbol for section %u: %s.\n", - txtndx, txtname); + txts->idx, txts->name); return missing_sym; } @@ -414,8 +406,7 @@ static int do_mcount(unsigned const reltype) unsigned long recval = 0; unsigned int recsym; - if (find_section_sym_index(sec->sh.sh_info, - txts->name, &recval, &recsym)) + if (find_section_sym_index(txts, &recval, &recsym)) goto out; sift_rel_mcount(&r_offset, sec, mrels, mlocs, -- 2.20.1