v5 Linker: merging module bytecode
Lesson, slides, and applied problem sets.
View SlidesLesson
v5 Linking: merging module bytecode
Why link?
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.