This is the mail archive of the
mailing list for the GCC project.
[PATCH] Make global file function names link unique
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: gcc-patches at gcc dot gnu dot org
- Cc: geoffk at apple dot com
- Date: Thu, 14 Dec 2006 20:09:30 -0500 (EST)
- Subject: [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.
J. David Anglin firstname.lastname@example.org
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
2006-12-14 John David Anglin <email@example.com>
* tree.c (get_file_function_name): Make global names link unique.
--- tree.c (revision 119869)
+++ tree.c (working copy)
@@ -6300,9 +6300,21 @@
const char *p;
- /* 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. */
- 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. */