[lld-macho] Support linking against stub dylibs
authorJez Ng <jezng@fb.com>
Wed, 7 Oct 2020 21:50:42 +0000 (14:50 -0700)
committerJez Ng <jezng@fb.com>
Tue, 10 Nov 2020 20:19:27 +0000 (12:19 -0800)
commit2e8e1bdb89392f8bbe1c3886b1f8da8746659bb2
tree1f1617c1117c3c66805d27f07568f27be0636587
parent703038b35a864d06e1926237c1568a430417b0b4
[lld-macho] Support linking against stub dylibs

Stub dylibs differ from "real" dylibs in that they lack any content in
their sections. What they do have are export tries and symbol tables,
which means we can still link against them. I am unclear how to
properly create these stub dylibs; XCode 11.3's `lipo` is able to create
stub dylibs, but those lack LC_ID_DYLIB load commands and are considered
invalid by most tooling. Newer versions of `lipo` aren't able to create
stub dylibs at all.  However, recent SDKs in XCode still come with valid
stub dylibs, so it still seems worthwhile to support them. The YAML in
this diff's test was generated by taking a non-stub dylib and editing
the appropriate fields.

Reviewed By: #lld-macho, smeenai

Differential Revision: https://reviews.llvm.org/D89012
lld/MachO/Driver.cpp
lld/test/MachO/dylib-stub.yaml [new file with mode: 0644]