Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp911691ybb; Fri, 10 Apr 2020 12:40:39 -0700 (PDT) X-Google-Smtp-Source: APiQypIY70eE33oM/PVoswpNepnYrnXn31A7Y6zQ24oXZBwkHea6Kfxss6D92u4Lm+5BylHd6Y5q X-Received: by 2002:a37:278c:: with SMTP id n134mr5840213qkn.348.1586547639205; Fri, 10 Apr 2020 12:40:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586547639; cv=none; d=google.com; s=arc-20160816; b=ENuMlXOiCzB77KKT+R8bAA1weytfGEU5JrqO/+oB1NbYmbMg2ic24Yqm6A2qI39AWv gV3Rf5MnenuMVBxLOGvsZSfGoY5OwXFVSMZmZI9tGfduiwMUd7zvnu/yf/bdta1Zd5TE AV0TtVpwlVfXtedU4Q6J1WxjKEBUvOPBaEH39TQPNeHTdO1tPrXvtJYiUPVBwElxcYbz gZCDVgHGMqGxCAnTQ0lipug0TO6a1O+/vvgOrBN4t3GPO0G/xt6tTeFDOV6Igp+wT8NF ZdDXDDk42PvdM3oBkE9X9oYws116OgjyqNIeR2UrRzA7W/Oqh2m50vlto1lHrYGpfNkA 38+g== 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=0uSWzVdv8KuZLuvtecTwK4pIhzFeQRjB1s08tQzWYbA=; b=Pw5FKeR//bV9OsfvZ1KOfWsDD8Wf7Yni9i4f223uXuBADVTn7rFjwDq9H+qHI6ob5d K2uA3hxzv/gmtaIsAwmaqpFidST17KgxbkFx8XvnabzP58/dN834MNPOSpsJalJumUKM EHg+Sua8ciRzlU3kO4gZ8WiVfAgFfU2rMQgYef54a1rWg6uxDODYR/Zbx1QXJZNduqRD FsjaJZ14MuXTqiZIoUxIyf65+LMRYjpK8spS95++mleaqVH/3cogf7s9022eqU+19w/x aA5Cg1bMR1ISZQncStxoQ7Y4ZUEafdL65L8B/h+18H/gYJ0U6/JaT7bKiXMmbfSiMOg+ tkMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si1320278qtb.386.2020.04.10.12.40.24; Fri, 10 Apr 2020 12:40:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727080AbgDJTir (ORCPT + 99 others); Fri, 10 Apr 2020 15:38:47 -0400 Received: from ex13-edg-ou-001.vmware.com ([208.91.0.189]:28734 "EHLO EX13-EDG-OU-001.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbgDJTiq (ORCPT ); Fri, 10 Apr 2020 15:38:46 -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; Fri, 10 Apr 2020 12:38:42 -0700 Received: from sc9-mailhost3.vmware.com (unknown [10.166.69.226]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 1A263B2C9B; Fri, 10 Apr 2020 15:38:46 -0400 (EDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Julien Thierry , Ingo Molnar , Steven Rostedt , Miroslav Benes , Matt Helsley Subject: [RFC][PATCH 26/36] objtool: mcount: Only keep ELF file size Date: Fri, 10 Apr 2020 12:35:49 -0700 Message-ID: <3bc0af0d3ba3ab8f9582e4aaf54c85be9ebfbea5.1586468801.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-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 95b93767d6eb..6de744aaf4c8 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_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