Skip to content

[runtime] Backwards-deployment support for class_getImageName #18060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jrose-apple
Copy link
Contributor

Follow-up to #17910. On Apple OSs that don't have the new Objective-C runtime function objc_setHook_getImageName, override the system definition of class_getImageName by literally rewriting symbol tables at run time.

Yes, you read that correctly.

The low-level part of this patch was written by @gparker42, then simplified and tweaked by me to fit the Swift coding style. Don't try this at home; it comes with all sorts of caveats and won't actually work on this year's iOS. (Fortunately we don't need it there, because that will have the new ObjC entry point.)

The rest of the patch is pretty straightforward: the replacement implementation calls the code that supports Swift objects (the same code we use on newer OSs), which then chains back to the original system implementation of class_getImageName. May we never have to touch this again.

SR-1917 / rdar://problem/41535552

@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - c4f6f3187f69e62a87bd625af26082bf669b97bb

@jrose-apple jrose-apple force-pushed the and-you-get-a-class_getImageName branch from c4f6f31 to 271cc0d Compare July 19, 2018 01:09
@jrose-apple
Copy link
Contributor Author

Full macOS tests here. I just failed to account for the new files getting compiled on Linux too.

@swift-ci Please smoke test

Follow-up to 3ed3774. On Apple OSs that don't have the new
Objective-C runtime function 'objc_setHook_getImageName', override the
system definition of 'class_getImageName' by literally rewriting
symbol tables at run time.

Yes, you read that correctly.

The low-level part of this patch was written by Greg Parker, then
simplified and tweaked by me to fit the Swift coding style. Don't try
this at home; it comes with all sorts of caveats and won't actually
work on this year's iOS. (Fortunately we don't need it there, because
that will have the new ObjC entry point.)

The rest of the patch is pretty straightforward: the replacement
implementation calls the code that supports Swift objects (the same
code we use on newer OSs), which then chains back to the original
system implementation of class_getImageName. May we never have to
touch this again.

rdar://problem/41535552
Reverts the effects of df974b2, but keeps the refactoring and nicer
tests.
@jrose-apple jrose-apple force-pushed the and-you-get-a-class_getImageName branch from 271cc0d to e9f71fd Compare July 19, 2018 01:28
@jrose-apple
Copy link
Contributor Author

@swift-ci Please smoke test

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve this message.

@jrose-apple jrose-apple merged commit 6f42fcc into swiftlang:master Jul 19, 2018
@jrose-apple jrose-apple deleted the and-you-get-a-class_getImageName branch July 19, 2018 15:36
jrose-apple added a commit to jrose-apple/swift that referenced this pull request Jul 19, 2018
…ss_getImageName

[runtime] Backwards-deployment support for class_getImageName

https://bugs.swift.org/browse/SR-1917
rdar://problem/41535552
(cherry picked from commit 6f42fcc)
jrose-apple added a commit that referenced this pull request Jul 19, 2018
Merge pull request #18060 from jrose-apple/and-you-get-a-class_getImageName

https://bugs.swift.org/browse/SR-1917
rdar://problem/41535552
(cherry picked from commit 6f42fcc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants