LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

What happens during symbol relocation?

The linker merges the object files' sections, gives each symbol a final address, and patches every reference to point at that address.

Before: .text/.data/.bss scattered across main.o and swap.o. After: all .text merged, all .data merged, .bss zero-filled in one executable

* Same-type sections from every object file collapse into one: all code together, all initialized data together, .bss zero-filled. *

The linker:

  1. Merges sections - combines all .text sections into one, all .data into one
  2. Assigns addresses - gives each symbol a final memory address
  3. Patches references - updates all code that references symbols

Before relocation (separate object files):

main.o:              swap.o:
  main()               swap()
  buf[2]={1,2}         *bufp0=&buf[0]
                       static *bufp1

After relocation (single executable):

Executable:
  Headers
  System code
  main()         ←─┐
  swap()         ←─┼── .text (merged)
  More code      ←─┘
  System data
  buf[2]={1,2}   ←─┐
  *bufp0=&buf[0] ←─┼── .data (merged)
  *bufp1         ←─┘   .bss (zero-initialized)

Go deeper:

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