v5 Linker: merging module bytecode

Lesson, slides, and applied problem sets.

View Slides

Lesson

v5 Linking: merging module bytecode

Each module compiles independently. The linker:

  • validates import order
  • merges function tables
  • rewrites function IDs
  • concatenates init code

Function ID rebasing

Modules start IDs at 0, so we offset them:

newID = oldID + offset

Then patch every MAKE_CLOSURE to the new ID.

Entry

The main module's init code runs last.


Module Items