Table of Contents

IronForgeCyber

Courses

Resources

Blog

Log In



IronForgeCyber

AboutPrivacyTerms

© 2026 IronForgeCyber. All rights reserved.

  1. courses
  2. binex-stack-exploits
  3. plt-got
5 min read

The PLT and GOT

Before we can overwrite a library function or leak one to beat ASLR, we need to understand how a program reaches a library function in the first place. That path runs through two tables the linker builds into every dynamically-linked binary: the PLT and the GOT. This page is the reference for both; later challenges (GOT overwrites and ret2plt) assume you have read it.

Static vs. Dynamic Linking

There are two ways a binary can be linked to the libraries it uses. Static linking compiles the library functions directly into the binary. Dynamic linking leaves the library out and uses the functions from a separate file (like libc) at runtime.

Dynamic linking is by far the most common. It keeps the binary small for distribution and avoids shipping a copy of libc with every program — every system already has one. The catch is that the binary no longer knows where its library functions live: libc is a separate file, loaded wherever the loader decides to put it. The binary needs a way to find system, printf, and friends at runtime. That is the job of the PLT and the GOT.

How a Library Call Is Resolved

Consider the most basic program: Hello World. It calls printf, which is declared in the header stdio.h but defined in libc. At compile time the linker is happy to accept the call because the header exists, but the real address of printf is unknown until the program runs and libc is loaded.

Two tables bridge that gap:

  • The PLT (Procedure Linkage Table) is a list of small stubs, one per imported function. Calling a function's PLT stub is equivalent to calling the library function itself. Because the PLT is a compile-time construct, its address is fixed in the binary (when PIE is off). This is why GDB writes library calls as printf@plt.
  • The GOT (Global Offset Table) is a table of addresses. Each entry holds the real location of a libc function once it has been resolved. The GOT is a run-time construct — it gets filled in as the program executes.

The GOT uses lazy binding: a function's real address is only resolved the first time it is called. Before that first call, the GOT entry points back into the PLT, at the resolver stub. On the first call the resolver runs, looks up the function's true address in libc, writes it into the GOT entry, and jumps there. Every call afterward reads the now-filled GOT entry and jumps straight to libc.

main call 0x401040 <puts@plt> puts@plt Jump through the GOT; the rest is the lazy-bind resolver. 0x401040 <+0>: jmp QWORD PTR [rip+0x2fc2] 0x401046 <+6>: push 0x1 0x40104b <+11>: jmp 0x401020 <_init+0x20> puts@got [0x404008] puts@GLIBC_2.2.5 → 0x401046 1st call → back into the PLT (resolver); afterward → libc. puts — inside libc endbr64 push r14 ... ret

In GDB you can read the GOT directly with the got command. Before a function's first call, its GOT entry points back into the PLT (the resolver); after the first call it points into libc.

Info
If a GOT entry is still empty (unresolved), the PLT stub falls through to the dynamic linker, which resolves the address and writes it into the GOT before jumping to the function.

Why This Matters for Exploitation

Two properties of these tables make them a recurring target:

  • The GOT is writable (by default). Each entry is just a function pointer sitting in a writable data section. If you have a write primitive, you can overwrite a GOT entry so that calling (say) printf actually jumps to win. That is a GOT overwrite.
  • The GOT reveals libc. Each resolved entry is a live libc address. If you can leak one, you can subtract its known offset and recover the libc base — the key to beating ASLR. Because the GOT lives in the binary (constant offset when PIE is off or defeated), you always know where to read.

RELRO: Protecting the GOT

The only protection specific to the GOT is RELRO (RELocation Read-Only). It comes in three levels:

  1. No RELRO: no protection on the GOT at all.
  2. Partial RELRO: moves the GOT above the program's variables (into the data segment) so a plain buffer overflow can't run into it. It does not make the GOT read-only, so a write-what-where still reaches it. This is the default on most toolchains.
  3. Full RELRO: marks the entire GOT read-only after load, which prevents GOT overwrites entirely. It is not the default because it forces the loader to resolve every function address at startup (no lazy binding), slowing program load.

checksec reports which level a binary uses. Partial RELRO — the common case — is exactly what makes GOT overwrites possible, as we'll see next.

the real implementation1st call