From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22139 invoked by alias); 15 Oct 2004 19:11:48 -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 22132 invoked from network); 15 Oct 2004 19:11:47 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 15 Oct 2004 19:11:47 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.10) with ESMTP id i9FJBbXr026670; Fri, 15 Oct 2004 15:11:42 -0400 Received: from [172.16.83.162] (vpn83-162.boston.redhat.com [172.16.83.162]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id i9FJBar16097; Fri, 15 Oct 2004 15:11:36 -0400 Subject: Re: gcc and -fPIC From: Jeffrey A Law Reply-To: law@redhat.com To: Gerhard Wiesinger Cc: gcc-help@gcc.gnu.org In-Reply-To: References: <72f84372eb57.72eb5772f843@southeast.rr.com> Content-Type: text/plain Organization: Red Hat, Inc Message-Id: <1097867494.4992.3.camel@localhost.localdomain> Mime-Version: 1.0 Date: Fri, 15 Oct 2004 19:11:00 -0000 Content-Transfer-Encoding: 7bit X-SW-Source: 2004-10/txt/msg00118.txt.bz2 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. jeff