What is __i686.get_pc_thunk.bx? Why do we need this call?

后端 未结 2 1346
醉梦人生
醉梦人生 2021-02-01 01:42

When I disassemble my small function, I happened to see this call

call   0xf60d2f47 <__i686.get_pc_thunk.bx>.

I have no clue why I need t

2条回答
  •  时光说笑
    2021-02-01 02:21

    Adding more to the information by example:

    Suppose after you do disass on gdb inside function startup, then you will find something like this:

    0x012c17a3  :     call   0x12b2ce7 <__i686.get_pc_thunk.bx>
    0x012c17a8 :     add    $0x10d6518,%ebx
    

    Then after you have called __i686.get_pc_thunk.bx, register ebx will be populated by value 0x012c17a8, which is the address of next instruction.

    You can read the function as get_pc(program counter).

    I found this article very nice for better understanding:

    https://www.technovelty.org/linux/plt-and-got-the-key-to-code-sharing-and-dynamic-libraries.html

提交回复
热议问题