Skip to content

Commit 04c52eb

Browse files
author
Alex B
committed
Address Feedback #5
1 parent 4ea30b4 commit 04c52eb

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

lld/MachO/ObjC.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ class ObjcCategoryMerger {
489489
InfoCategoryWriter infoCategoryWriter;
490490
std::vector<ConcatInputSection *> &allInputSections;
491491
// Map of base class Symbol to list of InfoInputCategory's for it
492-
std::map<const Symbol *, std::vector<InfoInputCategory>> categoryMap;
492+
DenseMap<const Symbol *, std::vector<InfoInputCategory>> categoryMap;
493493

494494
// Normally, the binary data comes from the input files, but since we're
495495
// generating binary data ourselves, we use the below array to store it in.
@@ -1064,6 +1064,7 @@ void ObjcCategoryMerger::collectAndValidateCategoriesData() {
10641064
"Failed to get a valid cateogry at __objc_catlit offset");
10651065

10661066
// We only support ObjC categories (no swift + @objc)
1067+
// TODO: Support swift + @objc categories also
10671068
if (!categorySym->getName().starts_with(objc::symbol_names::category))
10681069
continue;
10691070

@@ -1096,14 +1097,14 @@ void ObjcCategoryMerger::generateCatListForNonErasedCategories(
10961097
catListToErasedOffsets) {
10971098

10981099
// Go through all offsets of all __objc_catlist's that we process and if there
1099-
// are categories that we didn't process - generate a new __objv_catlist for
1100+
// are categories that we didn't process - generate a new __objc_catlist for
11001101
// each.
11011102
for (auto &mapEntry : catListToErasedOffsets) {
11021103
ConcatInputSection *catListIsec = mapEntry.first;
11031104
for (uint32_t catListIsecOffset = 0;
11041105
catListIsecOffset < catListIsec->data.size();
11051106
catListIsecOffset += target->wordSize) {
1106-
// This slot was erased, we can jsut skip it
1107+
// This slot was erased, we can just skip it
11071108
if (mapEntry.second.count(catListIsecOffset))
11081109
continue;
11091110

lld/test/MachO/objc-category-merging-complete-test.s

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# RUN: rm -rf %t; split-file %s %t && cd %t
33

44
## Create a dylib to link against(a64_file1.dylib) and merge categories in the main binary (file2_merge_a64.exe)
5-
# RUN: llvm-mc -filetype=obj -triple=arm64-ios-simulator -o a64_file1.o a64_file1.s
6-
# RUN: ld64.lld a64_file1.o -o a64_file1.dylib -dylib -arch arm64 -platform_version ios-simulator 14.0 15.0
5+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o a64_file1.o a64_file1.s
6+
# RUN: %lld -arch arm64 a64_file1.o -o a64_file1.dylib -dylib
77

8-
# RUN: llvm-mc -filetype=obj -triple=arm64-ios-simulator -o a64_file2.o a64_file2.s
9-
# RUN: ld64.lld -o a64_file2_no_merge.exe a64_file1.dylib a64_file2.o -arch arm64 -platform_version ios-simulator 14.0 15.0
10-
# RUN: ld64.lld -o a64_file2_merge.exe -objc_category_merging a64_file1.dylib a64_file2.o -arch arm64 -platform_version ios-simulator 14.0 15.0
8+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o a64_file2.o a64_file2.s
9+
# RUN: %lld -arch arm64 -o a64_file2_no_merge.exe a64_file1.dylib a64_file2.o
10+
# RUN: %lld -arch arm64 -o a64_file2_merge.exe -objc_category_merging a64_file1.dylib a64_file2.o
1111

1212
# RUN: llvm-objdump --objc-meta-data --macho a64_file2_no_merge.exe | FileCheck %s --check-prefixes=NO_MERGE_CATS
1313
# RUN: llvm-objdump --objc-meta-data --macho a64_file2_merge.exe | FileCheck %s --check-prefixes=MERGE_CATS
@@ -124,7 +124,6 @@ NO_MERGE_CATS-NEXT: 2
124124
## void *_objc_empty_cache;
125125

126126
.section __TEXT,__text,regular,pure_instructions
127-
.ios_version_min 7, 0
128127
.p2align 2 ; -- Begin function -[MyBaseClass baseInstanceMethod]
129128
"-[MyBaseClass baseInstanceMethod]": ; @"\01-[MyBaseClass baseInstanceMethod]"
130129
.cfi_startproc
@@ -438,7 +437,6 @@ L_OBJC_IMAGE_INFO:
438437

439438

440439
.section __TEXT,__text,regular,pure_instructions
441-
.ios_version_min 7, 0
442440
.p2align 2 ; -- Begin function -[MyBaseClass(Category02) class02InstanceMethod]
443441
"-[MyBaseClass(Category02) class02InstanceMethod]": ; @"\01-[MyBaseClass(Category02) class02InstanceMethod]"
444442
.cfi_startproc

lld/test/MachO/objc-category-merging-extern-class-minimal.s

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# RUN: rm -rf %t; split-file %s %t && cd %t
33

44
## Create a dylib with a fake base class to link against
5-
# RUN: llvm-mc -filetype=obj -triple=arm64-ios-simulator -o a64_fakedylib.o a64_fakedylib.s
6-
# RUN: ld64.lld a64_fakedylib.o -o a64_fakedylib.dylib -dylib -arch arm64 -platform_version ios-simulator 14.0 15.0
5+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o a64_fakedylib.o a64_fakedylib.s
6+
# RUN: %lld -arch arm64 a64_fakedylib.o -o a64_fakedylib.dylib -dylib
77

88
## Create our main testing dylib - linking against the fake dylib above
9-
# RUN: llvm-mc -filetype=obj -triple=arm64-ios-simulator -o merge_cat_minimal.o merge_cat_minimal.s
10-
# RUN: ld64.lld -dylib -o merge_cat_minimal_no_merge.dylib a64_fakedylib.dylib merge_cat_minimal.o -arch arm64 -platform_version ios-simulator 14.0 15.0
11-
# RUN: ld64.lld -dylib -o merge_cat_minimal_merge.dylib -objc_category_merging a64_fakedylib.dylib merge_cat_minimal.o -arch arm64 -platform_version ios-simulator 14.0 15.0
9+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o merge_cat_minimal.o merge_cat_minimal.s
10+
# RUN: %lld -arch arm64 -dylib -o merge_cat_minimal_no_merge.dylib a64_fakedylib.dylib merge_cat_minimal.o
11+
# RUN: %lld -arch arm64 -dylib -o merge_cat_minimal_merge.dylib -objc_category_merging a64_fakedylib.dylib merge_cat_minimal.o
1212

1313
## Now verify that the flag caused category merging to happen appropriatelly
1414
# RUN: llvm-objdump --objc-meta-data --macho merge_cat_minimal_no_merge.dylib | FileCheck %s --check-prefixes=NO_MERGE_CATS
@@ -78,7 +78,6 @@ _OBJC_CLASS_$_MyBaseClass:
7878
; ================== Generated from ObjC: ==================
7979

8080
.section __TEXT,__text,regular,pure_instructions
81-
.ios_version_min 7, 0
8281
.p2align 2 ; -- Begin function -[MyBaseClass(Category01) cat01_InstanceMethod]
8382
"-[MyBaseClass(Category01) cat01_InstanceMethod]": ; @"\01-[MyBaseClass(Category01) cat01_InstanceMethod]"
8483
.cfi_startproc

0 commit comments

Comments
 (0)