I have the following c programme:
void function(int a, int b, int c) {
char buffer1[]="aaaaa";
char buffer2[]="bbbbbbbbbb";
}
int main() {
function(1,2,3);
return 0;
}
When i print frame information when executing the function, I get the following gdb output:
(gdb) info frame
Stack level 0, frame at 0x7fffffffe1c0:
rip = 0x40119b in function (ss1.c:4); saved rip = 0x4011ca
called by frame at 0x7fffffffe1d0
source language c.
Arglist at 0x7fffffffe1b0, args: a=1, b=2, c=3
Locals at 0x7fffffffe1b0, Previous frame's sp is 0x7fffffffe1c0
Saved registers:
rbp at 0x7fffffffe1b0, rip at 0x7fffffffe1b8
(gdb)
When printing the addresses of the function arguments and local variables, I get:
(gdb) p/x &c
$65 = 0x7fffffffe184
(gdb) p/x &b
$66 = 0x7fffffffe188
(gdb) p/x &a
$67 = 0x7fffffffe18c
(gdb) p/x &buffer1
$68 = 0x7fffffffe197
(gdb) p/x &buffer2
$69 = 0x7fffffffe19d
Why is there a gap of 11 bytes between the address of arg a and that of var buffer1 -and not just a gap of 4 bytes which is the size of a?
Why is there a gap of 19 bytes between the address of buffer2 and the frame pointer (0x7fffffffe1b0) -and not just a gap of 11 bytes which is the size of buffer2?
Thanks