Dynamic lookup symbols are symbols that work like dynamic symbols
in ELF: They're not bound to a dylib like normal Mach-O twolevel lookup
symbols, but they live in a global pool and dyld resolves them against
exported symbols from all loaded dylibs.
This adds support for dynamical lookup symbols to lld/mac. They are
represented as DylibSymbols with file set to nullptr.
This also uses this support to implement the -U flag, which makes
a specific symbol that's undefined at the end of the link a
dynamic lookup symbol.
For -U, it'd be sufficient to just to a pass over remaining undefined symbols
at the end of the link and to replace them with dynamic lookup symbols then.
But I'd like to use this code to implement flat_namespace too, and that will
require real support for resolving dynamic lookup symbols in SymbolTable. So
this patch adds this now already.
While writing tests for this, I noticed that we didn't set N_WEAK_DEF in the
symbol table for DylibSymbols, so this fixes that too.
In addition to -flat_namespace, this will also be useful for implementing
-undefined dynamic_lookup, and, with -flat_namespace, -undefined warning
and -undefined suppress – but for these, the pass at the end would've sufficed too.
This isn't 100% done, there are a few XXXs left, but I'm out of evening, and what's
left is pretty basic. So I'm sending it out now for better timezone overlap :)
that would be BIND_SPECIAL_DYLIB_FLAT_LOOKUP