From: theguest <theguest@ono.com>
To: linux-assembly@vger.kernel.org
Subject: Basic assembly
Date: Mon, 11 Nov 2002 01:01:31 +0100 [thread overview]
Message-ID: <20021111000131.GA9775@theguest.homelinux.net> (raw)
Hi!
First of all, I'm spanish so sorry for my bad english.
I'm new on the list and I'm a novice in assembly. I'm interested in
linux assembly because I'm interested in linux security, buffer
overflows...
So, I'm reading the "Smash the stack for fun and profit" and the results
that Aleph get are different from mine.
For example he has this code in C:
-------------
void function(int a, int b, int c){
char buffer1[5];
char buffer2[10];
}
void main(){
function (1,2,3);
}
-------------
He gets linux assembly code using gcc:
$ gcc -S -o example1.s example1.c
He says his assembly code has a line like:
subl $20,%esp
He says the memory is reserved multiples of "word". He says word=4bytes.
So our 5 bytes buffer needs 2 words = 8 bytes and buffer2[10]->12bytes.
That's why uses subl to get 20 bytes from esp. That seems correct for
me but when I compile it in assembly using gcc I don't get the same
assembly code...
For example:
subl $8,%esp
addl $-4,%esp
in the main function
and in the function <function>:
subl $40,%esp
Why are my code reserving other quantity of space for variables?
It's something related with optimizated compilation in gcc?
Thanks in advance and sorry if something isn't correct in my first email
to the list.
next reply other threads:[~2002-11-11 0:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-11 0:01 theguest [this message]
2002-11-11 4:27 ` Basic assembly Joseph D. Wagner
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=20021111000131.GA9775@theguest.homelinux.net \
--to=theguest@ono.com \
--cc=linux-assembly@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