Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp912476ybb; Fri, 10 Apr 2020 12:41:40 -0700 (PDT) X-Google-Smtp-Source: APiQypIdpGkkuC0agsjrQqKBtwp8BGBg03ufm1+Swqie96ejhQ7tFclPpzf/AYn2h/ILJOCWdGQH X-Received: by 2002:ae9:f802:: with SMTP id x2mr5826827qkh.144.1586547699885; Fri, 10 Apr 2020 12:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586547699; cv=none; d=google.com; s=arc-20160816; b=BvF28w+MMTdnDdL6fFFYxmWFFSD1QNW76GHta9cPCTH+L70Ed6wkUAjit9VxQLQk9c x0Wq8o3JIiWS27CERmc1CZF0lfLbU+9mmg0k6krZMhZ99/ZgZX6b5j/Li2ZBj6UE+XRv CRLDQ504WL8h0Z1wTuzFFZ5fNzvVG9NLEc/tpncLaUdX3nGNTq3/9yAsi/R+COwy3cMx 0RuUVGld469NnzWsVtkZP69J2IbGfkQGAsZKzAwU+1CZ2MMNon2JKj8YVP+beu/AlOhV Nuv3kJ3kWG1xEhh+KGiaxaqjiLGFS/c1MA8bzR7U2hmbxmX8+5rgfmkCaXme10GrnRZI KcSg== 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=32LgyjgF9Rws7bENkZNk7e8qjUime8Vog0G++m+NQWQ=; b=dkz/DX/rgU3Gla5sPiUGQwEIlWT2bJd2pdzU9F1x+2ttrujdCGk05RqaGkl8Eellyu bHh2kMnlyD84/06c+KdUJM0TnSTerfrJaioO2p906b3ETIB82tt27r21naL6ASfKUPTn hEVLkXer2A9GdX79JeRymKAmZ7kQdo02erunkRQGYYTeypufBX9DcSj9kt6G+lgx0aIY CbzRnCurqiUFnhuUjhUVzJA1QdEi6UFJ6S7YUib9DVu0oq9au6NdBFsB8sMFQQwJ3TRN dSHFLj12Wlc5lzSEv7dCHfRYhyaJ2ywTdLxzj5ZmSKAaJNrlQ17HaAtMA5HMg+IGC82j rI5A== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g4si1675340qto.149.2020.04.10.12.41.24; Fri, 10 Apr 2020 12:41:39 -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; 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; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727048AbgDJTil (ORCPT + 99 others); Fri, 10 Apr 2020 15:38:41 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:28725 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbgDJTil (ORCPT ); Fri, 10 Apr 2020 15:38:41 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Fri, 10 Apr 2020 12:38:36 -0700 Received: from sc9-mailhost3.vmware.com (unknown [10.166.69.226]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 6379740C50; Fri, 10 Apr 2020 12:38:40 -0700 (PDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Julien Thierry , Ingo Molnar , Steven Rostedt , Miroslav Benes , Matt Helsley Subject: [RFC][PATCH 25/36] objtool: mcount: Move relocation entry size detection Date: Fri, 10 Apr 2020 12:35:48 -0700 Message-ID: <4ae840c9f019d1014426b0f4f9b32c253c3cd5e9.1586468801.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-001.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 f39919e1ea7e..95b93767d6eb 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 e6efdd34958e..084f1eff0df0 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