@@ -28,6 +28,8 @@ class SwiftObjectFileFormat {
28
28
public:
29
29
virtual ~SwiftObjectFileFormat () {}
30
30
virtual llvm::StringRef getSectionName (ReflectionSectionKind section) = 0;
31
+ // / Predicate to identify if the named section can contain reflection data.
32
+ virtual bool sectionContainsReflectionData (llvm::StringRef sectionName) = 0;
31
33
};
32
34
33
35
// / Responsible for providing the Mach-O reflection section identifiers.
@@ -50,6 +52,15 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
50
52
}
51
53
llvm_unreachable (" Section type not found." );
52
54
}
55
+
56
+ bool sectionContainsReflectionData (llvm::StringRef sectionName) override {
57
+ // For Mach-O, the caller must call this function twice, once with just the
58
+ // section name (ex `__swift5_fieldmd`), and again with the segment
59
+ // qualified section name (ex `__DATA,__const`).
60
+ return sectionName.startswith (" __swift5_" ) ||
61
+ sectionName == " __DATA_CONST,__const" ||
62
+ sectionName == " __DATA,__const" ;
63
+ }
53
64
};
54
65
55
66
// / Responsible for providing the ELF reflection section identifiers.
@@ -72,6 +83,10 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
72
83
}
73
84
llvm_unreachable (" Section type not found." );
74
85
}
86
+
87
+ bool sectionContainsReflectionData (llvm::StringRef sectionName) override {
88
+ return sectionName.startswith (" swift5_" );
89
+ }
75
90
};
76
91
77
92
// / Responsible for providing the COFF reflection section identifiers
@@ -94,6 +109,10 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
94
109
}
95
110
llvm_unreachable (" Section not found." );
96
111
}
112
+
113
+ bool sectionContainsReflectionData (llvm::StringRef sectionName) override {
114
+ return sectionName.startswith (" .sw5" );
115
+ }
97
116
};
98
117
} // namespace swift
99
118
#endif // SWIFT_ABI_OBJECTFILE_H
0 commit comments