This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Make global file function names link unique
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: geoffk at apple dot com (Geoffrey Keating)
- Cc: gcc-patches at gcc dot gnu dot org, mark at codesourcery dot com
- Date: Mon, 18 Dec 2006 16:26:15 -0500 (EST)
- Subject: Re: [PATCH] Make global file function names link unique
> 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.
The enclosed version only adds the crc32 for 'I' and 'D' when the
target doesn't handle constructors/destructors (i.e., it uses collect2).
I believe that adding the crc32 is necessary in all cases when 'F'
and 'N' are used.
Adding randomness based on flag_random_seed causes the assembly
output to change from one compilation to another. This creates
several new testsuite regressions that I would prefer to avoid.
Also note that the last case uses different names for the crc32
Aside from changes to comments and the 'if', the patch is identical
to the one approved here:
and subsequently removed here:
Tested on hppa2.0-hp-hpux11.11 and hppa-unknown-linux-gnu.
J. David Anglin email@example.com
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
2006-12-18 John David Anglin <firstname.lastname@example.org>
* tree.c (get_file_function_name): Make global names link unique.
--- tree.c (revision 119963)
+++ tree.c (working copy)
@@ -6283,7 +6283,7 @@
*p = '_';
-/* Generate a name for a special-purpose function function.
+/* Generate a name for a special-purpose function.
The generated name may need to be unique across the whole link.
TYPE is some string to identify the purpose of this function to the
linker or collect2; it must start with an uppercase letter,
@@ -6300,9 +6300,29 @@
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 translation
+ unit, just use it. */
- p = first_global_object_name;
+ p = first_global_object_name;
+ /* The generated name needs to be unique across the whole link for
+ types 'I' and 'D' when constructors/destructors are not handled
+ by the target, and for types 'F' and 'N'. */
+ if ((type != 'I' && type != 'D') || !targetm.have_ctors_dtors)
+ const char *file = main_input_filename;
+ 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. */