LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

What is the Global Offset Table (GOT) and how is it used?

The Global Offset Table is a per-process table of addresses; PIC code reads each external symbol's real location from it after the dynamic linker fills it in.

Read-only shared library code reads an address from the read-write per-process GOT, which points to external data; the dynamic linker patches the GOT entry at load

* Shared code stays read-only by reaching external data indirectly: it reads the address from the per-process GOT, which the dynamic linker fills in at load. *

Problem: Shared library code doesn't know where external variables are located at compile time.

Solution: Indirect access through GOT:

  1. Each external symbol gets a GOT entry
  2. Code references symbols via GOT
  3. Dynamic linker fills GOT entries at load time

Memory layout:

Library code (.text) - read-only, shared
    ↓
    references
    ↓
GOT (.got) - read-write, per-process
    ↓
    contains addresses of
    ↓
External data

Example:

// Library code wants to access external 'buf'
extern int buf[];
int x = buf[0];

Generated PIC code:

# Get GOT base
lea  _GLOBAL_OFFSET_TABLE_(%rip), %rbx
# Load address of buf from GOT
mov  buf@GOT(%rbx), %rax
# Access buf[0]
mov  (%rax), %eax

Tip: The GOT is in the data segment, so each process can have different values (pointing to different memory locations).

Go deeper:

From Quiz: REVE1 / Program Execution | Updated: Jul 10, 2026