[The World of Linkers—Lab 03] Who Owns the Name? Global Symbol Resolution
Select each global name's definition, then bind actual references to that identity. Theory 03 explains strong/weak/COMMON selection and local-name isolation.
Starting point: class3 code and tests, in the private repository; access is required. Each files element is one object's validated symbol table, retaining its original order and null record. Use class2 records to implement two interfaces in the class3 crate library.
Implementation tasks
| Task | Interface | Required outcome |
|---|---|---|
| C3.1 | build_globals | Validate symbols and select global definitions in input order, returning byte-keyed Globals |
| C3.2 | bind | Resolve one SymbolId to a Selection, zero for an unresolved WEAK, or a precise error |
The class3 README specifies the matrix, types, and diagnostic rules, with a two-table example showing Globals and bind results. SymbolId is a file ordinal plus a symbol-table index. Selection retains input identity rather than an address.
LOCAL names do not enter global competition. Strong definitions beat COMMON, which beats weak definitions. Two strong definitions conflict; weak ties keep the first. COMMON size and alignment take independent maxima while retaining the first identity; layout allocates storage later. Validate each symbol before selection even when a strong definition already exists.
Building the map allows undefined names. A required unresolved reference fails when bind is called for that use. bind must use the same unmodified tables as build_globals. Consult the handout for supported bindings and static-selection limits; dynamic interposition is not implemented.
A minimal matrix is: read COMMON(size=8, align=8), then a WEAK definition, and keep COMMON; read a GLOBAL section definition next, and replace COMMON. If two GLOBAL definitions arrive, the second immediately produces a duplicate-definition error. Globals still stores “input-file number plus symbol-table index,” not a virtual address; only after layout can bind participate in address calculation.
Acceptance and what it establishes
From the cloned repository root on native x86-64 Linux:
cargo test --locked -p class0 -p class1 -p class2 -p class3cargo test --locked -p class0 -p class1 -p class2 -p class3 --releasepython3 scripts/grade.py class3Contract tests cover strong/weak competition, first-conflict order, local isolation, independent COMMON maxima, use-time errors, byte names, and malformed metadata. Permuting inputs preserves strong-over-weak selection but may change a weak tie; determinism does not mean identical selection under every permutation.
The native test assembles caller and provider separately, parses them through class1/class2, and binds the caller's relocation to the provider identity. It validates the resolution pipeline, not layout or execution of linked output.