From patchwork Sat Sep 16 10:36:16 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: 141025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1587119vqi; Sat, 16 Sep 2023 03:36:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFYoum589zpJGRtfSWcJJ6WeTeVirohVgEDRLBmU6132YUMmptFyMy1wYlpuhrEcDpWR8Wt X-Received: by 2002:ac2:5f69:0:b0:4f8:766f:8dc3 with SMTP id c9-20020ac25f69000000b004f8766f8dc3mr3162226lfc.32.1694860608228; Sat, 16 Sep 2023 03:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694860608; cv=none; d=google.com; s=arc-20160816; b=MEKLByzbaWu2EwRyXyUM3STyNrxeAoMD1rKQIpNA4L4g68ly+BpMs/js+/X1JxT1fk 7yvapQrYmfXcybbT2cgWSLNQdBKfEMTIpjmoqh21nGNGaeBqlCb9wr/h6uh2BR/4w0cJ vp1/5WGsaWwjHi38luDPHfsXJCymb7NwPlmXzzdjy0MTvq/pVelGeg24xcnAKFlu6mA0 Hl+8CCRSte9QjSklkbt9MAxjKN7FqmtiTJ330MWPvznUOCuHpX9v6gFypO40e8VHazzt o49XQzfvmYR4+wHcw+pc7rjqqDG13aHp/h6/CyCjdklZZ2lD3fxzHDRMeGzaYfW8j2M9 j4JQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=81EBPqlvqcWYxQvJt+7+Nn6Lg7JJD+TftM109DhEBIs=; fh=LUrEkQF9vvLXpHHEKq9IbL4CRmZPhfxptKOJUppCeCU=; b=KFyL9XuuYTF0qb1HNG8RGd0iRDJ8td8Nkj6pQgebk62MROtfqyU+d9ePv7kkilR61v oS76XdJTh2qgh4iWUFOIfQt2AnEF5ob4IzxxN4IV1DyPl6kopsO+YTagB3eqxGS7Uk8q 7/0+SQQh4NbUt/eGOAxc3htye3Nc6cAYTSd/1uZhdVMyhwwqcqQ2Kf36ClA+DjPjaRfG 0FyyiprmflWS/he9QVQYZoArawAZXGT5pqlgHeV3uTr0HcO785qpr/3jy6muY7s7h6UG qbCeMNviqEngk72XH+vRGMcpflhweQNImpKYiivOQDc2s2sIJScZjVp3dG1vbKc87dLp 4Tqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=l4IVKLvF; 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 d4-20020aa7c1c4000000b00525b948f961si4865608edp.291.2023.09.16.03.36.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 03:36:48 -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=l4IVKLvF; 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 080BE3857738 for ; Sat, 16 Sep 2023 10:36:42 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by sourceware.org (Postfix) with ESMTPS id 5BF443858D37 for ; Sat, 16 Sep 2023 10:36:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5BF443858D37 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=1694860594; bh=C0qOV/ywoO2uusrBklRvDdw6N4my/jqs9qBcppQdcjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l4IVKLvF39IYJszHe8YjKztWpJGUQhzAjLW09U2rWY+r8Qns89gHFxzrk8nuHUVqB gKfYV+GkgDQcr7Tt2BdOit77/9ll0Rsp9y2xOjEgX8l1zCs3AB9tpSHMkPxOOuy0oY g/2QThXc9rjOpBQtvQnG1mUyiOEZOt5lbMusgE9s= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= To: binutils@sourceware.org Cc: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Alan Modra Subject: [PATCH v2 1/2] ld: write resolved path to included file to dependency-file Date: Sat, 16 Sep 2023 12:36:16 +0200 Message-ID: <20230916103619.819791-2-thomas@t-8ch.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230916103619.819791-1-thomas@t-8ch.de> References: <20230916103619.819791-1-thomas@t-8ch.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.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: 1777190157372193119 X-GMAIL-MSGID: 1777190157372193119 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 --- ld/ldfile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ld/ldfile.c b/ld/ldfile.c index b8fd4e5d8e0a..29938eca0bc0 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -528,8 +528,10 @@ try_open (const char *name, bool *sysrooted) result = fopen (name, "r"); - if (result != NULL) + if (result != NULL) { *sysrooted = is_sysrooted_pathname (name); + track_dependency_files (name); + } if (verbose) { @@ -711,8 +713,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;