@@ -31,6 +31,8 @@ class SwiftObjectFileFormat {
31
31
virtual llvm::Optional<llvm::StringRef> getSegmentName () {
32
32
return {};
33
33
}
34
+ // / Predicate to identify if the named section can contain reflection data.
35
+ virtual bool sectionContainsReflectionData (llvm::StringRef sectionName) = 0;
34
36
};
35
37
36
38
// / Responsible for providing the Mach-O reflection section identifiers.
@@ -56,6 +58,15 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
56
58
llvm::Optional<llvm::StringRef> getSegmentName () override {
57
59
return {" __TEXT" };
58
60
}
61
+
62
+ bool sectionContainsReflectionData (llvm::StringRef sectionName) override {
63
+ // For Mach-O, the caller must call this function twice, once with just the
64
+ // section name (ex `__swift5_fieldmd`), and again with the segment
65
+ // qualified section name (ex `__DATA,__const`).
66
+ return sectionName.startswith (" __swift5_" ) ||
67
+ sectionName == " __DATA_CONST,__const" ||
68
+ sectionName == " __DATA,__const" ;
69
+ }
59
70
};
60
71
61
72
// / Responsible for providing the ELF reflection section identifiers.
@@ -78,6 +89,10 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
78
89
}
79
90
llvm_unreachable (" Section type not found." );
80
91
}
92
+
93
+ bool sectionContainsReflectionData (llvm::StringRef sectionName) override {
94
+ return sectionName.startswith (" swift5_" );
95
+ }
81
96
};
82
97
83
98
// / Responsible for providing the COFF reflection section identifiers
@@ -100,6 +115,10 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
100
115
}
101
116
llvm_unreachable (" Section not found." );
102
117
}
118
+
119
+ bool sectionContainsReflectionData (llvm::StringRef sectionName) override {
120
+ return sectionName.startswith (" .sw5" );
121
+ }
103
122
};
104
123
} // namespace swift
105
124
#endif // SWIFT_ABI_OBJECTFILE_H
0 commit comments