Is it necessary to lock the entire session in order to resolve relocations or would it be sufficient to:
(1) Lock the collection of related dylibs.
(2) Visit each dylib individually with a lock for only this one instance.
The change here adds SearchOrderMutex and visitInSearchOrder() to achieve (1).
It does not implement (2), but instead just assumes that the individual dylibs remain unchanged during visitation. I started drafting (2), but it quickly became big and I stopped to avoid wasting time here.
One more note on the current approach:
IIUC ExecutionSessionBase::lookup() either resolves all symbols in all dylibs or returns an error. Wouldn't this mean that a single broken dylib could cause everything to fail?
Is there a fundamental reason for this?
Otherwise, for (2) it would be easy to return both, errors and symbols for each dylib, and degrade errors to warnings if all requested symbols could be resolved.
With your ErrorList implementation we would be perfectly prepared for it.