public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Gerhard Wiesinger <lists@wiesinger.com>
To: Jeffrey A Law <law@redhat.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: gcc and -fPIC
Date: Fri, 15 Oct 2004 19:16:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.61.0410152112220.578@bbs.intern> (raw)
In-Reply-To: <1097867494.4992.3.camel@localhost.localdomain>



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 <X::f()+0xc>
>>>>  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

  reply	other threads:[~2004-10-15 19:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-15 18:26 bserdar
2004-10-15 18:46 ` Dave Korn
2004-10-15 18:51 ` Gerhard Wiesinger
2004-10-15 19:11   ` Jeffrey A Law
2004-10-15 19:16     ` Gerhard Wiesinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-10-15 18:58 bserdar
2004-10-15 17:08 Gerhard Wiesinger
2004-10-15 17:54 ` Dave Korn
2004-10-15 19:55 ` Andreas Schwab
2004-10-16  6:06   ` Gerhard Wiesinger
2004-10-16 12:09     ` Andreas Schwab
2004-10-16 15:17       ` Daniel Jacobowitz
2004-10-17 18:57         ` Gerhard Wiesinger
2004-10-17 19:31           ` Daniel Jacobowitz
2004-10-18  5:17             ` Gerhard Wiesinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0410152112220.578@bbs.intern \
    --to=lists@wiesinger.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=law@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).