[lld] [lld-macho] Ignore labels on sections ld64 treats as ignoreLabel (PR #194275)

Vy Nguyen via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 29 09:32:15 PDT 2026


================
@@ -0,0 +1,97 @@
+# REQUIRES: aarch64
+
+## ld64's PointerToCStringSection / ObjC2ClassRefsSection / CFStringSection
+## have `ignoreLabel=true`. Labels on records in these sections never become
+## named atoms. When LLD treated such labels as external symbols, an
+## identically-named symbol in another section (e.g. a cstring in
+## __objc_methname) would trigger the `replaceSymbol` path in
+## SymbolTable::addDefined. That silently replaced the Defined in-place with
+## the other-section's state while leaving stale pointers in the record-split
+## subsection's symbols list. ICF::foldIdentical then asserted
+## `(*it)->value == 0` because the stale Defineds carried the other section's
+## offsets.
+##
+## This test exercises exactly that shape: labels `l005` / `l007` appear both
+## on an __objc_selrefs record and on cstring pieces in another TU.
+
+# RUN: rm -rf %t && split-file %s %t
+
+# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/m.s  -o %t/m.o
+# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/o.s  -o %t/o.o
+# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/e1.s -o %t/e1.o
+# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/e2.s -o %t/e2.o
+# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/e3.s -o %t/e3.o
+
+# RUN: %lld -arch arm64 -lSystem --icf=all -dylib %t/m.o %t/e1.o %t/e2.o %t/e3.o %t/o.o -o %t/out.dylib
+
----------------
oontvoo wrote:

Would you be willing to add a quick CHECK here to verify that there's indeed no symbols?

Eg.,   `llvm-otool -v -s __TEXT __cstring  %t/out.dylib` (or `llvm-nm %t/out.dylib` )

https://github.com/llvm/llvm-project/pull/194275


More information about the llvm-commits mailing list