Re: Smashing the Stack?

From: Gigi Sullivan (sullivanat_private)
Date: Sat Jul 20 2002 - 05:55:34 PDT

  • Next message: Sebastian Hegenbart: "Re: Smashing the Stack?"

    Aiee :)
    
       Hello!
    
    On Wed, Jul 17, 2002 at 08:46:58AM -0700, Jeremy Junginger wrote:
    > void function(int a, int b, int c) {
    > 	char buffer1[5];
    > 	char buffer2[10];
    > 
    > void main() {
    > 	function(1,2,3);
    > }
    > 
    > in "word" (4 byte) increments.   That makes sense; however, when I
    > generate the assembly code with the exact same code, I see that it is
    > subtracting 40 rather than the expected 20
    > (bufger1(5bytes=2words=8bytes+10bytes=3words=12bytes).  This part looks
    
       This should be due to default stack boundary that gcc uses. Version 2.7.2.3
       (quite old) seems to have default stack boundary set to 2; that means
       that you have stuff on a 2^2=4 byte, i.e. dword boundary.
    
       For example, gcc 2.95.2 seems to set this default to 3, IIRC. 
       To change this, just compile using -mpreferred-stack-boundary=2 so you'll
       get the "usual" stuff on a dword (4 byte) boundary.
    
       Hope this helps.
    
    bye bye
    
                               -- gg sullivan
    
    -- 
    Lorenzo Cavallaro `Gigi Sullivan' <sullivanat_private>
    
    Until I loved, life had no beauty;
    I did not know I lived until I had loved. (Theodor Korner)
    



    This archive was generated by hypermail 2b30 : Sat Jul 20 2002 - 08:46:23 PDT