Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorTapan Thaker <tapanth@uber.com>2022-05-12 02:29:07 +0300
committerKeith Smiley <keithbsmiley@gmail.com>2022-05-12 03:00:39 +0300
commitd64bad8ff12611a3c79420a895df19c23fe86ae0 (patch)
tree44d4fe5915c8d4fc8a80f43de75a80fa385e024c /lld
parent0950d4060cd916a1d08da657db2513d2ce3e38fa (diff)
[lld/macho] Fixes the -ObjC flag
When checking the segment name for Swift symbols, we should be checking that they start with `__swift` instead of checking for equality Fixes the issue https://github.com/llvm/llvm-project/issues/55355 Reviewed By: #lld-macho, keith, thevinster Differential Revision: https://reviews.llvm.org/D125250
Diffstat (limited to 'lld')
-rw-r--r--lld/MachO/ObjC.cpp2
-rw-r--r--lld/test/MachO/objc.s18
2 files changed, 14 insertions, 6 deletions
diff --git a/lld/MachO/ObjC.cpp b/lld/MachO/ObjC.cpp
index 3c40c5d7181b..fbc129cf6589 100644
--- a/lld/MachO/ObjC.cpp
+++ b/lld/MachO/ObjC.cpp
@@ -40,7 +40,7 @@ template <class LP> static bool objectHasObjCSection(MemoryBufferRef mb) {
if ((segname == segment_names::data &&
sectname == section_names::objcCatList) ||
(segname == segment_names::text &&
- sectname == section_names::swift)) {
+ sectname.startswith(section_names::swift))) {
return true;
}
}
diff --git a/lld/test/MachO/objc.s b/lld/test/MachO/objc.s
index 9cfd5285e0be..ad7e639d99c2 100644
--- a/lld/test/MachO/objc.s
+++ b/lld/test/MachO/objc.s
@@ -5,11 +5,12 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-objc-category.s -o %t/has-objc-category.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-objc-symbol-and-category.s -o %t/has-objc-symbol-and-category.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-swift.s -o %t/has-swift.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-swift-proto.s -o %t/has-swift-proto.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/no-objc.s -o %t/no-objc.o
## Make sure we don't mis-parse a 32-bit file as 64-bit
# RUN: llvm-mc -filetype=obj -triple=armv7-apple-watchos %t/no-objc.s -o %t/wrong-arch.o
-# RUN: llvm-ar rcs %t/libHasSomeObjC.a %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/wrong-arch.o
-# RUN: llvm-ar rcs %t/libHasSomeObjC2.a %t/no-objc.o %t/has-objc-symbol-and-category.o %t/has-swift.o %t/wrong-arch.o
+# RUN: llvm-ar rcs %t/libHasSomeObjC.a %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/has-swift-proto.o %t/wrong-arch.o
+# RUN: llvm-ar rcs %t/libHasSomeObjC2.a %t/no-objc.o %t/has-objc-symbol-and-category.o %t/has-swift.o %t/has-swift-proto.o %t/wrong-arch.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
@@ -19,19 +20,21 @@
# RUN: %lld -lSystem %t/test.o -o %t/test -L%t -lHasSomeObjC2 -ObjC
# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=OBJC
-# RUN: %lld -lSystem %t/test.o -o %t/test --start-lib %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/wrong-arch.o --end-lib -ObjC
+# RUN: %lld -lSystem %t/test.o -o %t/test --start-lib %t/no-objc.o %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/has-swift-proto.o %t/wrong-arch.o --end-lib -ObjC
# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=OBJC
# OBJC: Sections:
# OBJC-NEXT: Idx Name Size VMA Type
# OBJC-NEXT: 0 __text {{.*}} TEXT
# OBJC-NEXT: 1 __swift {{.*}} DATA
-# OBJC-NEXT: 2 __objc_catlist {{.*}} DATA
-# OBJC-NEXT: 3 has_objc_symbol {{.*}} DATA
+# OBJC-NEXT: 2 __swift5_fieldmd{{.*}} DATA
+# OBJC-NEXT: 3 __objc_catlist {{.*}} DATA
+# OBJC-NEXT: 4 has_objc_symbol {{.*}} DATA
# OBJC-EMPTY:
# OBJC-NEXT: SYMBOL TABLE:
# OBJC-DAG: g F __TEXT,__text _main
# OBJC-DAG: g F __TEXT,__text _OBJC_CLASS_$_MyObject
+# OBJC-DAG: g O __TEXT,__swift5_fieldmd $s7somelib4Blah_pMF
# RUN: %lld -lSystem %t/test.o -o %t/test -L%t -lHasSomeObjC
# RUN: llvm-objdump --section-headers --syms %t/test | FileCheck %s --check-prefix=NO-OBJC
@@ -93,6 +96,11 @@ _has_dup:
.section __TEXT,__swift
.quad 0x1234
+#--- has-swift-proto.s
+.section __TEXT,__swift5_fieldmd
+.globl $s7somelib4Blah_pMF
+$s7somelib4Blah_pMF:
+
#--- no-objc.s
## This archive member should not be pulled in by -ObjC since it does not
## contain any ObjC-related data.