public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Prevent LTO section collision for a symbol name starting with '*'.
@ 2019-08-09 15:19 Martin Liška
  2019-08-12 10:39 ` Richard Biener
  0 siblings, 1 reply; 26+ messages in thread
From: Martin Liška @ 2019-08-09 15:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka

[-- Attachment #1: Type: text/plain, Size: 838 bytes --]

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  <mliska@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  <mliska@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



[-- Attachment #2: 0001-Prevent-LTO-section-collision-for-a-symbol-name-star.patch --]
[-- Type: text/x-patch, Size: 1119 bytes --]

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;
+}


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2019-10-30 10:08 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 15:19 [PATCH] Prevent LTO section collision for a symbol name starting with '*' Martin Liška
2019-08-12 10:39 ` Richard Biener
2019-08-12 10:43   ` Martin Liška
2019-08-12 10:46     ` Richard Biener
2019-08-12 10:50       ` Martin Liška
2019-08-12 10:58         ` Richard Biener
2019-08-12 11:01           ` Richard Biener
2019-08-12 10:52       ` Richard Biener
2019-08-15 14:57   ` Jan Hubicka
2019-08-16  9:11     ` Richard Biener
2019-08-23 13:20     ` Martin Liška
2019-08-23 14:00       ` Martin Liška
2019-08-23 15:39         ` Jan Hubicka
2019-08-23 15:43           ` Martin Liška
2019-08-23 16:32             ` Jan Hubicka
2019-08-23 16:42               ` Martin Liška
2019-08-23 23:18                 ` Jan Hubicka
2019-08-26 11:54                   ` Martin Liška
2019-09-09 12:39                     ` Martin Liška
2019-09-09 14:33                       ` Jan Hubicka
2019-09-11 11:38                         ` Martin Liška
2019-09-18 10:14                           ` Martin Liška
2019-10-22 11:15                             ` Martin Liška
2019-10-29 11:34                               ` Martin Liška
2019-10-29 14:51                                 ` Jan Hubicka
2019-10-30 10:11                                   ` Martin Liška

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).