1
000011d9 <main>:
11d9:       8d 4c 24 04             lea    0x4(%esp),%ecx
11dd:       83 e4 f0                and    $0xfffffff0,%esp
11e0:       ff 71 fc                push   -0x4(%ecx)
11e3:       55                      push   %ebp
11e4:       89 e5                   mov    %esp,%ebp
11e6:       53                      push   %ebx
11e7:       51                      push   %ecx
11e8:       83 ec 20                sub    $0x20,%esp
11eb:       e8 f0 fe ff ff          call   10e0 <__x86.get_pc_thunk.bx>
11f0:       81 c3 10 2e 00 00       add    $0x2e10,%ebx
11f6:       c7 45 ef 49 41 32 32    movl   $0x32324149,-0x11(%ebp)
10
  • the answer also stated using GDB or any debugger so it is easy to lookup what esp is by querying the register and it shouldn't matter what the actual address of esp is it is like a hotel room you pay for the time you stay and you may get room 102 or room 704 edit your question to state what is the actual problem you are trying to solve or understand
    – blabb
    Mar 5, 2022 at 13:55
  • Hi, I re-wrote my question so it's more clear. Thanks!
    – user40564
    Mar 6, 2022 at 14:31
  • i don't think a compiler will emit -0x11(%ebp) is that a randomly typed instruction and you are still not clear what calculation you want to perform ? that last instruction is a store instruction it stores the constant "22AI" in some place
    – blabb
    Mar 6, 2022 at 18:06
  • Seriously thank you so much! I tried to explain It better in another comment but I'm new to this website also and I'm not sure where things get posted
    – user40564
    Mar 6, 2022 at 18:13
  • Also would you mind explaining how you determined It was a store instruction and specifically the value 22AI? Really sorry if that is a waste of time for you
    – user40564
    Mar 6, 2022 at 18:20

1 Answer 1

2

You are approaching it wrong, the problem is the memory of esp can't be known before you run the program because the value is always random at the runtime so you can't know for sure the real register esp value until you run it.

The esp is only need to store the top of your program stack. So i don't think the actual value is neccessary because most of the time we only care about the offset from esp.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.