diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -1155,7 +1155,7 @@ for (const CachedHashStringRef &cachedName : config->exportedSymbols.literals) { if (const Symbol *sym = symtab->find(cachedName)) - if (isa(sym)) + if (isa(sym) || isa(sym)) continue; error("undefined symbol " + cachedName.val() + "\n>>> referenced from option -exported_symbol(s_list)"); diff --git a/lld/test/MachO/export-options.s b/lld/test/MachO/export-options.s --- a/lld/test/MachO/export-options.s +++ b/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 | \