From 9aa5359a82e3a9ecf27355c3dba1c2453897db68 Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Fri, 4 Jul 2025 23:44:30 -0700 Subject: [ObjC] Fix handling of relative method selectors with MSVC The order that the operands to `+` are evaluated in is unspecified. Clang happens to evaluate them left to right and gives the expected answer. MSVC picks the opposite order and so the value it computes is off by 4. This was resulting in missing method names when arm64 binaries containing Objective-C are analyzed on Windows. --- view/sharedcache/core/ObjC.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'view/sharedcache/core/ObjC.cpp') diff --git a/view/sharedcache/core/ObjC.cpp b/view/sharedcache/core/ObjC.cpp index dc3012a5..b6de8ba6 100644 --- a/view/sharedcache/core/ObjC.cpp +++ b/view/sharedcache/core/ObjC.cpp @@ -97,8 +97,12 @@ void SharedCacheObjCProcessor::GetRelativeMethod(ObjCReader* reader, method_t& m if (m_customRelativeMethodSelectorBase.has_value()) { meth.name = m_customRelativeMethodSelectorBase.value() + reader->ReadS32(); - meth.types = reader->GetOffset() + reader->ReadS32(); - meth.imp = reader->GetOffset() + reader->ReadS32(); + + uint64_t offset = reader->GetOffset(); + meth.types = offset + reader->ReadS32(); + + offset += sizeof(int32_t); + meth.imp = offset + reader->ReadS32(); } else { -- cgit v1.3.1