Index: lld/trunk/ELF/Config.h =================================================================== --- lld/trunk/ELF/Config.h +++ lld/trunk/ELF/Config.h @@ -89,6 +89,7 @@ bool VersionScript = false; bool WarnCommon; bool ZCombreloc; + bool ZDefs; bool ZExecStack; bool ZNodelete; bool ZNow; Index: lld/trunk/ELF/Driver.cpp =================================================================== --- lld/trunk/ELF/Driver.cpp +++ lld/trunk/ELF/Driver.cpp @@ -353,6 +353,7 @@ error("number of threads must be > 0"); Config->ZCombreloc = !hasZOption(Args, "nocombreloc"); + Config->ZDefs = hasZOption(Args, "defs"); Config->ZExecStack = hasZOption(Args, "execstack"); Config->ZNodelete = hasZOption(Args, "nodelete"); Config->ZNow = hasZOption(Args, "now"); Index: lld/trunk/ELF/Writer.cpp =================================================================== --- lld/trunk/ELF/Writer.cpp +++ lld/trunk/ELF/Writer.cpp @@ -793,7 +793,7 @@ if (!Config->NoUndefined) { if (Config->Relocatable) return; - if (Config->Shared) + if (Config->Shared && !Config->ZDefs) if (Sym->symbol()->Visibility == STV_DEFAULT) return; } Index: lld/trunk/test/ELF/zdefs.s =================================================================== --- lld/trunk/test/ELF/zdefs.s +++ lld/trunk/test/ELF/zdefs.s @@ -0,0 +1,7 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld -shared %t.o -o %t1.so + +# RUN: not ld.lld -z defs -shared %t.o -o %t1.so 2>&1 | FileCheck -check-prefix=ERR %s +# ERR: undefined symbol: foo + +callq foo@PLT