Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1543036ybg; Tue, 2 Jun 2020 12:53:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF87cvvAq2CZRB/f+eMQIw67MZBvYXM5t3k5sM/ICIJt+dAM2YddX9ATjSvN2xuSdIrEs0 X-Received: by 2002:a17:907:2058:: with SMTP id pg24mr15654189ejb.63.1591127636393; Tue, 02 Jun 2020 12:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591127636; cv=none; d=google.com; s=arc-20160816; b=UNvNArHVmR57qUvO8IsGFNvTh/5cM3PhtVbTE8hbAbV5UjvGWnGUgJRFFIMJUBJOIQ QUwY52FVPMn3VH9YaPQzUVkFhdCg70/kqKH+n53GGbmCfBqmPpTa52YjUOtp4lg3BAF0 j1Sf4hz0gTF879vCoPR5a3Y/T59nur7594OgpHKkt2LT65ekKe/Nhdz7Fp5mEJGd9znW 2i+eGrMK6HSnIP3KUD54YRH/XPjY3HidJ29QCx5JGAazlV7yQneO5p8uOD+fu6xL6M0F F8ODoHxdQblXVWx2wkZASg1YFDa57E0tkTXICwIHTbntEXg91egKM+RCU1B38kjvGJBx 1eAg== 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=3VZifmwG18PY8dQf7w0C0r9Xx05vuSmzhsvGyTnXKJI=; b=XTSV4pBz9xz7q8G5VFB/r6kcr8l5a0GApluNF2lj/qJDizzR/r8YEGLq5tOksII7B3 2kyulbnIFffzzko3kL7zVXKQryXwJgjK22qIBtFQeibuBtndBHaRj9RLXaQdikOn0nAE +2cyxy2INptzjriUVTlnOVb5YusRnLsZqrwwQvkjSEF1YhK6AiVo+zv/9JnMe98caJYz ROeXn1/jndmGjKV0aIv5hRYfgVjMOiTmfpix+xPK/+0A6xqotDRUyEGoYk2LcKGj8ZuW b0raF9Mr+ioIO+DQrM4v1YpOc/Bp3wCwJyUvuUO/jDjaw+NvuAJLOnqqUitEO9/hab6Z ArCA== 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 b10si1968174edr.286.2020.06.02.12.53.29; Tue, 02 Jun 2020 12:53:56 -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 S1728461AbgFBTvS (ORCPT + 99 others); Tue, 2 Jun 2020 15:51:18 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:36862 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728363AbgFBTvC (ORCPT ); Tue, 2 Jun 2020 15:51:02 -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:50:58 -0700 Received: from sc9-mailhost3.vmware.com (unknown [10.200.192.49]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 1255140BEE; Tue, 2 Jun 2020 12:50:59 -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 16/32] objtool: mcount: Restrict using ehdr in append_func() Date: Tue, 2 Jun 2020 12:50:09 -0700 Message-ID: <735691b9308adaa3cc1e4b15506459e4c9e8ad57.1591125127.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-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 Use the ehdr parameter to append_func() to write the ELF file's header but use the objtool ELF header data as the basis for making changes. The makes it clearer when we can switch from using the old recordmcount wrapper to write the ELF file because ehdr will only be passed on to uwrite() calls and those will get replaced later. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/objtool/recordmcount.h b/tools/objtool/recordmcount.h index 98cf9eea6074..7ebc617fb3a6 100644 --- a/tools/objtool/recordmcount.h +++ b/tools/objtool/recordmcount.h @@ -99,8 +99,8 @@ static int append_func(Elf_Ehdr *const ehdr, char const *mc_name = (sizeof(Elf_Rela) == rel_entsize) ? ".rela__mcount_loc" : ".rel__mcount_loc"; - unsigned const old_shnum = w2(ehdr->e_shnum); - uint_t const old_shoff = _w(ehdr->e_shoff); + unsigned const old_shnum = lf->ehdr.e_shnum; + uint_t const old_shoff = lf->ehdr.e_shoff; uint_t const old_shstr_sh_size = _w(shstr->sh_size); uint_t const old_shstr_sh_offset = _w(shstr->sh_offset); uint_t t = 1 + strlen(mc_name) + _w(shstr->sh_size); @@ -167,7 +167,7 @@ static int append_func(Elf_Ehdr *const ehdr, return -1; ehdr->e_shoff = _w(new_e_shoff); - ehdr->e_shnum = w2(2 + w2(ehdr->e_shnum)); /* {.rel,}__mcount_loc */ + ehdr->e_shnum = w2(2 + lf->ehdr.e_shnum); /* {.rel,}__mcount_loc */ if (ulseek(0, SEEK_SET) < 0) return -1; if (uwrite(ehdr, sizeof(*ehdr)) < 0) -- 2.20.1