Skip to content

Commit 09c5aab

Browse files
committed
Revert "Reland 2nd attempt: [lld-macho] Fix bug in reading cpuSubType field."
This reverts commit b08acee. Still breaks tests, see https://reviews.llvm.org/D139572#4003191
1 parent 5b1592b commit 09c5aab

File tree

2 files changed

+5
-33
lines changed

2 files changed

+5
-33
lines changed

lld/MachO/InputFiles.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,8 @@ std::optional<MemoryBufferRef> macho::readFile(StringRef path) {
231231
return std::nullopt;
232232
}
233233

234-
uint32_t cpuType = read32be(&arch[i].cputype);
235-
uint32_t cpuSubtype =
236-
read32be(&arch[i].cpusubtype) & ~MachO::CPU_SUBTYPE_MASK;
237-
238-
// FIXME: LD64 has a more complex fallback logic here.
239-
// Consider implementing that as well?
240-
if (cpuType != static_cast<uint32_t>(target->cpuType) ||
241-
cpuSubtype != target->cpuSubtype)
234+
if (read32be(&arch[i].cputype) != static_cast<uint32_t>(target->cpuType) ||
235+
read32be(&arch[i].cpusubtype) != target->cpuSubtype)
242236
continue;
243237

244238
uint32_t offset = read32be(&arch[i].offset);

lld/test/MachO/fat-arch.s

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
1-
# REQUIRES: x86,aarch64
2-
## FIXME: The tests doesn't run on windows right now because of llvm-mc (can't produce triple=arm64-apple-macos11.0)
3-
# UNSUPPORTED: system-windows
4-
1+
# REQUIRES: x86
52
# RUN: llvm-mc -filetype=obj -triple=i386-apple-darwin %s -o %t.i386.o
63
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.x86_64.o
7-
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %s -o %t.arm64.o
8-
94
# RUN: llvm-lipo %t.i386.o %t.x86_64.o -create -o %t.fat.o
105
# RUN: %lld -o /dev/null %t.fat.o
6+
117
# RUN: llvm-lipo %t.i386.o -create -o %t.noarch.o
128
# RUN: not %lld -o /dev/null %t.noarch.o 2>&1 | \
139
# RUN: FileCheck %s -DFILE=%t.noarch.o
1410
# CHECK: error: unable to find matching architecture in [[FILE]]
1511

16-
## Validates that we read the cpu-subtype correctly from a fat exec.
17-
# RUN: %lld -o %t.x86_64.out %t.x86_64.o
18-
# RUN: %lld -arch arm64 -o %t.arm64.out %t.arm64.o
19-
# RUN: llvm-lipo %t.x86_64.out %t.arm64.out -create -o %t.fat.exec.out
20-
# RUN: %lld %t.x86_64.o -bundle_loader %t.fat.exec.out -bundle -o %t.fat.bundle
21-
22-
# RUN: llvm-otool -h %t.fat.bundle -f %t.fat.exec.out | FileCheck %s --check-prefix=CPU-SUB
23-
# CPU-SUB: Fat headers
24-
# CPU-SUB: nfat_arch 2
25-
# CPU-SUB: architecture 0
26-
# CPU-SUB-NEXT: cputype 16777223
27-
# CPU-SUB-NEXT: cpusubtype 3
28-
# CPU-SUB: architecture 1
29-
# CPU-SUB-NEXT: cputype 16777228
30-
# CPU-SUB-NEXT: cpusubtype 0
31-
32-
# CPU-SUB: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
33-
# CPU-SUB-NEXT: 0xfeedfacf 16777223 3 0x{{.+}} {{.+}} {{.+}} {{.+}} {{.+}}
34-
3512
.text
3613
.global _main
3714
_main:
15+
mov $0, %eax
3816
ret

0 commit comments

Comments
 (0)