linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* x86 and linux stack layout
@ 2004-11-21 13:33 Daniel Souza
  2004-11-21 15:13 ` Justinas
  2004-11-21 19:08 ` Glynn Clements
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Souza @ 2004-11-21 13:33 UTC (permalink / raw)
  To: linux-c-programming

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-11-22  3:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-21 13:33 x86 and linux stack layout Daniel Souza
2004-11-21 15:13 ` 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

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).