[lld] [lld-macho] Implement ObjC category merging (-objc_category_merging) (PR #82928)
Kyungwoo Lee via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 29 07:34:36 PST 2024
================
@@ -176,13 +187,22 @@ ObjcCategoryChecker::ObjcCategoryChecker()
roClassLayout(target->wordSize), listHeaderLayout(target->wordSize),
methodLayout(target->wordSize) {}
-// \p r must point to an offset within a cstring section.
+// \p r must point to an offset within a cstring section or ConcatInputSection
static StringRef getReferentString(const Reloc &r) {
if (auto *isec = r.referent.dyn_cast<InputSection *>())
return cast<CStringInputSection>(isec)->getStringRefAtOffset(r.addend);
auto *sym = cast<Defined>(r.referent.get<Symbol *>());
- return cast<CStringInputSection>(sym->isec)->getStringRefAtOffset(sym->value +
- r.addend);
+ uint32_t dataOff = sym->value + r.addend;
+ if (auto *cisec = dyn_cast<ConcatInputSection>(sym->isec)) {
+ uint32_t buffSize = cisec->data.size();
+ const char *pszBuff = reinterpret_cast<const char *>(cisec->data.data());
+ assert(dataOff < buffSize);
+ uint32_t sLen = strnlen(pszBuff + dataOff, buffSize - dataOff);
----------------
kyulee-com wrote:
I thought about creating a separate function instead of jamming this logic here. Given it's unrelated to this PR, moving it out of this PR would be okay as you commented.
https://github.com/llvm/llvm-project/pull/82928
More information about the llvm-commits
mailing list