From: "Ihar 'Philips' Filipau" <filia@softhome.net>
To: Jaco Kroon <jkroon@cs.up.ac.za>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: stack allocation and gcc
Date: Wed, 10 Mar 2004 15:25:09 +0100 [thread overview]
Message-ID: <404F2545.40708@softhome.net> (raw)
In-Reply-To: <404F104C.2030206@cs.up.ac.za>
Jaco Kroon wrote:
> Hi Ihar,
>
> In your code you have 3 buffers, one in the mani branch of 32 bytes and
> one of 32 bytes in each of the sub branches. This adds up to a total of
> 64 bytes since as you say, the two buffers named buf2[32] can be
> shared. Thus it is 32 bytes for buf and 32 bytes for the shared
> buffer. Now if you look at the function startup code:
>
> 0: 55 push %ebp
> 1: 89 e5 mov %esp,%ebp
> 3: 83 ec 68 sub $0x68,%esp
>
> THe push saves the frame pointer (ebp). The mov sets up the new stack
> frame and the sub allocates space of 68 bytes on the stack, 4 bytes more
> than the expected 64, this is probably for temporary storage required
> somewhere in the function. As such, gcc does not allocate 32 bytes too
> many (at least not on i386, but probably not on other architectures
> either).
>
> Jaco
>
0x68 != 68.
[ All known to me assemblers on ix86 use hexadecimal number by
default. I was sort of surprised to find out that ppc gas uses decimal
numbers only. ]
0x68 == 104 == 32*3 + 4 + 4.
As I have said, keep adding to function 'do { char buf[32];
printf(buf); } while(0)' increse this number. As in my logic it is
supposed to be unchanged - all renundant buffers do have same size - 32
bytes.
--
Ihar 'Philips' Filipau / with best regards from Saarbruecken.
-- _ _ _
"... and for $64000 question, could you get yourself |_|*|_|
vaguely familiar with the notion of on-topic posting?" |_|_|*|
-- Al Viro @ LKML |*|*|*|
next prev parent reply other threads:[~2004-03-10 14:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-10 12:27 stack allocation and gcc Ihar 'Philips' Filipau
2004-03-10 12:55 ` Jaco Kroon
2004-03-10 13:15 ` Bart Hartgers
2004-03-10 13:21 ` Richard B. Johnson
2004-03-10 15:05 ` Ihar 'Philips' Filipau
2004-03-11 6:04 ` IBM Thinkpad with docking station Frank Fiene
2004-03-10 14:25 ` Ihar 'Philips' Filipau [this message]
[not found] ` <200403101344.37171.baldrick@free.fr>
2004-03-10 14:06 ` stack allocation and gcc Ihar 'Philips' Filipau
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=404F2545.40708@softhome.net \
--to=filia@softhome.net \
--cc=jkroon@cs.up.ac.za \
--cc=linux-kernel@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