Hi. The patch is about prevention of LTO section name clashing. Now we have a situation where body of 2 functions is streamed into the same ELF section. Then we'll end up with smashed data.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin gcc/ChangeLog: 2019-08-09 Martin Liska <mli...@suse.cz> PR lto/91393 PR lto/88220 * lto-streamer.c (lto_get_section_name): Replace '*' leading character with '0'. gcc/testsuite/ChangeLog: 2019-08-09 Martin Liska <mli...@suse.cz> PR lto/91393 PR lto/88220 * gcc.dg/lto/pr91393_0.c: New test. --- gcc/lto-streamer.c | 15 ++++++++++++--- gcc/testsuite/gcc.dg/lto/pr91393_0.c | 11 +++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/lto/pr91393_0.c
diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index bd0126faebb..ffcaae516a5 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -124,9 +124,18 @@ lto_get_section_name (int section_type, const char *name, struct lto_file_decl_d { gcc_assert (name != NULL); if (name[0] == '*') - name++; - add = name; - sep = ""; + { + /* Symbols starting with '*' can clash with a symbol + that has the same name. Use then zero as one can't + use digits at the beginning of identifiers. */ + sep = "0"; + add = name + 1; + } + else + { + add = name; + sep = ""; + } } else if (section_type < LTO_N_SECTION_TYPES) { diff --git a/gcc/testsuite/gcc.dg/lto/pr91393_0.c b/gcc/testsuite/gcc.dg/lto/pr91393_0.c new file mode 100644 index 00000000000..43b2426c86b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr91393_0.c @@ -0,0 +1,11 @@ +void __open_alias(int, ...) __asm__("open"); +void __open_alias(int flags, ...) {} +extern __inline __attribute__((__gnu_inline__)) int open() {} +struct { + void *func; +} a = {open}; + +int main() +{ + return 0; +}