[lld/mac] Add some support for dynamic lookup symbols, and implement -U
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. Differential Revision: https://reviews.llvm.org/D97521
Loading
Please register or sign in to comment