GCC substracting strange amount of bytes from esp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi list,

I've got a question concerning the assembly produced by gcc of
the following c code:

void test() {
   char buffer1[10];
   char buffer2[10];
   int *ret;
}

void main() {
  test();
}

If I disassemble the test function I see that gcc 4.5.2 produced the
following assembly:

   0x08048374 <+0>:     push   %ebp
   0x08048375 <+1>:     mov    %esp,%ebp
   0x08048377 <+3>:     sub    $0x20,%esp
   0x0804837a <+6>:     leave
   0x0804837b <+7>:     ret

I would expect that 0x1c or 0x18 byte will be substracted from esp, but
it's 0x20. 

Asking uncle Google I found an old bug report that gcc used to
substracted more from esp than necessary
(http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9624), but it's marked
fixed since 4.0.0.

I made a few tests with other gcc versions (2.9.5, 3.3, 4.0, 4.2, 4.4)
and all substract more bytes than necessary some more than others but
no version used the exact number of bytes.

Am I missing or misunderstanding something or is this a feature /
bug? :)
Thanks for any hint or link.
Have a nice day!

Balle
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk1C6hEACgkQEQHD8bvs9q1UQgCgofxlH74ybvN5rIvB3yIvvBRf
zqIAnj64oNkFVD/f2erCI973gUheWK1Y
=C/15
-----END PGP SIGNATURE-----



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux