Is this always the address for GDB debug program?

前端 未结 2 2022
天命终不由人
天命终不由人 2021-01-29 01:39

I will narrow down my questions:

The entry address in GDB stays the same for the same program (even after reboot, and after rewriting the source code).

Why is th

相关标签:
2条回答
  • 2021-01-29 02:12

    Your program is (at least partially) statically linked, and main() almost certainly is. Rebooting your computer isn't going to change that statically linked part of the executable.

    0 讨论(0)
  • 2021-01-29 02:35

    For example 0x80483f4 is the starting address.

    This is likely. Unless you have PIE (position independent executables), it will stay the same (for one binary) forever.

    $2 = 0x80483fa <main()+6>
    (gdb) x $2
    0x80483fa <main()+6>:   0x3fc45c7
    

    That is the binary representation of the instructions at main()+6. Will never change in one binary.

    (gdb) p 0x3fc45c7
    $3 = 66864583   <-- even after reboot.
    

    That means 0x3fc45c7 is 66864583 in decimal...

    Note that none of this has anything to do with a or b.

    BTW the best way to get values of variables "before assignment" is to printf them before the assignment.

    0 讨论(0)
提交回复
热议问题