Skip to content

Commit e2be9a3

Browse files
committed
[ABI] Add predicate to identify sections containing reflection data
1 parent b6a4923 commit e2be9a3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

include/swift/ABI/ObjectFile.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,20 @@ class SwiftObjectFileFormat {
3131
virtual llvm::Optional<llvm::StringRef> getSegmentName() {
3232
return {};
3333
}
34+
virtual bool sectionContainsReflectionData(llvm::StringRef sectionName) {
35+
return getSectionName(fieldmd) == sectionName ||
36+
getSectionName(assocty) == sectionName ||
37+
getSectionName(builtin) == sectionName ||
38+
getSectionName(capture) == sectionName ||
39+
getSectionName(typeref) == sectionName ||
40+
getSectionName(reflstr) == sectionName;
41+
}
3442
};
3543

3644
/// Responsible for providing the Mach-O reflection section identifiers.
3745
class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
46+
using super = SwiftObjectFileFormat;
47+
3848
public:
3949
llvm::StringRef getSectionName(ReflectionSectionKind section) override {
4050
switch (section) {
@@ -56,6 +66,11 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
5666
llvm::Optional<llvm::StringRef> getSegmentName() override {
5767
return {"__TEXT"};
5868
}
69+
70+
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
71+
return super::sectionContainsReflectionData(sectionName) ||
72+
sectionName == "__DATA_CONST,__const";
73+
}
5974
};
6075

6176
/// Responsible for providing the ELF reflection section identifiers.

0 commit comments

Comments
 (0)