Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -549,9 +549,12 @@ template void SymbolTable::scanShlibUndefined() { for (SharedFile *File : SharedFiles) for (StringRef U : File->getUndefinedSymbols()) - if (SymbolBody *Sym = find(U)) + if (SymbolBody *Sym = find(U)) { if (Sym->isDefined()) Sym->symbol()->ExportDynamic = true; + else if (Sym->isLazy()) + addUndefined(U); + } } // This function processes --export-dynamic-symbol and --dynamic-list. Index: test/ELF/Inputs/shared4.s =================================================================== --- test/ELF/Inputs/shared4.s +++ test/ELF/Inputs/shared4.s @@ -0,0 +1,3 @@ +.globl _shared +_shared: + call _start@plt Index: test/ELF/shared-lazy.s =================================================================== --- test/ELF/shared-lazy.s +++ test/ELF/shared-lazy.s @@ -0,0 +1,10 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/archive.s -o %t2.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared4.s -o %t3.o +# RUN: llvm-ar rcs %t2.a %t2.o +# RUN: ld.lld -shared %t3.o -o %t3.so +# RUN: ld.lld -shared %t.o %t2.a %t3.so -o %t.so +# RUN: llvm-objdump -t %t.so | FileCheck --check-prefix=DEFINED %s + +# DEFINED: _start +call _entry@plt