From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27446 invoked by alias); 8 Dec 2011 04:01:40 -0000 Received: (qmail 27436 invoked by uid 22791); 8 Dec 2011 04:01:39 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-yx0-f169.google.com (HELO mail-yx0-f169.google.com) (209.85.213.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 08 Dec 2011 04:01:26 +0000 Received: by yenq10 with SMTP id q10so1388844yen.0 for ; Wed, 07 Dec 2011 20:01:25 -0800 (PST) Received: by 10.236.73.138 with SMTP id v10mr1460489yhd.109.1323316885783; Wed, 07 Dec 2011 20:01:25 -0800 (PST) Received: from bubble.grove.modra.org ([115.187.252.19]) by mx.google.com with ESMTPS id v48sm6926322yhk.6.2011.12.07.20.01.22 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Dec 2011 20:01:24 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 86EFB170C2BF; Thu, 8 Dec 2011 14:31:18 +1030 (CST) Date: Thu, 08 Dec 2011 04:01:00 -0000 From: Alan Modra To: Michael Eager Cc: gdb@sourceware.org, "Ryan S.Arnold" Subject: Re: Next over function with Secure PLT Message-ID: <20111208040118.GB10960@bubble.grove.modra.org> References: <4EE0088C.4070208@eagerm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4EE0088C.4070208@eagerm.com> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-12/txt/msg00008.txt.bz2 On Wed, Dec 07, 2011 at 04:58:22PM -0800, Michael Eager wrote: > When using PowerPC Secure PLT, trying to "next" over a > library function in a shared library does not work correctly. > Instead of skipping over the function, gdb steps through > the PLT entry which shows up as code in > call___do_global_ctors_aux. As an aside, if you use a newer linker symbols will be emitted on each plt stub by default for -shared. > This doesn't happen when "nexting" over a library function > in the executable. Next works the same as with a local function. > > When reading the executable, ppc_elf_get_synthetic_symtab() > calls is_nonpic_glink_stub() to recognizes the PLT stub and > then generates internal symbols for each PLT stub like foo@plt. > It also creates an entry for __glink and __glink_PLTresolve. > > If I modify is_nonpic_glink_stub() to recognize the shared > library PLT stub format, similar internal symbols are created > and gdb seems to work correctly. Don't do that. You can't easily know which plt entry is loaded by a PIC stub. > There's a comment before the call: > /* If the stubs are those for -shared/-pie then we might have > multiple stubs for each plt entry. If that is the case then > there is no way to associate stubs with their plt entries short > of figuring out the GOT pointer value used in the stub. */ > if (!is_nonpic_glink_stub (abfd, glink, > glink_vma - GLINK_ENTRY_SIZE - glink->vma)) > > What is this trying to tell me? What are the circumstances where > there would be multiple stubs for each PLT entry? If there are > multiple stubs, then this might create multiple foo@plt symbols > with different values. Would this cause any problems? There can be multiple stubs using the same PLT entry when linking -fPIC code. -fPIC effectively gives you a 64k GOT per file, with the result that r30 may differ from one function to another in the executable. Since r30 is used in a PIC stub to calculate the PLT entry address, you need a different stub for different values of r30. gdb ought to just pattern match the stub code to recognize when the pc is in a stub. -- Alan Modra Australia Development Lab, IBM