Hi. The patch fixed wrong strcat to a char pointer received with getenv.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin gcc/ChangeLog: 2020-03-12 Martin Liska <mli...@suse.cz> PR lto/94157 * lto-wrapper.c (run_gcc): Allocate a new buffer. Do not strcat to result of getenv. 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 | 6 +++++- gcc/testsuite/gcc.dg/lto/pr94157_0.c | 6 ++++++ 2 files changed, 11 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..84a0bd24e91 100644 --- a/gcc/lto-wrapper.c +++ b/gcc/lto-wrapper.c @@ -1317,7 +1317,11 @@ run_gcc (unsigned argc, char *argv[]) char *xassembler_opts_string = XOBFINISH (&temporary_obstack, char *); - strcat (collect_gcc_options, xassembler_opts_string); + char *collect = (char *)xmalloc (strlen (collect_gcc_options) + + strlen (xassembler_opts_string) + 1); + strcpy (collect, collect_gcc_options); + strcat (collect, xassembler_opts_string); + collect_gcc_options = collect; } 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() { + +}