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]

fix weakrefs for darwin


Darwin apparently does some funky stuff with symbol names for symbol
indirection, lazy stubs et al, that involves creating symbol names out
of other symbol names, so it has to be aware of transparent aliases.
This patch fixes it, and Dale Ranta says in the PR that it fixed the
problem, although I can't bootstrap it myself since I don't have
hardware nor software to run Darwin.  Ok to install?

Another approach, that avoids duplicating the code from assemble_name
al over the place, would be to introduce an alternate entry point in
varasm.c that is like assemble_name, but that, instead of printing the
name to a stream, returns it in a string.

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR libfortran/24991
	* config/darwin.c (machopic_indirection_name,
	machopic_output_indirection): Follow transparent alias chain.

Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c	(revision 107601)
+++ gcc/config/darwin.c	(working copy)
@@ -316,6 +316,21 @@
   const char *suffix;
   const char *prefix = user_label_prefix;
   const char *quote = "";
+  tree id;
+
+  id = maybe_get_identifier (name);
+  if (id)
+    {
+      tree id_orig = id;
+
+      while (IDENTIFIER_TRANSPARENT_ALIAS (id))
+	id = TREE_CHAIN (id);
+      if (id != id_orig)
+	{
+	  name = IDENTIFIER_POINTER (id);
+	  namelen = strlen (name);
+	}
+    }
   
   if (name[0] == '*')
     {
@@ -861,7 +876,19 @@
     {
       char *sym;
       char *stub;
+      tree id;
 
+      id = maybe_get_identifier (sym_name);
+      if (id)
+	{
+	  tree id_orig = id;
+
+	  while (IDENTIFIER_TRANSPARENT_ALIAS (id))
+	    id = TREE_CHAIN (id);
+	  if (id != id_orig)
+	    sym_name = IDENTIFIER_POINTER (id);
+	}
+
       sym = alloca (strlen (sym_name) + 2);
       if (sym_name[0] == '*' || sym_name[0] == '&')
 	strcpy (sym, sym_name + 1);
-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

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