PLT and GOT for shared libs (ELF)

Introduction

With static linking, the position of the code of the static libs are exactly known during compile time. This isn’t true for shared linking, and PLT and GOT are necessary to call to the right addresses in the shared libs.


Procedure

  1. To call a shared lib function, your app is requesting the PLT.
  2. The PLT then requests the actual address from the GOT.
    • First time: The address has to be calculated and stored in the GOT.
    • Next time: The address can directly be read from the GOT.

Terminology

  • PLT (Procedure Linkage Table)
  • GOT (Global Offset Table)