[lld] 66692c8 - Revert "[lld-macho] Fix bug in reading cpuSubType field."
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 9 05:32:39 PST 2022
Author: Nico Weber
Date: 2022-12-09T08:32:28-05:00
New Revision: 66692c822aee47baa2cb71f92090d58a8dc01116
URL: https://github.com/llvm/llvm-project/commit/66692c822aee47baa2cb71f92090d58a8dc01116
DIFF: https://github.com/llvm/llvm-project/commit/66692c822aee47baa2cb71f92090d58a8dc01116.diff
LOG: Revert "[lld-macho] Fix bug in reading cpuSubType field."
This reverts commit e54cfa48d2d56e025fee9e239f8ba4fdec5520c8.
Test fails at least on macOS: https://reviews.llvm.org/D139572#3984162
Added:
Modified:
lld/MachO/InputFiles.cpp
lld/test/MachO/fat-arch.s
Removed:
################################################################################
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index b7a8c91250ded..7fb5594aa97cf 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -231,14 +231,8 @@ std::optional<MemoryBufferRef> macho::readFile(StringRef path) {
return std::nullopt;
}
- uint32_t cpuType = 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 (cpuType != static_cast<uint32_t>(target->cpuType) ||
- cpuSubtype != target->cpuSubtype)
+ if (read32be(&arch[i].cputype) != static_cast<uint32_t>(target->cpuType) ||
+ read32be(&arch[i].cpusubtype) != target->cpuSubtype)
continue;
uint32_t offset = read32be(&arch[i].offset);
diff --git a/lld/test/MachO/fat-arch.s b/lld/test/MachO/fat-arch.s
index fd03248b2ee09..33928b1049be1 100644
--- a/lld/test/MachO/fat-arch.s
+++ b/lld/test/MachO/fat-arch.s
@@ -1,30 +1,16 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=i386-apple-darwin %s -o %t.i386.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.x86_64.o
-# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos11.0 %s -o %t.arm64.o
-
# RUN: llvm-lipo %t.i386.o %t.x86_64.o -create -o %t.fat.o
# RUN: %lld -o /dev/null %t.fat.o
+
# RUN: llvm-lipo %t.i386.o -create -o %t.noarch.o
# RUN: not %lld -o /dev/null %t.noarch.o 2>&1 | \
# RUN: FileCheck %s -DFILE=%t.noarch.o
# CHECK: error: unable to find matching architecture in [[FILE]]
-## Validates that we read the cpu-subtype correctly from a fat exec.
-# RUN: %lld -o %t.x86_64.out %t.x86_64.o
-# RUN: %lld -arch arm64 -o %t.arm64.out %t.arm64.o
-# RUN: llvm-lipo %t.x86_64.out %t.arm64.out -create -o %t.fat.exec.out
-
-# RUN: llvm-otool -h %t.fat.exec.out | FileCheck %s --check-prefix=PRE-COND
-# PRE-COND: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
-# PRE-COND-NEXT: 0xfeedfacf 16777223 3 0x80 2 13 648 0x00200085
-
-# RUN: %lld %t.x86_64.o -bundle_loader %t.fat.exec.out -bundle -o %t.fat.bundle
-# RUN: llvm-otool -h %t.fat.bundle | FileCheck %s --check-prefix=POST-COND
-# POST-COND: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
-# POST-COND-NEXT: 0xfeedfacf 16777223 3 0x00 8 10 520 0x00000085
-
.text
.global _main
_main:
+ mov $0, %eax
ret
More information about the llvm-commits
mailing list