Skip to content

Commit 20573bd

Browse files
committed
[MetadataReader] Adapt to newer Objective-C class_rw_t
Newer Objective-C runtimes implement a size optimization in class_rw_t which requires an additional indirection to get to the class_ro_t pointer. Thanks to Davide for getting to the bottom of this!
1 parent a9b5fe3 commit 20573bd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/swift/Remote/MetadataReader.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,6 +2613,13 @@ class MetadataReader {
26132613
if (!Reader->readInteger(RemoteAddress(dataPtr + OffsetToROPtr), &dataPtr))
26142614
return StoredPointer();
26152615

2616+
// Newer Objective-C runtimes implement a size optimization where the RO
2617+
// field is a tagged union. If the low-bit is set, then the pointer needs
2618+
// to be dereferenced once more to yield the real class_ro_t pointer.
2619+
if (dataPtr & 1)
2620+
if (!Reader->readInteger(RemoteAddress(dataPtr^1), &dataPtr))
2621+
return StoredPointer();
2622+
26162623
return dataPtr;
26172624
}
26182625

0 commit comments

Comments
 (0)