[lld] [lld-macho] Add support for category names in ConcatInputSection's (PR #90850)
Kyungwoo Lee via llvm-commits
llvm-commits at lists.llvm.org
Sun May 5 08:55:46 PDT 2024
================
@@ -186,13 +186,23 @@ 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 CStringInputSection or a
+// 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);
+ if (auto *s = dyn_cast_or_null<CStringInputSection>(sym->isec()))
----------------
kyulee-com wrote:
nit: it seems `sym->isec()` is being used in the following code. Can we replace them by a variable? Perhaps the similar thing for `sym->value + r.addend` which seems representing an offset.
```suggestion
auto *isec = sym->isec();
auto offset = sym->value + r.addend;
if (auto *s = dyn_cast_or_null<CStringInputSection>(isec))
return s->getStringRefAtOffset(offset);
if (isa<ConcatInputSection>(isec)) {
auto strData = isec->data.slice(offset);
uint32_t len = strnlen((const char *)strData.data(), strData.size());
return StringRef((const char *)strData.data(), len);
}
```
https://github.com/llvm/llvm-project/pull/90850
More information about the llvm-commits
mailing list