[ORC-RT] Fix objc selector corruption

We were writing a pointer to a selector string into the contents of a
string instead of overwriting the pointer to the string, leading to
corruption. This was causing non-deterministic failures of the
'trivial-objc-methods' test case.

Differential Revision: https://reviews.llvm.org/D112671
This commit is contained in:
Ben Langmuir 2021-10-27 15:39:51 -07:00
parent d378a0febc
commit beb3d48262
1 changed files with 2 additions and 2 deletions

View File

@ -112,10 +112,10 @@ Error registerObjCSelectors(
if (auto Err = validatePointerSectionExtent("__objc_selrefs", ObjCSelRefs))
return Err;
for (uintptr_t SelEntry : ObjCSelRefs.toSpan<uintptr_t>()) {
for (uintptr_t &SelEntry : ObjCSelRefs.toSpan<uintptr_t>()) {
const char *SelName = reinterpret_cast<const char *>(SelEntry);
auto Sel = sel_registerName(SelName);
*reinterpret_cast<SEL *>(SelEntry) = Sel;
*reinterpret_cast<SEL *>(&SelEntry) = Sel;
}
}