[lld] [lld-macho] Make category merging symbol names match ld64 (PR #90864)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 2 10:47:15 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-macho
Author: None (alx32)
<details>
<summary>Changes</summary>
When generating symbols for various category constructs, make sure the symbol names match the format of those generated by ld64 when it does category merging.
---
Full diff: https://github.com/llvm/llvm-project/pull/90864.diff
3 Files Affected:
- (modified) lld/MachO/ObjC.cpp (+3-3)
- (modified) lld/test/MachO/objc-category-merging-complete-test.s (+2-2)
- (modified) lld/test/MachO/objc-category-merging-extern-class-minimal.s (+2-2)
``````````diff
diff --git a/lld/MachO/ObjC.cpp b/lld/MachO/ObjC.cpp
index 95fe0c9374f150..1a480d1a36e8ad 100644
--- a/lld/MachO/ObjC.cpp
+++ b/lld/MachO/ObjC.cpp
@@ -795,7 +795,7 @@ void ObjcCategoryMerger::emitAndLinkProtocolList(
listSec->parent = infoCategoryWriter.catPtrListInfo.outputSection;
std::string symName = ptrList.categoryPrefix;
- symName += extInfo.baseClassName + "_$_(" + extInfo.mergedContainerName + ")";
+ symName += extInfo.baseClassName + "(" + extInfo.mergedContainerName + ")";
Defined *ptrListSym = make<Defined>(
newStringData(symName.c_str()), /*file=*/parentSym->getObjectFile(),
@@ -853,7 +853,7 @@ void ObjcCategoryMerger::emitAndLinkPointerList(
listSec->parent = infoCategoryWriter.catPtrListInfo.outputSection;
std::string symName = ptrList.categoryPrefix;
- symName += extInfo.baseClassName + "_$_" + extInfo.mergedContainerName;
+ symName += extInfo.baseClassName + "(" + extInfo.mergedContainerName + ")";
Defined *ptrListSym = make<Defined>(
newStringData(symName.c_str()), /*file=*/parentSym->getObjectFile(),
@@ -930,7 +930,7 @@ Defined *ObjcCategoryMerger::emitCategoryBody(const std::string &name,
addInputSection(newBodySec);
std::string symName =
- objc::symbol_names::category + baseClassName + "_$_(" + name + ")";
+ objc::symbol_names::category + baseClassName + "(" + name + ")";
Defined *catBodySym = make<Defined>(
newStringData(symName.c_str()), /*file=*/objFile, newBodySec,
/*value=*/0, bodyData.size(), /*isWeakDef=*/false, /*isExternal=*/false,
diff --git a/lld/test/MachO/objc-category-merging-complete-test.s b/lld/test/MachO/objc-category-merging-complete-test.s
index 3bc3ca26b6ae6c..d2d264a3f26c2d 100644
--- a/lld/test/MachO/objc-category-merging-complete-test.s
+++ b/lld/test/MachO/objc-category-merging-complete-test.s
@@ -13,7 +13,7 @@
# RUN: llvm-objdump --objc-meta-data --macho a64_file2_merge.exe | FileCheck %s --check-prefixes=MERGE_CATS
-MERGE_CATS: __OBJC_$_CATEGORY_MyBaseClass_$_(Category02|Category03)
+MERGE_CATS: __OBJC_$_CATEGORY_MyBaseClass(Category02|Category03)
MERGE_CATS-NEXT: name {{.*}} Category02|Category03
MERGE_CATS: instanceMethods
MERGE_CATS-NEXT: entsize 24
@@ -90,7 +90,7 @@ MERGE_CATS-NEXT: name {{.*}} MyProtocol03Prop
MERGE_CATS-NEXT: attributes {{.*}} Ti,R,D
-NO_MERGE_CATS-NOT: __OBJC_$_CATEGORY_MyBaseClass_$_(Category02|Category03)
+NO_MERGE_CATS-NOT: __OBJC_$_CATEGORY_MyBaseClass(Category02|Category03)
NO_MERGE_CATS: __OBJC_$_CATEGORY_MyBaseClass_$_Category02
NO_MERGE_CATS: instanceMethods
NO_MERGE_CATS-NEXT: 24
diff --git a/lld/test/MachO/objc-category-merging-extern-class-minimal.s b/lld/test/MachO/objc-category-merging-extern-class-minimal.s
index ede7ef5d9c32d4..ea79f29a421c5c 100644
--- a/lld/test/MachO/objc-category-merging-extern-class-minimal.s
+++ b/lld/test/MachO/objc-category-merging-extern-class-minimal.s
@@ -20,7 +20,7 @@ MERGE_CATS-NOT: __OBJC_$_CATEGORY_MyBaseClass_$_Category01
MERGE_CATS-NOT: __OBJC_$_CATEGORY_MyBaseClass_$_Category02
# Check that the merged cateogry is there, in the correct format
-MERGE_CATS: __OBJC_$_CATEGORY_MyBaseClass_$_(Category01|Category02)
+MERGE_CATS: __OBJC_$_CATEGORY_MyBaseClass(Category01|Category02)
MERGE_CATS-NEXT: name {{.*}} Category01|Category02
MERGE_CATS: instanceMethods
MERGE_CATS-NEXT: 24
@@ -37,7 +37,7 @@ MERGE_CATS-NEXT: instanceProperties 0x0
#### Check merge categories disabled ###
# Check that the merged category is not there
-NO_MERGE_CATS-NOT: __OBJC_$_CATEGORY_MyBaseClass_$_(Category01|Category02)
+NO_MERGE_CATS-NOT: __OBJC_$_CATEGORY_MyBaseClass(Category01|Category02)
# Check that the original categories are there
NO_MERGE_CATS: __OBJC_$_CATEGORY_MyBaseClass_$_Category01
``````````
</details>
https://github.com/llvm/llvm-project/pull/90864
More information about the llvm-commits
mailing list