[lld] [llvm] [lld] Fix -ObjC load behavior with LTO for section names with whitespace (PR #146654)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 12:58:45 PDT 2025
================
@@ -293,10 +293,21 @@ static Expected<bool> hasObjCCategoryInModule(BitstreamCursor &Stream) {
std::string S;
if (convertToString(Record, 0, S))
return error("Invalid section name record");
+
// Check for the i386 and other (x86_64, ARM) conventions
- if (S.find("__DATA,__objc_catlist") != std::string::npos ||
- S.find("__OBJC,__category") != std::string::npos ||
- S.find("__TEXT,__swift") != std::string::npos)
+
+ SmallVector<StringRef, 2> SplitName;
+ StringRef(S).split(SplitName, ',');
+ if (SplitName.size() < 2)
+ break;
+ StringRef Segment = SplitName[0].trim();
+ StringRef Section = SplitName[1].trim();
----------------
ellishg wrote:
Do you ever expect more than one comma? If not I think we can do this
```suggestion
auto [Segment, Section] = StringRef(S).split(",");
Segment = Segment.trim();
Section = Section.trim();
```
And we don't need to check if `Section` is empty because it won't match any of the below cases anyway
https://github.com/llvm/llvm-project/pull/146654
More information about the llvm-commits
mailing list