This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

powerpc64-elf gas weak syms


This patch moves ppc_elf_frob_symbol logic into
ppc_frob_file_before_adjust, as it's better to do a single symbol
lookup than call a function on every symbol.

ppc_frob_file_before_adjust also ties together function entry and
descriptor symbol usage so that weak undefined functions lose
both syms together, or keep both.  I found this necessary at one
stage during glibc porting, and although the need has gone, I
still thing it's a good idea to keep function syms consistent.

	* config/tc-ppc.c (ppc_elf_frob_symbol): Delete.
	(ppc_frob_file_before_adjust): New function.
	* config/tc-ppc.h (tc_frob_symbol): Don't define.
	(ppc_elf_frob_symbol): Don't declare.
	(tc_frob_file_before_adjust): Define.
	(ppc_frob_file_before_adjust): Declare.

Applies on top of the previous patch.

Index: gas/config/tc-ppc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.c,v
retrieving revision 1.49
diff -u -p -r1.49 tc-ppc.c
--- gas/config/tc-ppc.c	12 Jun 2002 16:14:02 -0000	1.49
+++ gas/config/tc-ppc.c	9 Jul 2002 11:03:09 -0000
@@ -1688,21 +1688,49 @@ ppc_elf_validate_fix (fixp, seg)
     }
 }
 
-/* Don't emit .TOC. symbol.  */
-int
-ppc_elf_frob_symbol (sym)
-     symbolS *sym;
+/* Prevent elf_frob_file_before_adjust removing a weak undefined
+   function descriptor sym if the corresponding code sym is used.  */
+
+void
+ppc_frob_file_before_adjust ()
 {
-  const char *name;
+  symbolS *symp;
 
-  name = S_GET_NAME (sym);
-  if (name != NULL && strcmp (name, ".TOC.") == 0)
+  if (!ppc_obj64)
+    return;
+
+  for (symp = symbol_rootP; symp; symp = symbol_next (symp))
     {
-      S_CLEAR_EXTERNAL (sym);
-      return 1;
+      const char *name;
+      char *dotname;
+      symbolS *dotsym;
+      size_t len;
+
+      name = S_GET_NAME (symp);
+      if (name[0] == '.')
+	continue;
+
+      if (! S_IS_WEAK (symp)
+	  || S_IS_DEFINED (symp))
+	continue;
+
+      len = strlen (name) + 1;
+      dotname = xmalloc (len + 1);
+      dotname[0] = '.';
+      memcpy (dotname + 1, name, len);
+      dotsym = symbol_find (dotname);
+      free (dotname);
+      if (dotsym != NULL && (symbol_used_p (dotsym)
+			     || symbol_used_in_reloc_p (dotsym)))
+	{
+	  symbol_mark_used (symp);
+	}
     }
 
-  return 0;
+  /* Don't emit .TOC. symbol.  */
+  symp = symbol_find (".TOC.");
+  if (symp != NULL)
+    symbol_remove (symp, &symbol_rootP, &symbol_lastP);
 }
 #endif /* OBJ_ELF */
 
Index: gas/config/tc-ppc.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-ppc.h,v
retrieving revision 1.16
diff -u -p -r1.16 tc-ppc.h
--- gas/config/tc-ppc.h	12 Jun 2002 16:14:02 -0000	1.16
+++ gas/config/tc-ppc.h	9 Jul 2002 11:03:09 -0000
@@ -271,9 +271,8 @@ extern int ppc_fix_adjustable PARAMS ((s
        && S_IS_DEFINED ((FIX)->fx_addsy) \
        && ! S_IS_COMMON ((FIX)->fx_addsy)))
 
-/* Finish up the symbol.  */
-#define tc_frob_symbol(sym, punt) punt = ppc_elf_frob_symbol (sym)
-extern int ppc_elf_frob_symbol PARAMS ((symbolS *));
+#define tc_frob_file_before_adjust ppc_frob_file_before_adjust
+extern void ppc_frob_file_before_adjust PARAMS ((void));
 
 #define DWARF2_LINE_MIN_INSN_LENGTH 4
 #endif /* OBJ_ELF */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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