ld: lang_add_input_file and new_afile leaks

Alan Modra amodra@gmail.com
Tue Feb 17 00:42:40 GMT 2026


These belong on stat_obstack, where the lang_input_statement is.

	* ldlang.c (new_afile): Replace concat with stat_concat.
	(lang_add_input_file): Likewise.

diff --git a/ld/ldlang.c b/ld/ldlang.c
index a8c7854b5f8..5ce8c754eac 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1232,7 +1232,7 @@ new_afile (const char *name,
 	}
       else
 	p->filename = name;
-      p->local_sym_name = concat ("-l", name, (const char *) NULL);
+      p->local_sym_name = stat_concat ("-l", name, (const char *) NULL);
       p->flags.maybe_archive = true;
       p->flags.real = true;
       p->flags.search_dirs = true;
@@ -1275,9 +1275,9 @@ lang_add_input_file (const char *name,
     {
       lang_input_statement_type *ret;
       char *sysrooted_name
-	= concat (ld_sysroot,
-		  name + (*name == '=' ? 1 : strlen ("$SYSROOT")),
-		  (const char *) NULL);
+	= stat_concat (ld_sysroot,
+		       name + (*name == '=' ? 1 : strlen ("$SYSROOT")),
+		       (const char *) NULL);
 
       /* We've now forcibly prepended the sysroot, making the input
 	 file independent of the context.  Therefore, temporarily

-- 
Alan Modra


More information about the Binutils mailing list