-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add exported symbol on non-Apple platforms to enumerate MetadataSection structures at runtime. #41621
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
Add exported symbol on non-Apple platforms to enumerate MetadataSection structures at runtime. #41621
Conversation
@swift-ci please smoke test |
@swift-ci please smoke test |
2f42ef5
to
b7862c9
Compare
@swift-ci please test |
This is tremendously useful, thank you! |
f8428e0
to
c1396c5
Compare
Changed the function from
|
@swift-ci please test |
c1396c5
to
4a43a08
Compare
@swift-ci please smoke test |
@swift-ci please smoke test linux |
@swift-ci please test |
1 similar comment
@swift-ci please test |
4df3d18
to
8648091
Compare
@swift-ci please test |
8648091
to
49c3750
Compare
@swift-ci please test |
49c3750
to
20b2166
Compare
@swift-ci please test |
20b2166
to
6352e14
Compare
@swift-ci please test |
6352e14
to
845904d
Compare
@swift-ci please test |
845904d
to
cce4d06
Compare
@swift-ci please smoke test |
cce4d06
to
ec4c8e2
Compare
@swift-ci please smoke test |
ec4c8e2
to
1dc8b69
Compare
@swift-ci please test |
ff1806b
to
0a87e61
Compare
@swift-ci please test |
0a87e61
to
bf1a309
Compare
Boy, |
@swift-ci please test |
bf1a309
to
a938de3
Compare
@swift-ci please test |
@swift-ci please test macOS |
b8019a7
to
86e7107
Compare
@swift-ci please test |
65ec9a6
to
beb0ef0
Compare
@swift-ci please test |
beb0ef0
to
a93a760
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that we can deal with the memory allocation paths in a follow up (but we really should - that can be a difficult thing to isolate later).
…on structures at runtime.
a93a760
to
8451822
Compare
@swift-ci please smoke test |
Add exported symbol on non-Apple platforms to enumerate MetadataSection structures at runtime.
On Apple platforms, it is possible to enumerate the loaded metadata section structures of a process using dyld API. This is useful when, for example, looking up types that conform to a specific protocol (as might be done by e.g. swift-argument-parser.)
On non-Apple platforms, it is not possible to look up these structures because their addresses are not exported. The structures are instead statically declared and, when an image is loaded, are ingested by
swift_addNewDSOImage()
(by way of static constructors emitted during compilation.)The end result is that there is no way, even when leveraging deep knowledge of the Swift ABI, to examine loaded Swift metadata on non-Apple platforms. This PR adds an exported function to the runtime named
swift_copyAllMetadataSections()
. This function returns a C array ofswift::MetadataSections
structures. Client code can then call this function and inspect the resulting structures as needed.