From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24777 invoked by alias); 15 Oct 2004 19:16:53 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 24766 invoked from network); 15 Oct 2004 19:16:52 -0000 Received: from unknown (HELO wiesinger.com) (212.186.124.96) by sourceware.org with SMTP; 15 Oct 2004 19:16:52 -0000 Received: from bbs.intern (localhost [127.0.0.1]) by wiesinger.com (8.12.10/8.12.10) with ESMTP id i9FJGlI9004757; Fri, 15 Oct 2004 21:16:47 +0200 Received: from localhost (gerhard@localhost) by bbs.intern (8.12.10/8.12.10/Submit) with ESMTP id i9FJGlld004753; Fri, 15 Oct 2004 21:16:47 +0200 Date: Fri, 15 Oct 2004 19:16:00 -0000 From: Gerhard Wiesinger To: Jeffrey A Law cc: gcc-help@gcc.gnu.org Subject: Re: gcc and -fPIC In-Reply-To: <1097867494.4992.3.camel@localhost.localdomain> Message-ID: References: <72f84372eb57.72eb5772f843@southeast.rr.com> <1097867494.4992.3.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-MailScanner-Information-wiesinger.com: See www.mailscanner.info for information X-MailScanner-wiesinger.com: Found to be clean X-MailScanner-From: lists@wiesinger.com X-SW-Source: 2004-10/txt/msg00119.txt.bz2 On Fri, 15 Oct 2004, Jeffrey A Law wrote: > On Fri, 2004-10-15 at 12:51, Gerhard Wiesinger wrote: >> On Fri, 15 Oct 2004 bserdar@nc.rr.com wrote: >> >>> >>>> 80485b3: e8 00 00 00 00 call 80485b8 >>>> 80485b8: 5b pop %ebx >>>> 80485b9: 81 c3 5c 12 00 00 add $0x125c,%ebx >>> >>> With pop ebx, it pops the eip at that instruction to ebx. I'm guessing it'll use ebx as a base pointer to data (or code?) from this point on. You can verify this guess by accessing some global variables from within X::f() and see whether it uses ebx-relative access. >>> >> >> OK, but why is the function call at 80485b3 to the next address at >> 80485b8? > Because it allows us to get the current PC's value in a position > independent way. > > ie, the call pushes the return address onto the stack and we pop > that value into ebx. > OK, I got it now. Thank you. Ciao, Gerhard