From 785ca51445a9b037c55ad5739eeafce9b49166e2 Mon Sep 17 00:00:00 2001
From: Rafael Avila de Espindola <espindola@google.com>
Date: Mon, 4 Jan 2010 15:25:11 +0000
Subject: [PATCH] 20100104_0.c: New.

2010-01-04  Rafael Avila de Espindola  <espindola@google.com>

	* gcc.dg/lto/20100104_0.c: New.

2010-01-04  Rafael Avila de Espindola  <espindola@google.com>

	* lto-streamer-out.c (output_unreferenced_globals): Output the full
	tree of an unreferenced global var.

From-SVN: r155619
---
 gcc/ChangeLog                         | 5 +++++
 gcc/lto-streamer-out.c                | 7 ++++++-
 gcc/testsuite/ChangeLog               | 4 ++++
 gcc/testsuite/gcc.dg/lto/20100104_0.c | 8 ++++++++
 4 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/lto/20100104_0.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 11adcd05ec8a..39c9b614f6fa 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2010-01-04  Rafael Avila de Espindola  <espindola@google.com>
+
+	* lto-streamer-out.c (output_unreferenced_globals): Output the full
+	tree of an unreferenced global var.
+
 2010-01-04  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/42542
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 6d1337378bb4..b27bbdd07041 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -1974,7 +1974,12 @@ output_unreferenced_globals (cgraph_node_set set)
       tree var = vnode->decl;
 
       if (TREE_CODE (var) == VAR_DECL && TREE_PUBLIC (var))
-	lto_output_tree_ref (ob, var);
+        {
+          /* Outputting just the reference will not output the object itself
+             or references it might have.*/
+          lto_output_tree (ob, var, true);
+          lto_output_tree_ref (ob, var);
+        }
     }
 
   output_zero (ob);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 44f692cc74d0..30b80afd82e3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2010-01-04  Rafael Avila de Espindola  <espindola@google.com>
+
+	* gcc.dg/lto/20100104_0.c: New.
+
 2010-01-04  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR target/42542
diff --git a/gcc/testsuite/gcc.dg/lto/20100104_0.c b/gcc/testsuite/gcc.dg/lto/20100104_0.c
new file mode 100644
index 000000000000..c17e7682f739
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/20100104_0.c
@@ -0,0 +1,8 @@
+/* { dg-lto-do assemble } */
+/* The problem with this testcase is that we were missing an undefined
+   reference to c_common_attribute_table. This can be tested with
+   GNUTARGET=plugin nm --plugin liblto_plugin.so 20100104_0.o
+   but we don't have support in the testsuite for doing it. */
+
+extern int c_common_attribute_table[];
+void *foobar = c_common_attribute_table;
-- 
GitLab