Skip to content

Draft: rts/linker: Split up object resolution and initialization

Ben Gamari requested to merge wip/T21253 into master

Previously the RTS linker would call initializers during the "resolve" phase of linking. However, this is problematic in the case of cyclic dependencies between objects. In particular, consider the case where we have a situation where a static library contains a set of recursive objects:

  • object A has depends upon symbols in object B
  • object B has an initializer that depends upon object A
  • we try to load object A

The linker would previously:

  1. start resolving object A
  2. encounter the reference to object B, loading it resolve object B
  3. run object B's initializer
  4. the initializer will attempt to call into object A, which hasn't been fully resolved (and therefore protected)

Fix this by moving constructor execution to a new linking phase, which follows resolution.

Fix #21253 (closed).

Edited by Ben Gamari

Merge request reports