ld: write resolved path to included file to dependency-file
authorThomas Weißschuh <thomas@t-8ch.de>
Thu, 21 Sep 2023 06:03:09 +0000 (08:03 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 21 Sep 2023 06:03:09 +0000 (08:03 +0200)
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 <thomas@t-8ch.de>
ld/ldfile.c

index df7c9cbd65e68fe998a7a96d0764bce069dee1a2..8f869c1f19ea5fd421971fa1d7e1541248d6e566 100644 (file)
@@ -743,7 +743,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)
     {
@@ -925,8 +928,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;