On Dec 21, 2012, Richard Biener <richard.guent...@gmail.com> wrote:

> On Fri, Dec 21, 2012 at 6:33 AM, Alexandre Oliva <aol...@redhat.com> wrote:
>> libmudflap emits a global initializer that registers memory ranges for
>> global data symbols.  However, even if IPA decides not to emit a symbol
>> because it's unused, we'd still emit registration sequences for them in
>> some cases, which, in the PR testcase, would result in TOC references to
>> the undefined symbols.

> Hmm, I think that at this point of the compilation you are looking for
> TREE_ASM_WRITTEN instead.

That doesn't work, several mudflap regressions show up because accesses
to global library symbols that are accessed by template methods compiled
with mudflap (say cout) are then verified but not registered.  We have
to register symbols that are not emitted but that referenced.

I've now updated the comment to reflect this.

Is this ok to install?  Regstrapped again (along with the patches for
feraiseexcept, since there weren't any non-comment changes here) on
x86_64-linux-gnu and i686-linux-gnu.

don't let mudflap register global symbols that won't be emitted

From: Alexandre Oliva <aol...@redhat.com>

for  gcc/ChangeLog

	PR libmudflap/53359
	* tree-mudflap.c (mudflap_finish_file): Skip deferred decls
	not found in the symtab.
---

 gcc/tree-mudflap.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)


diff --git a/gcc/tree-mudflap.c b/gcc/tree-mudflap.c
index 90d0448..e20f06e 100644
--- a/gcc/tree-mudflap.c
+++ b/gcc/tree-mudflap.c
@@ -1335,6 +1335,16 @@ mudflap_finish_file (void)
           if (! TREE_PUBLIC (obj) && ! TREE_ADDRESSABLE (obj))
             continue;
 
+	  /* If we're neither emitting nor referencing the symbol,
+	     don't register it.  We have to register external symbols
+	     if they happen to be in other files not compiled with
+	     mudflap (say system libraries), and we must not register
+	     internal symbols that we don't emit or they'll become
+	     dangling references or force symbols to be emitted that
+	     didn't have to.  */
+	  if (!symtab_get_node (obj))
+	    continue;
+
           if (! COMPLETE_TYPE_P (TREE_TYPE (obj)))
             {
               warning (OPT_Wmudflap,

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

Reply via email to