From patchwork Mon Sep 18 19:42:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 141532 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2908655vqi; Mon, 18 Sep 2023 12:42:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRnsSK+joHFFkruMDbk/ChGFwO2/PPcAXjPlkLsq+P1Wjm4KGIvPIa9tlT9b32Oo0Fsp3c X-Received: by 2002:a17:907:75ee:b0:9a9:fb1c:34ff with SMTP id jz14-20020a17090775ee00b009a9fb1c34ffmr7088094ejc.73.1695066158791; Mon, 18 Sep 2023 12:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695066158; cv=none; d=google.com; s=arc-20160816; b=J2Kh5EsKO4fq1O9fxhBZ8mjdg2eEzfY/3MwhwtCDNhxqilyjQYjDNJAQ60AD/30o2e SqGtw9LXiZSYZoYZDVLgRkfGv9ByVQv6GNKggbM6ohsgHjYgztzPMvIO3bZ+nQqmGpkF O7iZEoDsUh9SSrY2l3ukMfcoqhl15nySytZwNzbap2TQc5XUUSBrTOLiFE51vycbddDT YcFvaeeLgXs8htCBqBauPe7u5BMvkzojSytixVCe26IJYmXY8ieqEqTn75ZSE90l47L6 JvEtRCizFmznFpfdKC6JyNMQWtT0p6rGgP5Sm5IH9NnUimRvMHODPNdBk/1qrV9OojBW VsTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=SnpVdtX3BgRKKIW6ybB0q8GH33txw5Qu5azYXzHeFk8=; fh=KfHWJ+rAolCYMk+MgUz4uXtFeDKBZKd1oFlJhGPmZHU=; b=uwWpeH4UeuxyqeCG9HRONKd9MknlhhAVv8VkoEgIHoiLHwqzC1BYJoKqEQ901beXBe qcWH6zJ4VILlsC15Zc3VtaA76u8XSd3SZw4FubgKksDCeozbIrBXjmQurLRvmj4A2Zql AxwsETaQlFO0sPTc/UXAq6+8LUDpP7i7Kg6RPZJPNyMGpY0VdIOQRD+m1sca/m/biXLQ DhVpSFhM9O35WeU9hAaHaY9iKhp+qoafsWv6Sq2pcbl0U9cdtcSjr4bTzaSXIXCJV9ph XxHOsg/gw8QtFgj/95ELsq2JqomB2VUrBupTi1kUnJa+J3OGi964b5ToSNpxp9+kWx1d FavQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=MQMsexKg; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id h8-20020a17090619c800b0099bcf1c07cbsi8732752ejd.883.2023.09.18.12.42.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 12:42:38 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=MQMsexKg; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 07AB5385700D for ; Mon, 18 Sep 2023 19:42:37 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by sourceware.org (Postfix) with ESMTPS id D63CA3858C78 for ; Mon, 18 Sep 2023 19:42:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D63CA3858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=t-8ch.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=t-8ch.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1695066149; bh=u1Qmerz9yMceu2/dLF9DpI+Z5C1uONgl7XB927lxp9c=; h=From:To:Cc:Subject:Date:From; b=MQMsexKge6iYzYb7WRVwMXlPs40HpI0sXRd4IL3AD/DWpOA3ocvUmksGxXAVnWiYl XQzB3u/8LJV+/petxdcgzCI+DSfZbn7wKkT8FXbC6wheQWiuhuKhBV8wTv6O4FHwoD OCrF9bvH9dDCub6vbHjHzAqZ3vUchAU+vb6ynOs4= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= To: binutils@sourceware.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Jan Beulich , Alan Modra Subject: [PATCH v3] ld: write resolved path to included file to dependency-file Date: Mon, 18 Sep 2023 21:42:23 +0200 Message-ID: <20230918194226.1200853-1-thomas@t-8ch.de> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, 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: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777405692510850575 X-GMAIL-MSGID: 1777405692510850575 In ldfile_open_command_file_1() name written to the dependency files is the name as specified passed to the "INCLUDE" directive. This is before include-path processing so the tracked dependency location is most likely wrong. Instead track the opened file at the point where the resolved path is actually available, in try_open(). Signed-off-by: Thomas Weißschuh --- v2: https://sourceware.org/pipermail/binutils/2023-September/129503.html v2 -> v3: * drop "write absolute paths to dependencies" * fix code style in conditional v1: https://sourceware.org/pipermail/binutils/2023-September/129475.html v1 -> v2: * push call to track_dependencies() into try_open() to catch all dependencies * sign-off commits * write absolute paths to dependencies ld/ldfile.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) base-commit: 95ebc6fdec5780bf59685739cdd55cd41d0f55ac diff --git a/ld/ldfile.c b/ld/ldfile.c index b8fd4e5d8e0a..d73e251402c8 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -529,7 +529,10 @@ try_open (const char *name, bool *sysrooted) result = fopen (name, "r"); if (result != NULL) - *sysrooted = is_sysrooted_pathname (name); + { + *sysrooted = is_sysrooted_pathname (name); + track_dependency_files (name); + } if (verbose) { @@ -711,8 +714,6 @@ ldfile_open_command_file_1 (const char *name, enum script_open_style open_how) return; } - track_dependency_files (name); - lex_push_file (ldlex_input_stack, name, sysrooted); lineno = 1;