On 3/13/20 1:39 PM, Jakub Jelinek wrote:
       collect_gcc_options = concat (collect_gcc_options,
                                    xassembler_opts_string, NULL);
instead?

Ah, I forgot that concat is available here. I would choose
this way, even though it's a small memory leak.

I'm going to install the patch.
Martin
>From 4f287d2b028b61b47f4d8cec7b7db14636122653 Mon Sep 17 00:00:00 2001
From: Martin Liska <mli...@suse.cz>
Date: Thu, 12 Mar 2020 19:56:47 +0100
Subject: [PATCH] Do not strcat to result of getenv.

gcc/ChangeLog:

2020-03-12  Martin Liska  <mli...@suse.cz>

	PR lto/94157
	* lto-wrapper.c (run_gcc): Use concat for appending
	to collect_gcc_options.

gcc/testsuite/ChangeLog:

2020-03-12  Martin Liska  <mli...@suse.cz>

	PR lto/94157
	* gcc.dg/lto/pr94157_0.c: New test.
---
 gcc/lto-wrapper.c                    | 3 ++-
 gcc/testsuite/gcc.dg/lto/pr94157_0.c | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/lto/pr94157_0.c

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index b8a35c85714..46a88b233f6 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1317,7 +1317,8 @@ run_gcc (unsigned argc, char *argv[])
 
       char *xassembler_opts_string
 	= XOBFINISH (&temporary_obstack, char *);
-      strcat (collect_gcc_options, xassembler_opts_string);
+      collect_gcc_options = concat (collect_gcc_options, xassembler_opts_string,
+				    NULL);
     }
 
   get_options_from_collect_gcc_options (collect_gcc, collect_gcc_options,
diff --git a/gcc/testsuite/gcc.dg/lto/pr94157_0.c b/gcc/testsuite/gcc.dg/lto/pr94157_0.c
new file mode 100644
index 00000000000..3bca677c4fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr94157_0.c
@@ -0,0 +1,6 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -O0 -fipa-vrp -flto -Wa,--noexecstack -Wa,--noexecstack -Wa,--execstack  -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack -Wa,--execstack } } } */
+
+int main() {
+
+}
-- 
2.25.1

Reply via email to