Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp28221ybt; Thu, 18 Jun 2020 17:15:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT0VUvZAFARlUaUexxZA1KuKAj1lpXZ8rq3kqUxdLNJvOuKNvUQI2H2UVJnQg+2iKJyaLK X-Received: by 2002:a17:906:6d4b:: with SMTP id a11mr1278711ejt.108.1592525747643; Thu, 18 Jun 2020 17:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592525747; cv=none; d=google.com; s=arc-20160816; b=zCJmKW/x13qapuIrV6JfXnCAM3UpSZeQnm2GrJXvh5zbLOWEEhLuO3HA/6PBh6c80J dyM3usOz9wR4b94Nrt1WIdZBbsgf+qpGcCINhV0l9LXfgqYI1M49eftYHdGxQHGn0L0s 4oivyovyv6uZH7pVuoqDMl6iCDPQc7eIoAjwcfs99SalXGjIdgZHjs01Xp9o1RCJ/5eb CXwjVxrnfKG29OSYwNEKzC1IVipUr05c0/UHc7Ld9SxUKYcKabeuqWI/hBy3Wt9xUkZb 8uIzMO0SO834tAIUCmbe47rYdcPXax9uHtQ7TkpcEDEja7K2NKz705LD8si+nudalmfz I1Nw== 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=9O3BrIImE6U7EG73Sm0Si2lATSBswG93bmUPv4ZZQ68=; b=aTLmpmb+bW/dVaOX5fjm29qliL/zm2kXRGcwruVcsNNtWIzLhPmtxIz/JChN3/iuCV kdehuJzfe4Lo2jIrdPWCPKd+mwL2hFLCv3RTh8OroxL34+V6IUH73Uiy7xGtGxVi035J Wz0IgA4NtPBs1iya4wCmeFyhfcRBxV5lnN7t/mjy9n613D47CNgSItDzmpz+cTzCaFs5 /lj5BOfmeQAcetqD7brenMLPUf3bavtKCj4MH41OP0opff58mlcdpfWUEqabUAbVJCAr eAatxrbFNCMs6U9Bx//WbXurQywTJlTAW+2/a7f0mt3jnpQ56QcR5YaamIim98h6BPWL 72eg== 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 c16si2842091ejx.310.2020.06.18.17.15.22; Thu, 18 Jun 2020 17:15:47 -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 S1731975AbgFRUkU (ORCPT + 99 others); Thu, 18 Jun 2020 16:40:20 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:48844 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731307AbgFRUjV (ORCPT ); Thu, 18 Jun 2020 16:39:21 -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:12 -0700 Received: from sc9-mailhost2.vmware.com (unknown [10.129.221.29]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 11569B2656; Thu, 18 Jun 2020 16:39:16 -0400 (EDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Julien Thierry , Kamalesh Babulal , Matt Helsley Subject: [RFC][PATCH v5 22/51] objtool: mcount: Move has_rel_mcount() and tot_relsize() Date: Thu, 18 Jun 2020 13:38:08 -0700 Message-ID: <2511660716aabd9843ab58abef20425507aa354f.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 The has_rel_mcount() and tot_relsize() helpers are no longer dependent on the ELF wrapper so we can move them. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 26 ++++++++++++++++++++++++++ tools/objtool/recordmcount.h | 33 --------------------------------- 2 files changed, 26 insertions(+), 33 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index fae0b15d0632..918e47217379 100644 --- a/tools/objtool/recordmcount.c +++ b/tools/objtool/recordmcount.c @@ -446,6 +446,32 @@ static int nop_mcount(struct section * const rels, return 0; } +static char const *has_rel_mcount(const struct section * const rels) +{ + const struct section *txts; + if (rels->sh.sh_type != SHT_REL && rels->sh.sh_type != SHT_RELA) + return NULL; + txts = find_section_by_index(lf, rels->sh.sh_info); + if ((txts->sh.sh_type != SHT_PROGBITS) || + !(txts->sh.sh_flags & SHF_EXECINSTR)) + return NULL; + return txts->name; +} + +static unsigned tot_relsize(void) +{ + const struct section *sec; + unsigned totrelsz = 0; + char const *txtname; + + 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; + } + return totrelsz; +} + /* 32 bit and 64 bit are very similar */ #include "recordmcount.h" #define RECORD_MCOUNT_64 diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index 25028c61da2b..2733f7fde51d 100644 --- a/tools/objtool/recordmcount.h +++ b/tools/objtool/recordmcount.h @@ -20,8 +20,6 @@ #undef append_func #undef mcount_adjust #undef sift_rel_mcount -#undef has_rel_mcount -#undef tot_relsize #undef do_func #undef Elf_Shdr #undef Elf_Rel @@ -36,8 +34,6 @@ #ifdef RECORD_MCOUNT_64 # define append_func append64 # define sift_rel_mcount sift64_rel_mcount -# define has_rel_mcount has64_rel_mcount -# define tot_relsize tot64_relsize # define do_func do64 # define mcount_adjust mcount_adjust_64 # define Elf_Rel Elf64_Rel @@ -51,8 +47,6 @@ #else # define append_func append32 # define sift_rel_mcount sift32_rel_mcount -# define has_rel_mcount has32_rel_mcount -# define tot_relsize tot32_relsize # define do_func do32 # define mcount_adjust mcount_adjust_32 # define Elf_Rel Elf32_Rel @@ -165,33 +159,6 @@ static uint_t *sift_rel_mcount(uint_t *mlocp, return mlocp; } -static char const *has_rel_mcount(const struct section * const rels) -{ - const struct section *txts; - if (rels->sh.sh_type != SHT_REL && rels->sh.sh_type != SHT_RELA) - return NULL; - txts = find_section_by_index(lf, rels->sh.sh_info); - if ((txts->sh.sh_type != SHT_PROGBITS) || - !(txts->sh.sh_flags & SHF_EXECINSTR)) - return NULL; - return txts->name; -} - - -static unsigned tot_relsize(void) -{ - const struct section *sec; - unsigned totrelsz = 0; - char const *txtname; - - 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; - } - return totrelsz; -} - /* Overall supervision for Elf32 ET_REL file. */ static int do_func(unsigned const reltype) { -- 2.20.1