This is an archive of the discontinued LLVM Phabricator instance.

On Darwin systems, follow transition from on-disk dyld to shared-cache dyld at process launch
ClosedPublic

Authored by jasonmolenda on Jun 7 2022, 1:10 PM.

Details

Summary

In macOS Ventura et al, the dynamic linker, dyld, has moved into the shared cache image. A process starts with our normal on-disk /usr/lib/dyld, and the first thing it does is execute into an in-memory-only copy of dyld in the shared cache blob. lldb needs to track this transition as we hand off from one dyld to the other, to get notified about newly added binary images in the process.

All of the action happens in DynamicLoaderMacOS::NotifyBreakpointHit(), where we detect two new cases: A new dyld_image_dyld_moved which is called when the launch dyld is about to transition over to the shared cache dyld, and we can get the address of the new notification function out of all_image_infos and set an address breakpoint and we clear out the list of known binary images. And a new mode of dyld_notify_adding where we have no binary images registered (because it was cleared in the previous step), so we know that this is a new shared cache dyld doing its first notification, and treat it appropriately, setting our normal by-name notification breakpoint.

rdar://84222158

Diff Detail

Event Timeline

jasonmolenda created this revision.Jun 7 2022, 1:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2022, 1:10 PM
jasonmolenda requested review of this revision.Jun 7 2022, 1:10 PM
JDevlieghere accepted this revision.Jun 7 2022, 1:11 PM

LGTM. This was also reviewed internally and we've been living on this patch for a while now. Testing is provided by running the existing test suite on macOS Ventura.

This revision is now accepted and ready to land.Jun 7 2022, 1:11 PM