public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PowerPC64 synthetic syms
@ 2006-05-23  6:07 Alan Modra
  2006-05-23 15:48 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Modra @ 2006-05-23  6:07 UTC (permalink / raw)
  To: binutils

PowerPC64 bfd_get_synthetic_symtab provides pseudo function entry
symbols (dot-symbols) for object files generated by newer toolchains.
This is useful for objdump disassembly of object files.  gdb also has
at least one place where a dot-symbol is searched, solib-svr4.c
solib_break_names, so relies on bfd_get_synthetic_symtab.  A recent
testcase shows this to be unreliable because the ppc64 back-end only
creates one synthetic sym for each function descriptor, and ld.so
happens to have *two* symbols pointing at the functions descriptor.
Which dot-symbol is created depends on symbol table hash order.

Really, gdb should be looking up the function descriptor syms itself
instead of relying on a crutch like the synthetic syms, but the
following patch happens to cure gdb and makes sense in isolation.
Applying mainline and 2.17.

	* elf64-ppc.c (compare_symbols): Prefer strong dynamic global
	function syms over other syms.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.238
diff -u -p -r1.238 elf64-ppc.c
--- bfd/elf64-ppc.c	9 May 2006 03:38:30 -0000	1.238
+++ bfd/elf64-ppc.c	23 May 2006 01:29:40 -0000
@@ -2626,6 +2626,32 @@ compare_symbols (const void *ap, const v
   if (a->value + a->section->vma > b->value + b->section->vma)
     return 1;
 
+  /* For syms with the same value, prefer strong dynamic global function
+     syms over other syms.  */
+  if ((a->flags & BSF_GLOBAL) != 0 && (b->flags & BSF_GLOBAL) == 0)
+    return -1;
+
+  if ((a->flags & BSF_GLOBAL) == 0 && (b->flags & BSF_GLOBAL) != 0)
+    return 1;
+
+  if ((a->flags & BSF_FUNCTION) != 0 && (b->flags & BSF_FUNCTION) == 0)
+    return -1;
+
+  if ((a->flags & BSF_FUNCTION) == 0 && (b->flags & BSF_FUNCTION) != 0)
+    return 1;
+
+  if ((a->flags & BSF_WEAK) == 0 && (b->flags & BSF_WEAK) != 0)
+    return -1;
+
+  if ((a->flags & BSF_WEAK) != 0 && (b->flags & BSF_WEAK) == 0)
+    return 1;
+
+  if ((a->flags & BSF_DYNAMIC) != 0 && (b->flags & BSF_DYNAMIC) == 0)
+    return -1;
+
+  if ((a->flags & BSF_DYNAMIC) == 0 && (b->flags & BSF_DYNAMIC) != 0)
+    return 1;
+
   return 0;
 }
 
-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-05-24  1:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-23  6:07 PowerPC64 synthetic syms Alan Modra
2006-05-23 15:48 ` Andreas Schwab
2006-05-24  8:13   ` Alan Modra
2006-05-24  8:17     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).