3

I'm trying to learn how GOT/PLT works in ELF binaries. The way I see it - there's three sections; .got, .plt and .got.plt.

When the program tries to call an imported function which is lazy binded, it does so by calling the plt procedure. In case the entry has not yet been resolved, the jump in the plt section jumps to the address pointed by in the .got.plt section, which points back to the .plt section, where arguments are set up for the dlresolve (an index to the JMPREL, among other things, if I'm understanding correctly). The .plt then resolves the address of the function and calls it with the provided arguments. In the next call, when the function has already been resolved, the .plt section jumps again to the address pointed to by the .got.plt section, which now contains the resolved address of the function (so that it doesn't jump back to the .plt section).

It seems that in both cases only the .plt and .got.plt sections are involved, so I'm struggling to understand what's the purpose of the .got section. I read somewhere that it contains the global variables, but that seem to reside in the .data section, so I don't think that's really it.

Thanks!

1

1 Answer 1

1

.got.plt contains the addresses of the external functions used by the program. Previously that task was fulfilled by the common .got section, but nowadays it got split, so .got contains only pointers to the external data symbols (if any).

Your Answer

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

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