Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp548309ybt; Sat, 13 Jun 2020 12:52:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnFQdXLfKKMwW1Vr6eNgIMBh3E8cGmqY6DFAcjhF3OIBxHRfBaLkIPi+57sF9e9iEU9RS4 X-Received: by 2002:a17:906:ae88:: with SMTP id md8mr19778790ejb.347.1592077921636; Sat, 13 Jun 2020 12:52:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592077921; cv=none; d=google.com; s=arc-20160816; b=R2zIqLR3pCaSg0jHqZiJvTLgytZZkekMkc3qpebVB9E2skDxt0QYisW0x8RpqyURIj gogBLbeuBee7wSjx7MgzwowRybh/Syv/W4ifBBLiWZY/Mce48UDiRl54jLR32YGnUmy6 48WRY2ElygIAUQ8FWXMpZn6r+74iqjpQxY8OKntla3kagz4Pdr7vFSbCS4jF6hIBU766 QCDqw2hxVzBdb4sl6/Ao3L9l4E7/LCXxxdFEB8/aywo2rpTIOnUnospjSau8yMD2iOD7 QloiPOmI56afkz64o776aozPX/OqZWCZKPfRb57ulOTBM++cZGigNTa4YVKqASjVf/3/ Tn8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date; bh=CELRTq08MaJgzPN+e/ajW2rq1+CEvQwCG3JEPOw00GQ=; b=z2M9AIOPcW6mXYzKsX6kMtDjxsgUSGpZd5ms83InfTUFHn+dps7MeNhtxt+JV6HoLW q2FdWKFbs65gsJ/1orFjHNgvhlNpzVkOry+EWWGSATdhCoPjTlIzLp7CRgrZDP1rJjtb XLlt+my8ph6gmH5IDHQAGTu+bsO81ZnFsqbPwnIC3wGrTW2LnHxCl83O9iEa0fkc/uuw DQjeP76h16Bjn589OKWqJH3zlWYTNbfY8194n2yKoFna3lx/PRjduBNWoVGVqBqFeIVd 8KqMKfTZoWOZdVq/YO9dS+I4nFthPb+zqa5bY7PNLw6uDVstM+tOK1MX/jnlZ2TobHgH COpA== 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 n20si5632583edt.487.2020.06.13.12.51.38; Sat, 13 Jun 2020 12:52:01 -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 S1726507AbgFMTtQ (ORCPT + 99 others); Sat, 13 Jun 2020 15:49:16 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:25967 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbgFMTtN (ORCPT ); Sat, 13 Jun 2020 15:49:13 -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; Sat, 13 Jun 2020 12:49:07 -0700 Received: from localhost (unknown [10.200.193.92]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 3DD1DB13F0; Sat, 13 Jun 2020 15:49:13 -0400 (EDT) Date: Sat, 13 Jun 2020 12:49:12 -0700 From: Matt Helsley To: Peter Zijlstra CC: , Josh Poimboeuf , Steven Rostedt , Sami Tolvanen , Julien Thierry , Kamalesh Babulal Subject: Re: [RFC][PATCH v4 18/32] objtool: mcount: Move nop_mcount() Message-ID: <20200613194912.GB25598@rlwimi.vmware.com> Mail-Followup-To: Matt Helsley , Peter Zijlstra , linux-kernel@vger.kernel.org, Josh Poimboeuf , Steven Rostedt , Sami Tolvanen , Julien Thierry , Kamalesh Babulal References: <7109ceb239a88c2901eeb7f52c29f69cdb413cd3.1591125127.git.mhelsley@vmware.com> <20200612132656.GQ2531@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200612132656.GQ2531@hirez.programming.kicks-ass.net> 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 On Fri, Jun 12, 2020 at 03:26:56PM +0200, Peter Zijlstra wrote: > On Tue, Jun 02, 2020 at 12:50:11PM -0700, Matt Helsley wrote: > > +static int nop_mcount(struct section * const rels, > > + const char *const txtname) > > +{ > > + struct reloc *reloc; > > + struct section *txts = find_section_by_index(lf, rels->sh.sh_info); > > + unsigned mcountsym = 0; > > + int once = 0; > > + > > + list_for_each_entry(reloc, &rels->reloc_list, list) { > > + int ret = -1; > > + > > + if (!mcountsym) > > + mcountsym = get_mcountsym(reloc); > > + > > + if (mcountsym == GELF_R_INFO(reloc->sym->idx, reloc->type) && !is_fake_mcount(reloc)) { > > This makes no sense to me; why not have mcountsym be a 'struct symbol > *' and have get_mcountsym() return one of those. > > if (reloc->sym == mcountsym && ... ) > > is much nicer, no? Indeed! I'll change it from returning an unsigned long to struct symbol * before I move it out of the wrapper code. > > > + if (make_nop) { > > + ret = make_nop(txts, reloc->offset); > > + if (ret < 0) > > + return -1; > > + } > > + if (warn_on_notrace_sect && !once) { > > + printf("Section %s has mcount callers being ignored\n", > > + txtname); > > + once = 1; > > + /* just warn? */ > > + if (!make_nop) > > + return 0; > > + } > > + } > > + > > + /* > > + * If we successfully removed the mcount, mark the relocation > > + * as a nop (don't do anything with it). > > + */ > > + if (!ret) { > > + reloc->type = rel_type_nop; > > + rels->changed = true; > > I have an elf_write_rela(), I'll make sure to Cc you. Thanks! I might also make use of your patch to rewrite instructions. We need a way to turn certain prologue instructions into nops. Would it be more widely useful to move that functionality out of mcount and into the objtool ELF/per-arch code or do you think it's better inside the mcount subcommand code? Cheers, -Matt