Vulnerability Development mailing list archives

Re: Stack Allocations


From: Andrew Barros <abarros () tjhsst edu>
Date: Tue, 10 Jul 2001 21:18:18 -0400


This could be an alignment issue? Some compilers will attempt to align 
things on word or paragraph boundries beacuse in some cases its more effcient

        -ajb

On Mon, Jul 09, 2001 at 09:27:10AM -0400, msoda () aspre net wrote:
->Hey all,
->
->I have been reading up on buffer overflows and have noticed something odd
->with gcc assembly output.  Consider the following:
->
->void func()
->{
->   char buf[15];
->}
->
->main()
->{
->   func();
->}
->
->When running 'gcc -S' it shows that 24 bytes are allocated on the stack
->for buf[].  I thought it should allocate only 16 bytes.  It works fine, it
->just makes no sense to me.  If I tweak the assembly and change it to 16
->bytes and also change the offsets to %ebp that reference it, it works fine
->also.
->
->Does anyone know why gcc does this?  My need to understand everything is
->killing me!
->
->-Marc
->
---end quoted text---

-- 
Andrew Barros <abarros () tjhsst edu>
PGP Key Fingerprint:
D3B8 0800 C45A 143E 5CF0  E112 0A1B AB36 B655 1FB8

Attachment: _bin
Description:


Current thread: