Re: Stack Allocations

From: Andrew Barros (abarrosat_private)
Date: Tue Jul 10 2001 - 18:18:18 PDT

  • Next message: Nicolas Gregoire: "Re: Antivirus scanner DoS with zip archives"

    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, msodaat_private 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 <abarrosat_private>
    PGP Key Fingerprint:
    D3B8 0800 C45A 143E 5CF0  E112 0A1B AB36 B655 1FB8
    
    
    



    This archive was generated by hypermail 2b30 : Thu Jul 12 2001 - 21:47:41 PDT