I was under the impression that the order you declared variable would decide the ordering they are put on the stack when a function is called, there would be an inverse relationship (the reversed order from how they are declared would be used to put them on the stack).
For example I have two variables:
char buffer[16];
int flag = 0;
I would like to be sure that the flag always is put before the buffer but no matter which order i declare them in C, gdb shows that the buffer is always put before the flag on the stack wich is very bad for stack based buffer overflows. Why is this?
The system im using in Arch Linux 64bit running on an x86_64 with gcc 5.2