This is an archive of the discontinued LLVM Phabricator instance.

[lld-macho] Support linking against stub dylibs
ClosedPublic

Authored by int3 on Oct 7 2020, 2:58 PM.

Details

Reviewers
smeenai
Group Reviewers
Restricted Project
Commits
rG2e8e1bdb8939: [lld-macho] Support linking against stub dylibs
Summary

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.

Diff Detail

Event Timeline

int3 created this revision.Oct 7 2020, 2:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 7 2020, 2:58 PM
int3 requested review of this revision.Oct 7 2020, 2:58 PM
int3 added a reviewer: Restricted Project.Oct 7 2020, 2:58 PM
int3 edited the summary of this revision. (Show Details)Oct 13 2020, 10:28 PM
smeenai accepted this revision.Nov 9 2020, 6:15 PM
smeenai added a subscriber: smeenai.

LGTM

lld/test/MachO/dylib-stub.yaml
26

Any reason to prefer a universal binary with a single architecture to just a regular binary?

This revision is now accepted and ready to land.Nov 9 2020, 6:15 PM
int3 added inline comments.Nov 9 2020, 9:05 PM
lld/test/MachO/dylib-stub.yaml
26

The stub dylibs bundled with XCode all seem to be contained within a universal binary (probably generated by some non-public version of lipo), so I figured this would be a more representative test case

This revision was landed with ongoing or failed builds.Nov 10 2020, 12:19 PM
This revision was automatically updated to reflect the committed changes.