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


> I think you're still on the wrong track here.  The problem is at the  
> location where first_global_object_name is being set, not where it is  
> used.  get_file_function_name is correct by definition:  
> first_global_object_name must only be set to values for which the  
> code in get_file_function_name works.
> 
> So, you would want to ensure that first_global_object_name is not set  
> to any name which might be overridden.  It seems like code to  
> implement this should use things like flag_pic or  
> targetm.binds_local_p, since overriding is related to shared objects  
> and name binding.

I've had the following patch in my tree for some time.  It attempts
to fix notice_global_symbol by treating global symbols in shared links
in somewhat the same manner as that for weak symbols.  A global symbol
is picked in preference to a weak symbol.  However, there are timing
issues in the selection process, so it's not at all clear that this
will always work.  Comments appreciated.

I have no idea how to fix the problem with C++ where some symbols that
are initially global are subsequently changed to local symbols.  If this
is necessary, then the whole idea behind notice_global_symbol is wrong.

This discussion refers to PRs 30151 and 30174.

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

Index: varasm.c
===================================================================
--- varasm.c	(revision 121370)
+++ varasm.c	(working copy)
@@ -1307,6 +1307,7 @@
 void
 notice_global_symbol (tree decl)
 {
+  static bool shlib_global_object_flag = false;
   const char **type = &first_global_object_name;
 
   if (first_global_object_name
@@ -1321,11 +1322,25 @@
       || !MEM_P (DECL_RTL (decl)))
     return;
 
-  /* We win when global object is found, but it is useful to know about weak
-     symbol as well so we can produce nicer unique names.  */
+  /* We win when a global object is found that can't be overridden, but
+     it is useful to know about other global objects so we can produce
+     nicer unique names.  */
   if (DECL_WEAK (decl) || DECL_ONE_ONLY (decl))
-    type = &weak_global_object_name;
+    {
+      if (weak_global_object_name)
+	return;
 
+      type = &weak_global_object_name;
+    }
+  else if (flag_shlib)
+    {
+      if (shlib_global_object_flag)
+	return;
+
+      shlib_global_object_flag = true;
+      type = &weak_global_object_name;
+    }
+
   if (!*type)
     {
       const char *p;


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