Link to home
Start Free TrialLog in
Avatar of smisk
smisk

asked on

Newbie : Linux Word Size...

I'm running Linux (2.4.9) on an Intel box and trying to determine what is going on with this test :

Very simply, I have a function in C that goes as follows :

void f() {
  char buf[7];
}

When compiling to assembly via gcc -S and looking at the output, I see the function looks as follows :

f:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $24, %esp
        leave
        ret

Why is the assembly subtracting 24 bytes for a 7 byte buffer?  I know it has to be word aligned, but when I change buf[7] -> buf[8] I get the expected results :

f:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        leave
        ret

Shouldn't buf[7] produce the same output?

Thanks,
Steve
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial