[lld] [lld-macho] icf objc stubs (PR #79730)
Jez Ng via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 29 16:51:18 PST 2024
================
@@ -814,11 +814,54 @@ ObjCStubsSection::ObjCStubsSection()
: target->objcStubsSmallAlignment;
}
+bool ObjCStubsSection::isObjCStubSymbol(Symbol *sym) {
+ return sym->getName().starts_with(symbolPrefix);
+}
+
+StringRef ObjCStubsSection::getMethName(Symbol *sym) {
+ assert(isObjCStubSymbol(sym) && "not an objc stub");
+ auto name = sym->getName();
+ StringRef methname = name.drop_front(symbolPrefix.size());
+ return methname;
+}
+
+void ObjCStubsSection::initialize() {
+ // Do not fold selrefs without ICF.
+ if (config->icfLevel == ICFLevel::none)
+ return;
+
+ // Search methnames already referenced in __objc_selrefs
+ // Map the name to the corresponding selref entry
+ // which we will reuse when creating objc stubs.
+ for (ConcatInputSection *isec : inputSections) {
+ if (isec->shouldOmitFromOutput())
+ continue;
+ if (isec->getName() != "__objc_selrefs")
----------------
int3 wrote:
s/"__objc_selrefs"/section_names::objcSelrefs/
https://github.com/llvm/llvm-project/pull/79730
More information about the llvm-commits
mailing list