All of lore.kernel.org
 help / color / mirror / Atom feed
From: matthias.bgg@gmail.com (Matthias Brugger)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Find out function arguments value from stack pointer
Date: Wed, 12 Dec 2012 12:30:13 +0100	[thread overview]
Message-ID: <50C86AC5.9070507@gmail.com> (raw)
In-Reply-To: <CAJKgH8BMYsGjXneVragJMwmMQn-J6vRoQ_0q+tXKw6+NsUTRHg@mail.gmail.com>

On 12/12/2012 12:24 PM, Manavendra Nath Manav wrote:
> On Wed, Dec 12, 2012 at 4:38 PM, Fabio Pozzi <pozzi.fabio@gmail.com> wrote:
>>> When i call  print values at offsets starting from
>>> __builtin_frame_address (0) the function arguments start from offset
>>> 2. How can I confirm that this behavior is always consistent.
>>
>> Arguments are pushed on the stack before the saved frame pointer, thus
>> you have to add an offset equal to the frame pointer address size if
>> you start from the beginning of the saved frame pointer record on the
>> stack.
>
> Thanks Fabio!
> If I execute the same code on ARM arch, does it needs any changes?
>

I just wanted to mention. AFAIK who parameters are passed to the called 
function depends on the architecture (stack or some registers + stack).
I vaguely remember some MIPS ASM programming exercises in first year of 
university...

But if gcc has a in built function, that should do on all architectures, 
though.

  reply	other threads:[~2012-12-12 11:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12 10:15 Find out function arguments value from stack pointer Manavendra Nath Manav
2012-12-12 10:26 ` Fabio Pozzi
2012-12-12 10:32   ` Manavendra Nath Manav
2012-12-12 10:44     ` Manavendra Nath Manav
2012-12-12 11:08       ` Fabio Pozzi
2012-12-12 11:24         ` Manavendra Nath Manav
2012-12-12 11:30           ` Matthias Brugger [this message]
2012-12-12 23:09           ` 卜弋天

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=50C86AC5.9070507@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.