-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ABI] Add predicate to identify sections containing reflection data #41066
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
[ABI] Add predicate to identify sections containing reflection data #41066
Conversation
23dac14
to
1d5b4be
Compare
@swift-ci smoke test |
@@ -56,6 +65,12 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat { | |||
llvm::Optional<llvm::StringRef> getSegmentName() override { | |||
return {"__TEXT"}; | |||
} | |||
|
|||
bool sectionContainsReflectionData(llvm::StringRef sectionName) override { | |||
return sectionName.startswith("__swift5_") || |
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 looks sketchy: this line compares a section-name-only string and the next line a segment,section string. Does this actually work?
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.e., why isn't this __TEXT,_swift5_
?
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.
The caller is implemented to call first with the section name (ie __swift5_fieldmd
), and then secondly call with the segment qualified name (ie __DATA,__const
).
Here's that implementation: https://github.com/apple/llvm-project/pull/3848/files#diff-1c2c090c5ff772b9b304dbdd4cf45803478f4f33d11d042817fea7358e0cc96b
You'd prefer mach-o binaries call this once, and pass in a segment qualified name?
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.
Thanks, that makes sense! In light of the dsymutil patch that copies reflection metadata from __TEXT to __DWARF, this implementation is actually preferred.
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.
good to know!
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 added a comment to explain how the caller should call this function.
fwiw mach-o sections have a flags field. Ideally we wouldn't check names, and instead check for a flag. But that's not something that can independently implement. |
@swift-ci smoke test |
@swift-ci smoke test |
…ctions-containing-reflection-data [ABI] Add predicate to identify sections containing reflection data (cherry picked from commit 56a614a)
ABI/ObjectFile.h
abstracts reflection section names across platforms (binary file formats). However, some non-root reflection data is stored in general purpose sections, for example on Darwin type metadata can be placed in__DATA_CONST,__const
, such as data that has loader fixups (bindings or relocations).This change introduces a new predicate function to check if a section name could contain reflection data. These are the swift specific reflections sections, as well as general purpose sections that vary by platform. This initial change adds
__DATA_CONST,__const
for Mach-O files.This will be used by overrides of
MemoryReader::resolvePointer
, to know whether an address is from a reflection section or not. If the section doesn't contain reflection data, thenresolvePointer
should not return a symbol.