This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Make global file function names link unique


The enclosed change fixes two regressions.  The first is that global
constructors and destructors keyed to namespace global names need to
be link unique.  See PR 30151.

The same is also true for 'F' globals used for initializing DWARF unwind
frame information.  If one of these names in a shared library is overloaded,
the DWARF unwind isn't properly initialized and the unwind mechanism breaks
in a manner that's very difficult to debug.  An example of this problem
is the failure of the g++.old-deja/g++.abi/cxa_vec.C execution test noted
in PR 30174.

The use of crc32_string to create a unique file name is a compromise,
and there's a very small probability that it might conflict with a
user selected name or not yield a link unique name.  However, I don't
think any solution is perfect.  An advantages of using crc32_string
over the file's basename is that it's limited in length and doesn't
need any cleanup.

Ok for trunk?  Tested on hppa2.0w-hp-hpux11.11 with no regressions.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

:ADDPATCH middle-end:

2006-12-14  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR middle-end/30151
	PR middle-end/30174
	* tree.c (get_file_function_name): Make global names link unique.

Index: tree.c
===================================================================
--- tree.c	(revision 119869)
+++ tree.c	(working copy)
@@ -6300,9 +6300,21 @@
   const char *p;
   char *q;
 
-  /* If we already have a name we know to be unique, just use that.  */
+  /* If we already have a name we know to be unique to this file, use
+     that as a base for building a name unique across the whole link.  */
   if (first_global_object_name)
-    p = first_global_object_name;
+    {
+      const char *file = main_input_filename;
+      p = first_global_object_name;
+      if (! file)
+	file = input_filename;
+
+      /* Use the CRC32 string for file, because the full pathname
+	 might be quite long.  */
+      q = alloca (strlen (p) + 10);
+      sprintf (q, "%s_%08X", p, crc32_string (0, file));
+      p = q;
+    }
   /* If the target is handling the constructors/destructors, they
      will be local to this file and the name is only necessary for
      debugging purposes.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]