From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32751 invoked by alias); 23 May 2006 01:32:48 -0000 Received: (qmail 32742 invoked by uid 22791); 23 May 2006 01:32:47 -0000 X-Spam-Check-By: sourceware.org Received: from CPE-144-136-172-108.sa.bigpond.net.au (HELO grove.modra.org) (144.136.172.108) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 23 May 2006 01:32:17 +0000 Received: by bubble.grove.modra.org (Postfix, from userid 500) id 8F6841DF837; Tue, 23 May 2006 11:02:14 +0930 (CST) Date: Tue, 23 May 2006 06:07:00 -0000 From: Alan Modra To: binutils@sourceware.org Subject: PowerPC64 synthetic syms Message-ID: <20060523013214.GB12196@bubble.grove.modra.org> Mail-Followup-To: binutils@sourceware.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00395.txt.bz2 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