I can't use RSP to reference the end of the stack

55 views Asked by At

in my system (x86_64), when I'm using GDB, both RBP and RSP point to the same memory address after pushing a new stack frame, therefore I can't reference the end of the stack with the register RSP because it has the same value as RBP. I saw that in other systems the register RSP is used to keep track of the address of the end of the stack, but unfortunately it doesn't work like this in my GDB.

I'm using this little code to test it:

#include <stdio.h>

void test_function(int a, int b, int c, int d) {
    int flag;
    char buffer[10];
 
    flag = 31337;
    buffer[0] = 'A';
}

int main(){
    test_function(1, 2, 3, 4);
}

this is what I get in GDB:

gdb test

Notice that there is also no "sub" operation in assembly for RSP in the function prologue.

So, my question is, is there any other way to access to the end of the stack if I don't have the RSP register?

I'm still a newbie to this, I'm learning all the time, so there are things that maybe I'm ignoring or not understanding.

0

There are 0 answers