Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1646461ybt; Thu, 18 Jun 2020 13:46:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ6Y294RAEgqh+du7HsVz8A0rGfCmpP+MqhqLiFo+32jrdfs7noCTXiceRfM9RLVMfwFHT X-Received: by 2002:a17:906:2c10:: with SMTP id e16mr476097ejh.189.1592513207546; Thu, 18 Jun 2020 13:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592513207; cv=none; d=google.com; s=arc-20160816; b=N8bkb+QxboLZoBLKqd0KKz1zSYY8eq5SXPsMqjX5NRhl6ExMtLFnQMcGG1aecBTI6E 0Y9FJ0giiGHgXj6fZASfRGOWzf7MfXfvulFbf2PL2PmUOq/rwbpAf0WKYTim3E5XxOfq ouUa81KhdaPwmhFTo+YgBgxz3uxNkYtamzOzWT9E3ErxtR+cRQmXXvuIMIlYaMMIGwOn p2reHag2wVRQErDEO7BSYx6OV/PwR+hSf1bYCg6C+vKwaM4lUqEzWqrbSkop8WtTheA3 YBpzW/j4rgHs31N5mZ3xnviTD9SgbhEiwHSwPepBv0mhK0SMY609fMz/uguhXkB58INx 7Y9g== 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=BqeGcPY6Wa5TZ9XsSFx/sESGIPGimta/KcqlTdGVaLI=; b=bevLCRdtwJZ2zyT0zfGGbwU4Q15l5JAsV6gBCm4BgDDfOtdRTUPz5KvY+D8FxEgt6o GsiURhUlnuQcucvw4nmMCptM6kpwvMSSPk4zk32Drn+hfEFi8BCMzJU8bY9VA2ZAykMG nHzZV1f25985Z8apcuKLW3v1zrB+kc6Af6D/ZhVFxhGbrMEaeRu0ZJGzR0YZ7VjVQ94y PublxiC1XgjJBeK1xMXbbT5m4qvYgFuWe/3cDe3Rj3uiR1BoAZwqh1B3mn4Fbm7PuqOH n/olU0WRG0R7vKJfR7kBlOpmrEiH25qB3LgykxU38Hwd2iloDcDsyvl1ODOxpvJp4Odo +XYw== 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 np3si2547969ejb.144.2020.06.18.13.46.22; Thu, 18 Jun 2020 13:46: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 S1731444AbgFRUjp (ORCPT + 99 others); Thu, 18 Jun 2020 16:39:45 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:3944 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730998AbgFRUjL (ORCPT ); Thu, 18 Jun 2020 16:39:11 -0400 Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Thu, 18 Jun 2020 13:39:05 -0700 Received: from sc9-mailhost2.vmware.com (unknown [10.129.221.29]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id A8BBFB2656; Thu, 18 Jun 2020 16:39:08 -0400 (EDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Julien Thierry , Kamalesh Babulal , Matt Helsley Subject: [RFC][PATCH v5 13/51] objtool: mcount: Return symbol from mcountsym Date: Thu, 18 Jun 2020 13:37:59 -0700 Message-ID: <11eeca2d50d0609e0d63dc1760692ca00ee6e660.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-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 Before we can move this function out of the wrapper and into wordsize-independent code we need to return the relocation symbol information in a size-independent fashion. Previously we compared the raw info bits but that requires passing around an unsigned long. Instead we just use a pointer to the objtool struct symbol which callers can use as-needed. Reported-by: Kamalesh Babulal Signed-off-by: Matt Helsley Co-developed-by: Kamalesh Babulal Co-developed-by: Peter Zijlstra -- Thanks to Kamalesh Babulal for reporting this problem and suggesting a fix. Thanks to Peter Zijlstra for recommending an enhancement to the fix. --- tools/objtool/recordmcount.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index df8384f8e9e7..6ac120aa45af 100644 --- a/tools/objtool/recordmcount.h +++ b/tools/objtool/recordmcount.h @@ -271,7 +271,7 @@ static int append_func(Elf_Ehdr *const ehdr, return elf_write(lf); } -static unsigned get_mcountsym(struct reloc *reloc) +static struct symbol *get_mcountsym(struct reloc *reloc) { struct symbol *sym = reloc->sym; char const *symname = sym->name; @@ -283,8 +283,8 @@ static unsigned get_mcountsym(struct reloc *reloc) if (strcmp(mcount, symname) == 0 || (altmcount && strcmp(altmcount, symname) == 0) || (strcmp(fentry, symname) == 0)) - return GELF_R_INFO(reloc->sym->idx, reloc->type); - return 0; + return sym; + return NULL; } /* @@ -303,14 +303,14 @@ static uint_t *sift_rel_mcount(uint_t *mlocp, uint_t *const mloc0 = mlocp; Elf_Rel *mrelp = *mrelpp; unsigned int rel_entsize = rels->sh.sh_entsize; - unsigned mcountsym = 0; + struct symbol *mcountsym = NULL; struct reloc *reloc; list_for_each_entry(reloc, &rels->reloc_list, list) { if (!mcountsym) mcountsym = get_mcountsym(reloc); - if (mcountsym == GELF_R_INFO(reloc->sym->idx, reloc->type) && !is_fake_mcount(reloc)) { + if (mcountsym == reloc->sym && !is_fake_mcount(reloc)) { uint_t const addend = _w(reloc->offset - recval + mcount_adjust); mrelp->r_offset = _w(offbase @@ -342,7 +342,7 @@ static int nop_mcount(struct section * const rels, + (void *)ehdr); struct reloc *reloc; Elf_Shdr const *const shdr = &shdr0[rels->sh.sh_info]; - unsigned mcountsym = 0; + struct symbol *mcountsym = NULL; int once = 0; list_for_each_entry(reloc, &rels->reloc_list, list) { @@ -351,7 +351,7 @@ static int nop_mcount(struct section * const rels, if (!mcountsym) mcountsym = get_mcountsym(reloc); - if (mcountsym == GELF_R_INFO(reloc->sym->idx, reloc->type) && !is_fake_mcount(reloc)) { + if (mcountsym == reloc->sym && !is_fake_mcount(reloc)) { if (make_nop) { ret = make_nop((void *)ehdr, _w(shdr->sh_offset) + reloc->offset); if (ret < 0) -- 2.20.1