Skip to content

Commit f432f1b

Browse files
committed
Fix section name lookup in findMachOSectionByName to do comparison up-to the 16-byte section name limit, instead of the queried name length.
1 parent 59d1960 commit f432f1b

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -219,24 +219,9 @@ class ReflectionContext
219219
for (unsigned I = 0; I < NumSect; ++I) {
220220
auto S = reinterpret_cast<typename T::Section *>(
221221
SectionsBuf + (I * sizeof(typename T::Section)));
222-
if (strncmp(S->sectname, Name.data(), strlen(Name.data())) != 0)
222+
if (strncmp(S->sectname, Name.data(), sizeof(S->sectname)) != 0)
223223
continue;
224224

225-
// The above check verifies that `Name` is a prefix to the examined
226-
// section name, to allow for matching of sections with a suffix
227-
// like `_TEXT`, etc.
228-
// "__swift5_proto" section name is a substring of "__swift5_protos",
229-
// Ensure we don't return the latter when looking for the former.
230-
SwiftObjectFileFormatMachO ObjectFileFormat;
231-
if (Name.data() ==
232-
ObjectFileFormat.getSectionName(ReflectionSectionKind::conform)) {
233-
auto protocolsSectionName =
234-
ObjectFileFormat.getSectionName(ReflectionSectionKind::protocs);
235-
if (strncmp(S->sectname, protocolsSectionName.data(),
236-
strlen(protocolsSectionName.data())) == 0)
237-
continue;
238-
}
239-
240225
auto RemoteSecStart = S->addr + Slide;
241226
auto LocalSectBuf =
242227
this->getReader().readBytes(RemoteAddress(RemoteSecStart), S->size);

0 commit comments

Comments
 (0)