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; From patchwork Sat Sep 16 10:36:17 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: 141026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1587179vqi; Sat, 16 Sep 2023 03:37:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGn1pfsUpkl1zpWOfKgqILxLr4MCPrx7DTL/74b2FRDPPhfV7GZENLVvTgSMuDdxAHmcbtH X-Received: by 2002:a17:906:68ce:b0:9a6:572f:597f with SMTP id y14-20020a17090668ce00b009a6572f597fmr3476059ejr.38.1694860620877; Sat, 16 Sep 2023 03:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694860620; cv=none; d=google.com; s=arc-20160816; b=tiYAXkU5g+o74UE1sEyWQicz+UaC76AVneNoyPAaHJoZc1rtRKyrKu3Osh+g22nDEp OgfAItyRef/jomdoOSE3ZhprkHL2Gtx74N7de44sPs48/JPF/b7HW/7PQU2/69i1rrz/ cfNVUtMk8C4G1Jrp1Ka9CgbR7uLNGaDzBWbVGMPs/sJhZJvds32eWtFi8NtgIfuj3EdU +ZKUV0kqF6QvW/6XK/coOPDwHvN80+XSlsmjbyjxJHaQRtcms1bNwEokvcxFxCJHp1sY Iiw5s8ngd77DjF3s5TCdDJDW9jWjB2uv5XRT+cpVOCLnXx+tMLXmXM+rW/3yVzZoBGhj QP9w== 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=prJAcUZKdQq+b8mOyyXGAdS51ZvBMva0Jl+059guR4U=; fh=LUrEkQF9vvLXpHHEKq9IbL4CRmZPhfxptKOJUppCeCU=; b=Vl4wMNpVxXv23rodONG+Od95CvLjCwdVroPezABXraFsB3ywtgAburPrlT9NGeDsS/ 3+Vggz/vNVyoLrNK71BQSYPUYII3SSdgWbhLOBVo+r0FXXgoWf6U3DAid7k42wUr/9tj gkNUuRF65McXyb7FGiRgC2BrWLG1K/aQNlr+hj53myieh5OTNi8CybVMaehAJ3v/ZAGY Rwumzh6IbS+UXeVM6GmXfXrZaUUFRSFFuCDPUTgepO85VZiLUvnMaOE3lQLzfL9uVDHG RDQDQRmYdlbIselC4HPjIozMmu9NoDaRInrS6nnPv+v1AbCyuepmjDAo5EgnOob4vQ4L mOaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b=GYI7pSSF; 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" Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id pj4-20020a170906d78400b00993470682e9si4647443ejb.739.2023.09.16.03.37.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 03:37:00 -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=@t-8ch.de header.s=mail header.b=GYI7pSSF; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9C58C385C6EF for ; Sat, 16 Sep 2023 10:36:45 +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 6FFE63858CD1 for ; Sat, 16 Sep 2023 10:36:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6FFE63858CD1 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=YlE22fNbpswYUwdgZ6BW6GlP9BMJeOZm9k3zmCwd6HU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GYI7pSSFVym0P6ppPGo+AqVbu5qMyN3yqRo5qEI9yYOdvjPeBVtxpy1z3SsdVCqQO Lyn2T5nST/Ow8LgDjLuurPEp7ObOhSXxtK5MBYFoB29h5rihJkOKAiZ4TflW3SnWo4 Ka/JhvtzzD2ty0zFpfpwA6jYRWIEm1aCOY9Wy2KE= 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 2/2] ld: write full paths to dependency-file Date: Sat, 16 Sep 2023 12:36:17 +0200 Message-ID: <20230916103619.819791-3-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.2 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: 1777190170583659328 X-GMAIL-MSGID: 1777190170583659328 When relative paths are written to the dependency-file it forces the users of it to run from the same directory. To avoid this only write absolute paths. Signed-off-by: Thomas Weißschuh --- ld/ldmain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ld/ldmain.c b/ld/ldmain.c index 25cc89b72f90..f11ee6696125 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -174,7 +174,7 @@ track_dependency_files (const char *filename) { struct dependency_file *dep = (struct dependency_file *) xmalloc (sizeof (*dep)); - dep->name = xstrdup (filename); + dep->name = lrealpath (filename); dep->next = NULL; if (dependency_files == NULL) dependency_files = dep;