[PATCH] D139572: [lld-macho] Fix bug in reading cpuSubType field.
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 7 12:55:33 PST 2022
oontvoo created this revision.
oontvoo added a reviewer: int3.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
oontvoo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139572
Files:
lld/MachO/InputFiles.cpp
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -231,8 +231,14 @@
return std::nullopt;
}
- if (read32be(&arch[i].cputype) != static_cast<uint32_t>(target->cpuType) ||
- read32be(&arch[i].cpusubtype) != target->cpuSubtype)
+ uint32_t cuptype = read32be(&arch[i].cputype);
+ uint32_t cpusubtype =
+ read32be(&arch[i].cpusubtype) & ~MachO::CPU_SUBTYPE_MASK;
+
+ // FIXME: LD64 has a more complex fallback logic here.
+ // Consider implementing that as well?
+ if (cuptype != static_cast<uint32_t>(target->cpuType) ||
+ cpusubtype != target->cpuSubtype)
continue;
uint32_t offset = read32be(&arch[i].offset);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139572.481025.patch
Type: text/x-patch
Size: 785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221207/ef66611b/attachment.bin>
More information about the llvm-commits
mailing list