From patchwork Mon Oct 2 12:27:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 76942 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6B2F238555B9 for ; Mon, 2 Oct 2023 12:27:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B2F238555B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696249668; bh=MAczOHt7iOunX4kP09bKzeklkDhPzakk/ZciO/v1z9w=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Dpicbaz2WcRsXWjHDEm0H/TsLz//YBOPm3dikpQY1De/meG820J0kKm8/UZ7UNNPZ oCyNpi/DaZqzi+hB5HCjhrnIW1EsRzyIrUW1QsH9TrhEUquCAB1UfZzNzePz/1c19F P78I/MjhMjJ3JwwjarkQxAo4hsK+ZDQ8B0PnMYNs= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 020FF3858C5E for ; Mon, 2 Oct 2023 12:27:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 020FF3858C5E Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-491-4QAcAulrMcCOwtPKhJaI9A-1; Mon, 02 Oct 2023 08:27:17 -0400 X-MC-Unique: 4QAcAulrMcCOwtPKhJaI9A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7282800B35 for ; Mon, 2 Oct 2023 12:27:16 +0000 (UTC) Received: from prancer.redhat.com (unknown [10.42.28.106]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97DD740C2064 for ; Mon, 2 Oct 2023 12:27:16 +0000 (UTC) To: binutils@sourceware.org Subject: Commit: Use bfd_get_current_time more widely Date: Mon, 02 Oct 2023 13:27:15 +0100 Message-ID: <87leclp5uk.fsf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Nick Clifton via Binutils From: Nick Clifton Reply-To: Nick Clifton Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Sender: "Binutils" Hi Guys, I am applying the patch below to simplify some of the code in the linker and the BFD library. There were a couple of places where we were testing for and using the SOURCE_DATE_EPOCH environment variable. Since we now have a BFD library function that does this, there is no need for separate code. Cheers Nick bfd/ChangeLog * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Use bfd_get_current_time when filing in the timestamp. ld/ChangeLog * pe-dll.c (fill_edata): Use bfd_get_current_time when filling in the timestamp. diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index 2f2968d48e8..641c259d04b 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -839,17 +839,7 @@ _bfd_XXi_only_swap_filehdr_out (bfd * abfd, void * in, void * out) option was chosen. */ if ((pe_data (abfd)->timestamp) == -1) { - time_t now; - char *source_date_epoch; - - /* If the SOURCE_DATE_EPOCH environment variable is - defined then use that as the time, otherwise use - the current time. */ - source_date_epoch = getenv ("SOURCE_DATE_EPOCH"); - if (source_date_epoch) - now = (time_t) strtoll (source_date_epoch, NULL, 10); - else - now = time (NULL); + time_t now = bfd_get_current_time (0); H_PUT_32 (abfd, now, filehdr_out->f_timdat); } else diff --git a/ld/pe-dll.c b/ld/pe-dll.c index df08a57e644..fc83f5208d6 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -1232,15 +1232,7 @@ fill_edata (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED) if (pe_data (abfd)->timestamp == -1) { - time_t now; - char *source_date_epoch; - - source_date_epoch = getenv ("SOURCE_DATE_EPOCH"); - if (source_date_epoch) - now = (time_t) strtoll (source_date_epoch, NULL, 10); - else - now = time (NULL); - + time_t now = bfd_get_current_time (0); H_PUT_32 (abfd, now, edata_d + 4); } else