diff options
| author | Mark Rowe <mark@vector35.com> | 2025-07-04 23:44:30 -0700 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2025-07-07 18:57:44 -0700 |
| commit | 9aa5359a82e3a9ecf27355c3dba1c2453897db68 (patch) | |
| tree | 05f7b3a8f699dfb8c276160c793728db9d110fac /objectivec/objc.cpp | |
| parent | 402cf087cfcf69e0c38b027d2b8488d5cdcbed76 (diff) | |
[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.
Diffstat (limited to 'objectivec/objc.cpp')
| -rw-r--r-- | objectivec/objc.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/objectivec/objc.cpp b/objectivec/objc.cpp index 4c574600..e4b21ff6 100644 --- a/objectivec/objc.cpp +++ b/objectivec/objc.cpp @@ -838,9 +838,14 @@ void ObjCProcessor::LoadProtocols(ObjCReader* reader, Ref<Section> listSection) void ObjCProcessor::GetRelativeMethod(ObjCReader* reader, method_t& meth) { - meth.name = reader->GetOffset() + reader->ReadS32(); - meth.types = reader->GetOffset() + reader->ReadS32(); - meth.imp = reader->GetOffset() + reader->ReadS32(); + uint64_t offset = reader->GetOffset(); + meth.name = offset + reader->ReadS32(); + + offset += sizeof(int32_t); + meth.types = offset + reader->ReadS32(); + + offset += sizeof(int32_t); + meth.imp = offset + reader->ReadS32(); } void ObjCProcessor::ReadListOfMethodLists(ObjCReader* reader, ClassBase& cls, std::string_view name, view_ptr_t start) |
