-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add extraction of protocol conformance descriptor info, as read from an object file image, to TypeRefBuilder
.
#41027
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
Conversation
…ate CMake target: StaticMirror This target will then be used to have a broader set of tools for reading metadata from object files.
…om an object file image, to `TypeRefBuilder`.
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.
Some small comments, but this is looking very nice.
…l descriptor target in an conformance descriptor. Previously, the code assumed that such an indirect target will always point to an external symbol pointer, but it can also be an absolute pointer to an in-image protocol descriptor.
@swift-ci please test |
…up-to the 16-byte section name limit, instead of the queried name length.
Build failed |
@swift-ci please test |
Build failed |
TypeRefBuilder was originally intended to work even without a remote process. Perhaps ReflectionContext would be a better place for something that reads sections? |
Build failed |
@swift-ci please test |
Build failed |
db5d4f8
to
dcef67f
Compare
@swift-ci please test |
I agree that |
… their parent contexts and extracting their names
dcef67f
to
cd6d8f9
Compare
@swift-ci please test |
Build failed |
@swift-ci please test macOS platform |
Build failed |
…ance infos. Collect the mapping of unmangled-to-mangled names from the read out `Fields` section reflection infos and use that to identify the mangled name of a conforming type of a given protocol conformance.
@swift-ci please test |
@swift-ci please test Windows platform |
include/swift/ABI/Metadata.h
Outdated
template<unsigned PointerSize> | ||
using ExternalTypeContextDescriptor | ||
#if SWIFT_OBJC_INTEROP | ||
= TargetTypeContextDescriptor<External<WithObjCInterop<RuntimeTarget<PointerSize>>>>; |
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.
This still isn't quite right, since we want the client to be able to specify whether the target has ObjC interop separately from how the client builds. I believe the right approach here would be to modify ProtocolConformanceDescriptorReader
to be templated on ObjC interop as well as pointer size, and do the WithObjCInterop
/NoObjCInterop
logic there. @adrian-prantl Does that sound right?
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.
Ah, makes perfect sense, thank you.
Updated with the type aliases templated on ObjCInteropKind
to allow clients to decide on this separately from how this code is built.
…f `conformanceReader`, separately from how the client builds.
d9b3b37
to
5d17074
Compare
@swift-ci please test |
🎉 |
This PR adds the ability to read protocol conformance descriptors from object files, in order to get at the type/protocol information.
static_mirror
namespace:Code moved from
swift-reflection-dump.cpp
intoStaticMirror/ObjectFileContext.cpp
andStaticMirror/ObjectFileContext.h
, without changes.ObjectFile.h
has been taught about the__swift5_proto
sections in relevant object file formats.Metadata.h
now also provides type aliases forExternal
versions of Conformance and Protocol descriptors, as opposed toInProcess
ones.TypeRefBuilder.h
now provides API to query and dump conformance information -dumpConformanceSection
, which is templated on pointer size, since we may be reading this info from binaries built for 32-bit or 64-bit platforms.