Hi I am trying to find the memory address of where my data gets stored.
This is the assembly code of the function.
0x08048b20 <+0>: push %ebp
0x08048b21 <+1>: mov %esp,%ebp
0x08048b23 <+3>: sub $0x28,%esp
0x08048b26 <+6>: lea -0x14(%ebp),%eax
0x08048b29 <+9>: mov %eax,(%esp)
0x08048b2c <+12>: call 0x8048990 <Gets>
0x08048b31 <+17>: mov $0x1,%eax
0x08048b36 <+22>: leave
0x08048b37 <+23>: ret
My data which is a string gets stored at -0x14(%ebp) - (pretty positive). And I know the return address should be at 4(%ebp). What I am trying to do is set the return address to point at my code. And I can't use assembly to do this. I need to know the exact memory location of my where my function starts (which I know it stored at -0x14(%ebp)). Can anyone help me on how to get the memory location of that position?
The address on this line
0x08048b20 <+0>: push %ebp
The 0x08048b20 is the memory location for the function I am in, not %ebp right? My thinking is that if I get the memory location for %ebp, I can calculate the memory location of where my function starts.
I am using gdb, and I don't know how to get the memory address of it? Please, any help would be appreciated. Thank you.
EDIT: When I am standing at line <+6> in the assembly code, I print the values of %ebp and %esp, and they have an exact difference of 0x28 like they should. So I assumed that the address of %ebp is the value I get when I print it in gdb.
However, when I subtract 0x14 from this value (0xbfffb5d8) to give 0xbfffb5c4; it doesn't know where to jump to. If I have stored my string (which is actually byte code of disassembled code) at -0x14(%ebp), and I want to run that code; shouldn't I be putting the return address to -0x14(%ebp) or am I thinking completely wrongly?