Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1646810ybt; Thu, 18 Jun 2020 13:47:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPC7qnMcbf/50uCcbCFNgIqRWM/EB3PVD2EFZhAic00KISAPQ3eOp2Q7jCZoScbuiGrkuC X-Received: by 2002:aa7:d698:: with SMTP id d24mr98059edr.56.1592513238550; Thu, 18 Jun 2020 13:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592513238; cv=none; d=google.com; s=arc-20160816; b=OaX2K+5NTUfHpXJJpA0qLiPWFENFLuLVYn865CfNWO7+Y3lb8t43/S+IxkvcWOqXTB JeT2Is+1o7u69Wx4IIoqI6QD9nvPls1juAdy1Wu0l1jehSDROkOaNvmzMgbTApTLX5BX hg41Wrv30eDOEbHr3X9xz2Zs50vpKXvDW29SsfhZSzNDui4PjRJc90emqelCv1fXAJdh bzKGrhSSlmGMs90ZnZaZQoRKq5gQH9vjFv5cgaPxbk6b0Mo6yhkM+EYvPrSYg85cgzHX 2D+ro1m6IbiynTKqIVVH2uchuNdR0yT82h/cUeBrpAOzJs17+yMGUTniCSrmxzAfgSb4 /x2A== 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=OzWNzt/N0JrVazPn6M1pS5JRR3HIL28bGRTCy5jzPh4=; b=Val0ztjEP8HHb5HxWtF+SGlWP37BkpvT6aixbFpnUx/2vF1GxlST8r7zuE3TqiJKNg zAQsEEOYIfB6utNYeQPJN2te2694ZYsPhGy9gACNqUnZMhcTZveiDoNwXorHGkb3pF1w i7+vlvaRNhxlmsoVZm1fvSBhLXH8NgVKXFkCe3cmTBT0z9ZBIodX8PRbQX3BjX9aKTUC uJYPIrvbLcmv1CUbHuDoM3VPm5hzsOp9ymUiFY0uWC3ZDZDlN/QGY9j4d4BtagAULdm1 8tTMIJ9iaNT2pMXDB4dFHZ2hNaoH0S9s2fUaS/a4MYCFYia8QRigbB9Ia4/VF0wKtz7G +08Q== 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 s15si2545455ejz.132.2020.06.18.13.46.56; Thu, 18 Jun 2020 13:47:18 -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 S1731791AbgFRUkA (ORCPT + 99 others); Thu, 18 Jun 2020 16:40:00 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:4267 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731201AbgFRUjT (ORCPT ); Thu, 18 Jun 2020 16:39:19 -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:14 -0700 Received: from sc9-mailhost2.vmware.com (unknown [10.129.221.29]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id A7AD4B2656; Thu, 18 Jun 2020 16:39:17 -0400 (EDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Julien Thierry , Kamalesh Babulal , Matt Helsley Subject: [RFC][PATCH v5 24/51] objtool: mcount: Only keep ELF file size Date: Thu, 18 Jun 2020 13:38:10 -0700 Message-ID: <7b8b10fd9af71b621e784e82b8d9575d12047879.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 Since we're no longer writing to the ELF file mapping and we're not appending to it we don't need to keep more information from the stat structure. At the same time we can give the smaller global variable a better name. Signed-off-by: Matt Helsley --- tools/objtool/recordmcount.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/objtool/recordmcount.c b/tools/objtool/recordmcount.c index 29f299e5bb52..aa35173de3d9 100644 --- a/tools/objtool/recordmcount.c +++ b/tools/objtool/recordmcount.c @@ -48,17 +48,17 @@ static int fd_map; /* File descriptor for file being modified. */ static int mmap_failed; /* Boolean flag. */ static char gpfx; /* prefix for global symbol name (sometimes '_') */ -static struct stat sb; /* Remember .st_size, etc. */ static const char *altmcount; /* alternate mcount symbol name */ extern int warn_on_notrace_sect; /* warn when section has mcount not being recorded */ static void *file_map; /* pointer of the mapped file */ +static size_t file_map_size; /* original ELF file size */ static struct elf *lf; static void mmap_cleanup(void) { if (!mmap_failed) - munmap(file_map, sb.st_size); + munmap(file_map, file_map_size); else free(file_map); file_map = NULL; @@ -93,11 +93,13 @@ static void * umalloc(size_t size) */ static void *mmap_file(char const *fname) { + struct stat sb; + /* Avoid problems if early cleanup() */ fd_map = -1; mmap_failed = 1; file_map = NULL; - sb.st_size = 0; + file_map_size = 0; lf = elf_open_read(fname, O_RDWR); if (!lf) { @@ -129,6 +131,7 @@ static void *mmap_file(char const *fname) } } else mmap_failed = 0; + file_map_size = sb.st_size; out: fd_map = -1; -- 2.20.1