Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1543644ybg; Tue, 2 Jun 2020 12:55:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYn3jcajSoGYl1L8g1pSbfqEaS62IsmVFtZ72FTRxDEIsu8uGQOtdfVHpE4wPTNFk8fdxz X-Received: by 2002:a50:ccc5:: with SMTP id b5mr26801890edj.340.1591127700177; Tue, 02 Jun 2020 12:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591127700; cv=none; d=google.com; s=arc-20160816; b=F8sRTwsDB89ofWrNF8kHfNFm8xmxPuQOZlhAtvAUy9slZMqeybNsOilpsmX5tgfgY7 w0kH/t97vMjGQ5mQXN3PeIkK4IyYz3nQ0u2cunUAdzhFEUbDbJSu+QN/EZ/knjHlIOqe ig3d/JaiGe0CiqnDragCs4X9gfS8WOAwL6Zw1MwPdGIqOTIJOB1QwpK+FbkozQBMX8Gl /Hm4DzB0F2m3cmfHkYq3vUYexM0xl0tg1ebHZFt8nLDEkSsNaeA8xqCQCwKZ0j9FOuS/ 0qzkooeWbAtU50uEa9QQUEFMfD1dO1f0Vy9gRkcm7qpqoIZWPiFRla7rCQvQclzGW3Kw GIKw== 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=s2qt0F4ZeLGBwA6tlgV8mOd74uVFtlUiWVIooUXFI+c=; b=rRz/7j1CQKFo1DgqfVkhvIFvrm7OvzNpqQodIggpMN7UOdENliHMKxyE5HCgYnrAwL FFJ2JsX1B3nwElBtUu5BwBC7eT7p+ZrprIZd42pq5e9AnIefsgsa9E/IwyzlQTFkdbjN YAeEJeGGMnwCUxbwG6yjM4P2TgJD3ho3YV9Fp1ekSk7SVhWNUQ234GqQOMrsr7FvDFf/ idk2ZgvGn2jQ9C7L/K/GDQnTNj8oBUwt9rMsCikainUOxBAlPlZAFxvzv8b1Vl8WbdE3 q9pPdkgp87e1o3WDsaekVZ73JfHtZppZUYWHJJq4pyY01tFznCAU0e2SxS6DIauddLAo k2Fw== 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 d6si1999664edv.364.2020.06.02.12.54.37; Tue, 02 Jun 2020 12:55:00 -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 S1728596AbgFBTv4 (ORCPT + 99 others); Tue, 2 Jun 2020 15:51:56 -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 S1728386AbgFBTvF (ORCPT ); Tue, 2 Jun 2020 15:51:05 -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:51:02 -0700 Received: from sc9-mailhost3.vmware.com (unknown [10.200.192.49]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id 037FF40BED; Tue, 2 Jun 2020 12:51:02 -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 21/32] objtool: mcount: Only keep ELF file size Date: Tue, 2 Jun 2020 12:50:14 -0700 Message-ID: <735f431969b4ffb21251ce7f491a262dff9293bc.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 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 6feb4e6b4113..85e95e1ea6f6 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