Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1545515ybg; Tue, 2 Jun 2020 12:58:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGIBDNKla+9mIt3dFivzdsGGfyh7Gwcu+8P33NqPYwPzIwPki8fPWxTtMmfV2oPR6RhgsT X-Received: by 2002:a17:906:5fcd:: with SMTP id k13mr12370077ejv.459.1591127916340; Tue, 02 Jun 2020 12:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591127916; cv=none; d=google.com; s=arc-20160816; b=hzMtzNJogIdst58b6uI7j1kQ1tZh1ZeIcAKUj7Xq0jCQGgnzrdULciI+2KrzNAUsQ/ 4JVVJyZiTQC3cgEbIsZq6Kq79569HopiMhaf77gkx4buSXY6qyWd7AdNULLZWI9v7WD4 9QiZem0/mxYush1AAAMjUBrXayO/HqckBdVaK0S7IomSU/nW/TBT9ZFGtRalP5xqMEGf aovhqB2JzNF7XiDJ5h61Xl0yoY+slnVfeZp4pXavJJWm8AAviB/BHpUbgSpEemcXWGfD GnpARKhIUdw40feGwY4qsp8NokhZDlGp8aPXDXRYyKiClSF0Mz28liJsFE9rwOoCkGQO wqeQ== 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=v1eNrhwbmkMiGgTkqT7iGWAAT57qDBb1Lu7bE2EgM2U=; b=eCtCoXS872piDbn6exfL5pj8qQo0RDZHI7fjqeicml/JH/g+xtHulGqneD+eURtyqF VfKyN2E3YpLysm6P+nd6HsKtfMGxNhlFj5klDmDqsz/U8iKOJPmZu8OUWTNufhKdl698 4a6l0D42ZBliY/xPyJZ3ZMK3pWb3zNa0caEhNcORbeiQ7BXMdQ9vcn71BRydHNaxgDGN KDtW2gJYldWt+/2TfTfWWtcRFlezcAW70P9c9CDYKPaeLxoUCYMEXOSvhQkB+cAxOCS1 hz6MPwBO0jxC9eGOK3W0NNz+eZEDTelFKLVBYMbNSbk7s6xQMAn3Evlg1CyO0FMkekNl XdjQ== 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 j21si1891978ejc.497.2020.06.02.12.58.13; Tue, 02 Jun 2020 12:58:36 -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 S1728766AbgFBTxH (ORCPT + 99 others); Tue, 2 Jun 2020 15:53:07 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:29399 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbgFBTxE (ORCPT ); Tue, 2 Jun 2020 15:53:04 -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:07 -0700 Received: from sc9-mailhost3.vmware.com (unknown [10.200.192.49]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 5940F40BEE; Tue, 2 Jun 2020 12:51:08 -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 28/32] objtool: mcount: Move sift_rel_mcount out of wrapper file Date: Tue, 2 Jun 2020 12:50:21 -0700 Message-ID: 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 Now that this function no longer uses any of the old recordmcount wrapper code we can move it out of the wrapper too. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 47 +++++++++++++++++++++++++++++++++ tools/objtool/recordmcount.h | 50 ------------------------------------ 2 files changed, 47 insertions(+), 50 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index ef3c360a3db9..601be2504666 100644 --- a/tools/objtool/recordmcount.c +++ b/tools/objtool/recordmcount.c @@ -394,6 +394,53 @@ static int mcount_adjust = 0; /* Size of an entry in __mcount_loc; 4 or 8 */ static size_t loc_size; +/* + * Look at the relocations in order to find the calls to mcount. + * Accumulate the section offsets that are found, and their relocation info, + * onto the end of the existing arrays. + */ +static void sift_rel_mcount(GElf_Addr **mlocpp, + GElf_Sxword *r_offsetp, + void **const mrelpp, + const struct section * const rels, + unsigned const recsym_index, + unsigned long const recval, + unsigned const reltype, + bool is_rela) +{ + GElf_Rel *mrelp = *mrelpp; + GElf_Rela *mrelap = *mrelpp; + unsigned int mcount_sym_info = 0; + struct reloc *reloc; + + list_for_each_entry(reloc, &rels->reloc_list, list) { + unsigned long addend; + + if (!mcount_sym_info) + mcount_sym_info = get_mcount_sym_info(reloc); + + if (mcount_sym_info != GELF_R_INFO(reloc->sym->idx, reloc->type) || is_fake_mcount(reloc)) + continue; + + addend = reloc->offset - recval + mcount_adjust; + if (is_rela) { + mrelap->r_offset = *r_offsetp; + mrelap->r_info = GELF_R_INFO(recsym_index, reltype); + mrelap->r_addend = addend; + mrelap++; + **mlocpp = 0; + } else { + mrelp->r_offset = *r_offsetp; + mrelp->r_info = GELF_R_INFO(recsym_index, reltype); + mrelp++; + **mlocpp = addend; + } + (*mlocpp)++; + r_offsetp += loc_size; + } + *mrelpp = is_rela ? (void *)mrelap : (void *)mrelp; +} + /* 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 b58f0cc58f76..f12189331e27 100644 --- a/tools/objtool/recordmcount.h +++ b/tools/objtool/recordmcount.h @@ -17,67 +17,17 @@ * This conversion to macros was done by: * Copyright 2010 Steven Rostedt , Red Hat Inc. */ -#undef sift_rel_mcount #undef do_func #undef Elf_Rela #ifdef RECORD_MCOUNT_64 -# define sift_rel_mcount sift64_rel_mcount # define do_func do64 # define Elf_Rela Elf64_Rela #else -# define sift_rel_mcount sift32_rel_mcount # define do_func do32 # define Elf_Rela Elf32_Rela #endif -/* - * Look at the relocations in order to find the calls to mcount. - * Accumulate the section offsets that are found, and their relocation info, - * onto the end of the existing arrays. - */ -static void sift_rel_mcount(GElf_Addr **mlocpp, - GElf_Sxword *r_offsetp, - void **const mrelpp, - const struct section * const rels, - unsigned const recsym_index, - unsigned long const recval, - unsigned const reltype, - bool is_rela) -{ - GElf_Rel *mrelp = *mrelpp; - GElf_Rela *mrelap = *mrelpp; - unsigned int mcount_sym_info = 0; - struct reloc *reloc; - - list_for_each_entry(reloc, &rels->reloc_list, list) { - unsigned long addend; - - if (!mcount_sym_info) - mcount_sym_info = get_mcount_sym_info(reloc); - - if (mcount_sym_info != GELF_R_INFO(reloc->sym->idx, reloc->type) || is_fake_mcount(reloc)) - continue; - - addend = reloc->offset - recval + mcount_adjust; - if (is_rela) { - mrelap->r_offset = *r_offsetp; - mrelap->r_info = GELF_R_INFO(recsym_index, reltype); - mrelap->r_addend = addend; - mrelap++; - **mlocpp = 0; - } else { - mrelp->r_offset = *r_offsetp; - mrelp->r_info = GELF_R_INFO(recsym_index, reltype); - mrelp++; - **mlocpp = addend; - } - (*mlocpp)++; - r_offsetp += loc_size; - } - *mrelpp = is_rela ? (void *)mrelap : (void *)mrelp; -} - /* Overall supervision for Elf32 ET_REL file. */ static int do_func(unsigned const reltype) -- 2.20.1