From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25094 invoked by alias); 2 May 2008 21:51:57 -0000 Received: (qmail 25018 invoked by uid 22791); 2 May 2008 21:51:55 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 02 May 2008 21:51:35 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id CF19B983DA; Fri, 2 May 2008 21:51:33 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id AA305983D6; Fri, 2 May 2008 21:51:33 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1Js3AC-0003Qu-ON; Fri, 02 May 2008 17:51:32 -0400 Date: Fri, 02 May 2008 23:01:00 -0000 From: Daniel Jacobowitz To: Ulrich Weigand , gdb-patches@sourceware.org, bauerman@br.ibm.com, amodra@bigpond.net.au Subject: Re: Shared library call problems on PowerPC with current binutils/gdb Message-ID: <20080502215132.GA12244@caradoc.them.org> Mail-Followup-To: Ulrich Weigand , gdb-patches@sourceware.org, bauerman@br.ibm.com, amodra@bigpond.net.au References: <200804282253.m3SMrwQF005602@d12av02.megacenter.de.ibm.com> <20080429003951.GA30324@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080429003951.GA30324@caradoc.them.org> User-Agent: Mutt/1.5.17 (2007-12-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00117.txt.bz2 On Mon, Apr 28, 2008 at 08:39:51PM -0400, Daniel Jacobowitz wrote: > On Tue, Apr 29, 2008 at 12:53:58AM +0200, Ulrich Weigand wrote: > > - Extend elf_symtab_read to treat a synthetic symbol XXX@plt as a > > mst_solib_trampoline symbol for XXX. > > Sounds reasonable. I suggested this to Aleksandar for another > problem, even :-) Though it was kind of nice to have it show up in > disassembly with @plt; will it still do that? It's nice to know > immediately when I'm looking at the PLT stub instead of the > definition. This appears to work consistently, where by work I mean disassembly shows the @plt sym but breakpoints on the undecorated version work fine. I'm not sure exactly why; it may be luck. If it's luck and someone cares later, we could make it work reliably by making sure the @plt version has an accurate size and the non-@plt version has size 0, or by making lookup_minimal_symbol_by_pc_section explicitly prefer text to non-text symbols. Hmm, thinking about this more, it probably won't work for your case after all. lookup_solib_trampoline_symbol_by_pc will return NULL if the first symbol we find is the text version. What do you think? I wrote this because I need it to get some symbol for malloc on Symbian, where I do not have a symbol file corresponding to libc. The PLT entry works nicely for that purpose. -- Daniel Jacobowitz CodeSourcery 2008-05-02 Daniel Jacobowitz * elfread.c (elf_symtab_read): Create trampolines for @plt symbols. Index: symbian-fsf/gdb/elfread.c =================================================================== --- symbian-fsf.orig/gdb/elfread.c 2008-05-02 16:56:20.000000000 -0400 +++ symbian-fsf/gdb/elfread.c 2008-05-02 17:34:42.000000000 -0400 @@ -521,6 +521,33 @@ elf_symtab_read (struct objfile *objfile if (msym != NULL) msym->filename = filesymname; gdbarch_elf_make_msymbol_special (gdbarch, sym, msym); + + /* For @plt symbols, also record a trampoline to the + destination symbol. The @plt symbol will be used in + disassembly, and the trampoline will be used when we are + trying to find the target. */ + if (msym && ms_type == mst_text && type == ST_SYNTHETIC) + { + int len = strlen (sym->name); + + if (len > 4 && strcmp (sym->name + len - 4, "@plt") == 0) + { + char *base_name = alloca (len - 4 + 1); + struct minimal_symbol *mtramp; + + memcpy (base_name, sym->name, len - 4); + base_name[len - 4] = '\0'; + mtramp = record_minimal_symbol (base_name, symaddr, + mst_solib_trampoline, + sym->section, objfile); + if (mtramp) + { + MSYMBOL_SIZE (mtramp) = MSYMBOL_SIZE (msym); + mtramp->filename = filesymname; + gdbarch_elf_make_msymbol_special (gdbarch, sym, mtramp); + } + } + } } } }