From: Daniel Souza <thehazard@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: x86 and linux stack layout
Date: Sun, 21 Nov 2004 10:33:53 -0300 [thread overview]
Message-ID: <e1e1d5f40411210533b3d5ae4@mail.gmail.com> (raw)
Hi everybody
can anyone explain me how the x86 stack works ? like...
the stack starts at 0xbfffe000, growing forward, at the start of
the main() call (or another elf session that starts after main()
and initializes the argc, argv and envp args), and after
every CALL if modifies the EBP and ESP doing :
and after a RET call, it does:
and differences between JMP, LONGJMP and CALL,
what registers they change, etc.
And so, how function arguments looks like in the stack, for
example, when a function like
int foo (u_long boo, char *moo, char loo) {}
is caught, how they arguments looks like in the stack ?
i know that will be a 4 bytes long integer, another 4bytes
pointer (32b) and a 1byte char, in a reverse order. Will the
stack pointer be added (or subtracted) by 9 bytes, that
mean, the sum of all argument type lengths ?
When a function returns, where its result is stored on ?
If I make a lot of function calls, in anywhere the position of stack
of each call needs to be stored (like a backtrace)... where
is it stored on ?
what are stack frames ? whats the relation between ESP and EBP ?
What those ELF sessions that are caught before main() do ? what
happens internally
when main() returns ? like, execute another elf session like .dtors
and try to return the return code to OS, as return of a execve() for
example. Is it right ?
Thanks a lot =)
Daniel
--
# (perl -e 'while (1) { print "\x90"; }') | dd of=/dev/war
next reply other threads:[~2004-11-21 13:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-21 13:33 Daniel Souza [this message]
2004-11-21 15:13 ` x86 and linux stack layout Justinas
2004-11-21 19:08 ` Glynn Clements
2004-11-21 20:07 ` Daniel Souza
2004-11-21 21:00 ` Glynn Clements
2004-11-21 23:07 ` Daniel Souza
2004-11-22 3:50 ` Glynn Clements
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=e1e1d5f40411210533b3d5ae4@mail.gmail.com \
--to=thehazard@gmail.com \
--cc=linux-c-programming@vger.kernel.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 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 NNTP newsgroup(s).