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]

Re: [PATCH] Make global file function names link unique



On 14/12/2006, at 5:09 PM, John David Anglin wrote:


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.

I think your problem is that 'first_global_object_name' is supposed to be a name unique to this file, and you have found a case where it isn't. It would be better if you could ensure that first_global_object_name was really a name unique to this file. ("unique to this file" means "only this file in the whole link can be defining this symbol".)


If you can't guarantee that any name is unique to this file, you need to fall down to the last case in this function, where it already does all kinds of crc32 operations. If you're going to do that, or do something like what you have in the patch below, please only do it on targets that actually need it.

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. */

Attachment: smime.p7s
Description: S/MIME cryptographic signature


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