@@ -31,6 +31,8 @@ class SwiftObjectFileFormat {
3131 virtual llvm::Optional<llvm::StringRef> getSegmentName () {
3232 return {};
3333 }
34+ // / Predicate to identify if the named section can contain reflection data.
35+ virtual bool sectionContainsReflectionData (llvm::StringRef sectionName) = 0;
3436};
3537
3638// / Responsible for providing the Mach-O reflection section identifiers.
@@ -56,6 +58,15 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
5658 llvm::Optional<llvm::StringRef> getSegmentName () override {
5759 return {" __TEXT" };
5860 }
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+ }
5970};
6071
6172// / Responsible for providing the ELF reflection section identifiers.
@@ -78,6 +89,10 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
7889 }
7990 llvm_unreachable (" Section type not found." );
8091 }
92+
93+ bool sectionContainsReflectionData (llvm::StringRef sectionName) override {
94+ return sectionName.startswith (" swift5_" );
95+ }
8196};
8297
8398// / Responsible for providing the COFF reflection section identifiers
@@ -100,6 +115,10 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
100115 }
101116 llvm_unreachable (" Section not found." );
102117 }
118+
119+ bool sectionContainsReflectionData (llvm::StringRef sectionName) override {
120+ return sectionName.startswith (" .sw5" );
121+ }
103122};
104123} // namespace swift
105124#endif // SWIFT_ABI_OBJECTFILE_H
0 commit comments