[PATCH] D102099: [lld-macho] exported symbols can also be lazy

Greg McGary via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 7 18:34:37 PDT 2021


gkm updated this revision to Diff 343796.
gkm added a comment.

- update test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102099/new/

https://reviews.llvm.org/D102099

Files:
  lld/MachO/Driver.cpp
  lld/test/MachO/export-options.s


Index: lld/test/MachO/export-options.s
===================================================================
--- lld/test/MachO/export-options.s
+++ lld/test/MachO/export-options.s
@@ -2,6 +2,8 @@
 
 # RUN: split-file %s %t
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %t/default.s -o %t/default.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos %t/lazydef.s -o %t/lazydef.o
+# RUN: llvm-ar --format=darwin rcs %t/lazydef.a %t/lazydef.o
 
 ## Check that mixing exported and unexported symbol options yields an error
 # RUN: not %lld -dylib %t/default.o -o /dev/null \
@@ -11,15 +13,17 @@
 # CONFLICT: error: cannot use both -exported_symbol* and -unexported_symbol* options
 # CONFLICT-NEXT: >>> ignoring unexports
 
-## Check that exported literal symbol name is present in symbol table
-# RUN: not %lld -dylib %t/default.o -o /dev/null \
-# RUN:         -exported_symbol absent_literal \
-# RUN:         -exported_symbol absent_gl?b 2>&1 | \
+## Check that exported literal Defined and LazySymbol names are present in symbol table
+# RUN: not %lld -dylib %t/default.o %t/lazydef.a -o /dev/null \
+# RUN:         -exported_symbol _present_lazy \
+# RUN:         -exported_symbol _absent_literal \
+# RUN:         -exported_symbol _absent_gl?b 2>&1 | \
 # RUN:     FileCheck --check-prefix=UNDEF %s
 
-# UNDEF: error: undefined symbol absent_literal
+# UNDEF: error: undefined symbol _absent_literal
 # UNDEF-NEXT: >>> referenced from option -exported_symbol(s_list)
-# UNDEF-NOT: error: {{.*}} absent_gl{{.}}b
+# UNDEF-NOT: error: undefined symbol _present_lazy
+# UNDEF-NOT: error: {{.*}} _absent_gl{{.}}b
 
 ## Check that exported symbol is global
 # RUN: not %lld -dylib %t/default.o -o /dev/null \
@@ -41,6 +45,12 @@
 _private:
   retq
 
+#--- lazydef.s
+
+.globl _present_lazy
+_present_lazy:
+  retq
+
 ## Check that the export trie is unaltered
 # RUN: %lld -dylib %t/default.o -o %t/default
 # RUN: llvm-objdump --macho --exports-trie %t/default | \
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1155,7 +1155,7 @@
     for (const CachedHashStringRef &cachedName :
          config->exportedSymbols.literals) {
       if (const Symbol *sym = symtab->find(cachedName))
-        if (isa<Defined>(sym))
+        if (isa<Defined>(sym) || isa<LazySymbol>(sym))
           continue;
       error("undefined symbol " + cachedName.val() +
             "\n>>> referenced from option -exported_symbol(s_list)");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102099.343796.patch
Type: text/x-patch
Size: 2533 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210508/4fd54cb6/attachment.bin>


More information about the llvm-commits mailing list