Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1543268ybg; Tue, 2 Jun 2020 12:54:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6RD+CtoHTJ3kMX6ahuubXeR3rCptmEBPBRl1MfakWxwlTuwdPWZVvuZ4mEYhtpKFuANar X-Received: by 2002:a50:8d07:: with SMTP id s7mr28733504eds.371.1591127660945; Tue, 02 Jun 2020 12:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591127660; cv=none; d=google.com; s=arc-20160816; b=QfJSYLBUPQbUvLO2oZ5OzyiizWQhG+mrcJnuV5tWsQuc1KLWsl/UV7Ue3Hd8+dgOg5 S54jnjbZ3lvoYZf/DPEHwC3UXZXLDpNBgqQF15yt/TkIMX2IuG7Zm57OKBa9F8DQlPPj KbWhZCejJPpo7ffROYgdi6VxeTDbcKicGz9sy+RXP5JMtvqqMDHMr6F6PRrtTPNF0abC /xVKpzj96aJtQ4jtz6w4M7grD+papqcRLE4RQ67TAGTmTnxxjUt3dFSEv0Q06NnPtjuS ikk/ZIFzNX8w/rY5rEX5T9L/pnoJQqCdPliV7FOPu9DQCNFdFK77vXBshBy/a6sR6O9i SN8A== 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=67wDMr9moxHQ1ab8gauNraNXsx2rvDm7DaF2R+qSKrE=; b=nZvS+Lu+fc6bg6ELaLo52OjOv5YGmwpF/Xhl7Oa+GoVFWF7azMMNUtrepukuGeE39F /SvGh+UP18T1GlTomXdAxLclcXDYEgBuGiKGun0/qXUX8R4ZAKn5nWg9K8D19nlj/lxe /K+G6dvLcGgvIB5TD4sB+Z3YKfxusylvZPwPuoTL4v3pxVA5roTLnzqwBjz0czmwQ7VM WmcjTAB1GpEgr1vjcxZreND/Q+YqSYc+hi2DRonHlpHPD7sT06mqyuOZOGtyQdCT6Qyn eieT778cny0Xe58WL5J+DiCG+00ZVPHsb7PQVPVp4eK6S/dGw8a0dB/FuQy5mhA3ToWd 9T4g== 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 n24si513697edb.277.2020.06.02.12.53.57; Tue, 02 Jun 2020 12:54:20 -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 S1728513AbgFBTvX (ORCPT + 99 others); Tue, 2 Jun 2020 15:51:23 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:36862 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728305AbgFBTvF (ORCPT ); Tue, 2 Jun 2020 15:51:05 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Tue, 2 Jun 2020 12:51:01 -0700 Received: from sc9-mailhost3.vmware.com (unknown [10.200.192.49]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 2AE0340BEE; Tue, 2 Jun 2020 12:51:02 -0700 (PDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Sami Tolvanen , Julien Thierry , Kamalesh Babulal , Matt Helsley Subject: [RFC][PATCH v4 20/32] objtool: mcount: Move relocation entry size detection Date: Tue, 2 Jun 2020 12:50:13 -0700 Message-ID: <09f1cee98423ea4be0e5c3a0a03e0be8f0e970df.1591125127.git.mhelsley@vmware.com> X-Mailer: git-send-email 2.25.1 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 Move where we detect the size of relocation entries we wish to use into the first loop over the sections. This will allow us to allocate the mcount location and relocation sections before the next loop that collects them. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 8 +++++--- tools/objtool/recordmcount.h | 5 ++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index 248e49033538..6feb4e6b4113 100644 --- a/tools/objtool/recordmcount.c +++ b/tools/objtool/recordmcount.c @@ -457,7 +457,7 @@ static char const *has_rel_mcount(const struct section * const rels) return txts->name; } -static unsigned tot_relsize(void) +static unsigned tot_relsize(unsigned int *rel_entsize) { const struct section *sec; unsigned totrelsz = 0; @@ -465,8 +465,10 @@ static unsigned tot_relsize(void) list_for_each_entry(sec, &lf->sections, list) { txtname = has_rel_mcount(sec); - if (txtname && is_mcounted_section_name(txtname)) - totrelsz += sec->sh.sh_size; + if (!(txtname && is_mcounted_section_name(txtname))) + continue; + totrelsz += sec->sh.sh_size; + *rel_entsize = sec->sh.sh_entsize; } return totrelsz; } diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index f8d3e81c0129..352d2042be35 100644 --- a/tools/objtool/recordmcount.h +++ b/tools/objtool/recordmcount.h @@ -175,7 +175,7 @@ static int do_func(unsigned const reltype) uint_t * mloc0; uint_t * mlocp; - unsigned rel_entsize = 0; + unsigned int rel_entsize = 0; unsigned symsec_sh_link = 0; struct section *sec; @@ -185,7 +185,7 @@ static int do_func(unsigned const reltype) if (find_section_by_name(lf, "__mcount_loc") != NULL) return 0; - totrelsz = tot_relsize(); + totrelsz = tot_relsize(&rel_entsize); if (totrelsz == 0) return 0; mrel0 = umalloc(totrelsz); @@ -215,7 +215,6 @@ static int do_func(unsigned const reltype) if (result) goto out; - rel_entsize = sec->sh.sh_entsize; mlocp = sift_rel_mcount(mlocp, (void *)mlocp - (void *)mloc0, &mrelp, sec, recsym, (uint_t)recval, reltype); -- 2.20.1