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: 147269 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp1389440vqb; Mon, 2 Oct 2023 05:27:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwpHlPimgykN9DFZd0sB7ABt6bNvLGdBkhYw6ikdTiThOoxW/FTz57bdjzr2A4+Gv/laFx X-Received: by 2002:a05:6402:1859:b0:530:8a17:39e0 with SMTP id v25-20020a056402185900b005308a1739e0mr10210548edy.13.1696249650139; Mon, 02 Oct 2023 05:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696249650; cv=none; d=google.com; s=arc-20160816; b=NwGZKZY+/QH7b9BaBKMx6FLu3GHXoRf3YxYePwZpZe7yKjRrHNvrM4Ht1gjMTI+xDT S4/u3Gf9xcvovmwLmOQ7vfqcb7TIS6K1oONar6AKdMFy9zUC8ETd6P/zCO7VUyuotrq7 hoR+FfXeh8gZuN/eNOPLRtc8HZjy6Sg5MBQ38RmTVAcuEojB0b88fhvTDmbMhS4Fda4g J58aPbRONOJoH6qGgKOzj80aW0mQLX3Aoc69HvsvthXq/Uz9J7iG5GI3GEFwobpT8d/L lsK1ARSMtruFUcAGLCnpIj6IIjdVLbVYtg6UowlwFkDb2IeQwQKafuIcBm4poSGWhcBl Ez5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=MAczOHt7iOunX4kP09bKzeklkDhPzakk/ZciO/v1z9w=; fh=NLxAvL/bDfPg4AGOtxqvQlND8vazkZrNzKLY8+LAbBY=; b=B7IzOwQeS63Ntfk5JZBGpVkSUfSfhIZ6jZ7THiUplu2BYexofM2/AkbTXB2Dy90aJO ps2FzRQH9G8JWftDg0czZ0rlYWPRVx3avyyxYqVuTix1K8nRCdWGWKnT4jsJkyxzbXxk UUdlxsjBNdzorVF2//a96vCLsYpuLSq1wzjp821CTVdj9KtLNKbR6ENUTUkOmI/yArg7 PAVhVFfwJk/23SvX2zx8w34SyHOiSIPnQyK4WdzEeTdd8SAgIdsvRpfLoJlGZHNRQttp Sn+QI7FYL/63lZSyDL3h7+UrDLaJMvQ9AYWfHzD79F5Dd0rZVqboNx6UwMUFTBXXONsF XbMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Pw4bKb2w; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f13-20020a056402004d00b0053424c8f6cfsi11346111edu.290.2023.10.02.05.27.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 05:27:30 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Pw4bKb2w; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0FC4F3856961 for ; Mon, 2 Oct 2023 12:27:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FC4F3856961 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696249649; 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=Pw4bKb2wOMtbh616OYwI8t39M+gntvlrFpegkQrssAIsAdChD62Ostk4otblUIaAk /XPHbQASo7ZMd/z1BpHw4zL0NqPSDLojWEnbUDzrd4DBwJUUq1e+NnIC4CJIW2nKjV x60nbz6Ffdqe6AsU7VZ6ULlfLny4eJqV1vFUuvZ8= 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+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778646672986526055 X-GMAIL-MSGID: 1778646672986526055 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