x86 Assembly - Why is [e]bx preserved in calling conventions?

后端 未结 3 1703
心在旅途
心在旅途 2021-01-06 01:22

I\'ve noticed that a lot of calling conventions insist that [e]bx be preserved for the callee.

Now, I can understand why they\'d preserve something like [e]sp or [e]

3条回答
  •  日久生厌
    2021-01-06 02:17

    One of the main reasons, certainly for the i386 ELF ABI, is that ebx holds the address of the global offset table (GOT) register for position-independent code (PIC). See 3-35 of the specification for the details. It would be disruptive in the extreme, if, say, shared library code had to restore the GOT after every function call return.

提交回复
热议问题